ACK: [PATCH] uefi: uefidump: don't dump non-printable variable contents (LP: #1435346)

Alex Hung alex.hung at canonical.com
Wed Mar 25 03:12:14 UTC 2015


On 03/23/2015 10:58 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Do a hex dump of kernel dump UEFI vars if the contents is
> not printable ASCII.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/uefi/uefidump/uefidump.c | 32 ++++++++++++++++++++++++--------
>  1 file changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 8421e72..014abe2 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -768,19 +768,35 @@ static void uefidump_info_dump_type0(fwts_framework *fw, fwts_uefi_var *var)
>  {
>  	char *ptr = (char*)var->data;
>  	size_t len = var->datalen;
> +	bool printable = true;
>  
>  	while (len && *ptr) {
> -		char *start = ptr;
> -		while (len && *ptr && *ptr != '\n') {
> -			ptr++;
> -			len--;
> +		if (!(isspace(*ptr) || isprint(*ptr))) {
> +			printable = false;
> +			break;
>  		}
> +		ptr++;
> +		len--;
> +	}
>  
> -		if (*ptr == '\n') {
> -			*ptr++ = '\0';
> -			len--;
> -			fwts_log_info_verbatum(fw, "  KLog: %s.", start);
> +	ptr = (char*)var->data;
> +	len = var->datalen;
> +
> +	if (printable) {
> +		while (len && *ptr) {
> +			char *start = ptr;
> +			while (len && *ptr && *ptr != '\n') {
> +				ptr++;
> +				len--;
> +			}
> +			if (*ptr == '\n') {
> +				*ptr++ = '\0';
> +				len--;
> +				fwts_log_info_verbatum(fw, "  KLog: %s.", start);
> +			}
>  		}
> +	} else {
> +		uefidump_var_hexdump(fw, var);
>  	}
>  }
>  
> 

Acked-by: Alex Hung <alex.hung at canonical.com>

-- 
Cheers,
Alex Hung



More information about the fwts-devel mailing list