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

ivanhu ivan.hu at canonical.com
Fri Mar 27 03:27:54 UTC 2015


This patch had already been sent and got 2 acks, any differences from 
the last one?

On 2015年03月27日 11:06, 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);
>   	}
>   }
>   




More information about the fwts-devel mailing list