[PATCH 2/3] uefi: uefidump: add support for Driver#### (LP:#1237263)

Colin Ian King colin.king at canonical.com
Wed Oct 9 11:04:05 UTC 2013


I've not been able to test this one, just a few comments below..

On 09/10/13 09:48, Ivan Hu wrote:
> Add support for Driver#### - Each Driver#### variable contains
> an EFI_LOAD_OPTION. Each load option variable is appended with
> a unique number, for example Driver0001, Driver0002, etc.
> 
> This patch also modify the defination of FWTS_UEFI_LOAD_ACTIVE
> correspond to the UEFI spec.
> 
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |    3 ++-
>  src/uefi/uefidump/uefidump.c |   32 +++++++++++++++++++++++++++++++-
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index ecac84d..d38903e 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -20,7 +20,8 @@
>  #ifndef __FWTS_UEFI_H__
>  #define __FWTS_UEFI_H__
>  
> -#define FWTS_UEFI_LOAD_ACTIVE 0x00000001
> +#define FWTS_UEFI_LOAD_OPTION_ACTIVE 		0x00000001
> +#define FWTS_UEFI_LOAD_OPTION_FORCE_RECONNECT 	0x00000002
>  
>  typedef struct {
>  	uint16_t	*varname;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index a2aa619..4a736c9 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -508,7 +508,7 @@ static void uefidump_info_bootdev(fwts_framework *fw, fwts_uefi_var *var)
>  	int len;
>  
>  	fwts_log_info_verbatum(fw, "  Active: %s\n",
> -		(load_option->attributes & FWTS_UEFI_LOAD_ACTIVE) ? "Yes" : "No");
> +		(load_option->attributes & FWTS_UEFI_LOAD_OPTION_ACTIVE) ? "Yes" : "No");
>  	fwts_uefi_str16_to_str(tmp, sizeof(tmp), load_option->description);
>  	len = fwts_uefi_str16len(load_option->description);
>  	fwts_log_info_verbatum(fw, "  Info: %s\n", tmp);
> @@ -746,6 +746,28 @@ static void uefidump_info_driverorder(fwts_framework *fw, fwts_uefi_var *var)
>  	free(str);
>  }
>  
> +static void uefidump_info_driverdev(fwts_framework *fw, fwts_uefi_var *var)
> +{
> +	fwts_uefi_load_option * load_option = (fwts_uefi_load_option *)var->data;
> +	char tmp[2048];
> +	char *path;
> +	int len;
> +
> +	fwts_log_info_verbatum(fw, "  Force Reconnect: %s\n",
> +		(load_option->attributes & FWTS_UEFI_LOAD_OPTION_FORCE_RECONNECT) ? "Yes" : "No");
> +	fwts_uefi_str16_to_str(tmp, sizeof(tmp), load_option->description);

You are assuming that the variable data is long enough to do this
dereferencing description on load_option.  Can you check first if var is
long enough before doing this?

> +	len = fwts_uefi_str16len(load_option->description);
> +	fwts_log_info_verbatum(fw, "  Info: %s\n", tmp);
> +
> +	/* Skip over description to get to packed path, unpack path and print */
> +	path = (char *)var->data + sizeof(load_option->attributes) +
> +		sizeof(load_option->file_path_list_length) +
> +		(sizeof(uint16_t) * (len + 1));

As above with load_option->attributes on the dereferencing.

> +	path = uefidump_build_dev_path(NULL, (fwts_uefi_dev_path *)path);
> +	fwts_log_info_verbatum(fw, "  Path: %s.", path);
> +	free(path);
> +}
> +
>  static uefidump_info uefidump_info_table[] = {
>  	{ "PlatformLangCodes",	uefidump_info_platform_langcodes },
>  	{ "PlatformLang",	uefidump_info_platform_lang },
> @@ -805,6 +827,14 @@ static void uefidump_var(fwts_framework *fw, fwts_uefi_var *var)
>  		return;
>  	}
>  
> +	/* Check the driver load option Driver####. #### is a printed hex value */
> +	if ((strlen(varname) == 10) && (strncmp(varname, "Driver", 6) == 0)
> +			&& isxdigit(varname[6]) && isxdigit(varname[7])
> +			&& isxdigit(varname[8]) && isxdigit(varname[9])) {
> +		uefidump_info_driverdev(fw, var);
> +		return;
> +	}
> +
>  	/* otherwise just do a plain old hex dump */
>  	uefidump_var_hexdump(fw, var);
>  }
> 




More information about the fwts-devel mailing list