diff mbox

uefi: uefidump: fix the boot load option Boot#### larger than Boot1000 doesn't be parsered (LP:#1225850)

Message ID 1379314035-8872-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu Sept. 16, 2013, 6:47 a.m. UTC
Some firmware/BIOS create the Boot path not in order, some of Boot load options
are created larger than "Boot1000", such as Boot1001, Boot2001 etc. The uefidump
checks the boot path with the "Boot0" causes these Boot load options cannot be
parsered.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/uefi/uefidump/uefidump.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Colin Ian King Sept. 16, 2013, 8:04 a.m. UTC | #1
On 16/09/13 07:47, Ivan Hu wrote:
> Some firmware/BIOS create the Boot path not in order, some of Boot load options
> are created larger than "Boot1000", such as Boot1001, Boot2001 etc. The uefidump
> checks the boot path with the "Boot0" causes these Boot load options cannot be
> parsered.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefidump/uefidump.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index c072847..e4b6546 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -18,6 +18,7 @@
>   */
>  #include <stddef.h>
>  #include <inttypes.h>
> +#include <ctype.h>
>  
>  #include "fwts.h"
>  #include "fwts_uefi.h"
> @@ -747,7 +748,6 @@ static uefidump_info uefidump_info_table[] = {
>  	{ "LangCodes",		uefidump_info_langcodes },
>  	{ "Lang",		uefidump_info_lang },
>  	{ "Timeout",		uefidump_info_timeout },
> -	{ "Boot0",		uefidump_info_bootdev },
>  	{ "dump-type0-",	uefidump_info_dump_type0 },
>  	{ "SecureBoot",		uefidump_info_secure_boot },
>  	{ "SetupMode",		uefidump_info_setup_mode },
> @@ -781,6 +781,14 @@ static void uefidump_var(fwts_framework *fw, fwts_uefi_var *var)
>  		}
>  	}
>  
> +	/* Check the boot load option Boot####. #### is a printed hex value */
> +	if ((strlen(varname) == 8) && (strncmp(varname, "Boot", 4) == 0)
> +			&& isxdigit(varname[4]) && isxdigit(varname[5])
> +			&& isxdigit(varname[6]) && isxdigit(varname[7])) {
> +		uefidump_info_bootdev(fw, var);
> +		return;
> +	}
> +
>  	/* otherwise just do a plain old hex dump */
>  	uefidump_var_hexdump(fw, var);
>  }
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung Oct. 3, 2013, 1:03 a.m. UTC | #2
On 09/16/2013 02:47 PM, Ivan Hu wrote:
> Some firmware/BIOS create the Boot path not in order, some of Boot load options
> are created larger than "Boot1000", such as Boot1001, Boot2001 etc. The uefidump
> checks the boot path with the "Boot0" causes these Boot load options cannot be
> parsered.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c |   10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index c072847..e4b6546 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -18,6 +18,7 @@
>    */
>   #include <stddef.h>
>   #include <inttypes.h>
> +#include <ctype.h>
>
>   #include "fwts.h"
>   #include "fwts_uefi.h"
> @@ -747,7 +748,6 @@ static uefidump_info uefidump_info_table[] = {
>   	{ "LangCodes",		uefidump_info_langcodes },
>   	{ "Lang",		uefidump_info_lang },
>   	{ "Timeout",		uefidump_info_timeout },
> -	{ "Boot0",		uefidump_info_bootdev },
>   	{ "dump-type0-",	uefidump_info_dump_type0 },
>   	{ "SecureBoot",		uefidump_info_secure_boot },
>   	{ "SetupMode",		uefidump_info_setup_mode },
> @@ -781,6 +781,14 @@ static void uefidump_var(fwts_framework *fw, fwts_uefi_var *var)
>   		}
>   	}
>
> +	/* Check the boot load option Boot####. #### is a printed hex value */
> +	if ((strlen(varname) == 8) && (strncmp(varname, "Boot", 4) == 0)
> +			&& isxdigit(varname[4]) && isxdigit(varname[5])
> +			&& isxdigit(varname[6]) && isxdigit(varname[7])) {
> +		uefidump_info_bootdev(fw, var);
> +		return;
> +	}
> +
>   	/* otherwise just do a plain old hex dump */
>   	uefidump_var_hexdump(fw, var);
>   }
>

Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index c072847..e4b6546 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -18,6 +18,7 @@ 
  */
 #include <stddef.h>
 #include <inttypes.h>
+#include <ctype.h>
 
 #include "fwts.h"
 #include "fwts_uefi.h"
@@ -747,7 +748,6 @@  static uefidump_info uefidump_info_table[] = {
 	{ "LangCodes",		uefidump_info_langcodes },
 	{ "Lang",		uefidump_info_lang },
 	{ "Timeout",		uefidump_info_timeout },
-	{ "Boot0",		uefidump_info_bootdev },
 	{ "dump-type0-",	uefidump_info_dump_type0 },
 	{ "SecureBoot",		uefidump_info_secure_boot },
 	{ "SetupMode",		uefidump_info_setup_mode },
@@ -781,6 +781,14 @@  static void uefidump_var(fwts_framework *fw, fwts_uefi_var *var)
 		}
 	}
 
+	/* Check the boot load option Boot####. #### is a printed hex value */
+	if ((strlen(varname) == 8) && (strncmp(varname, "Boot", 4) == 0)
+			&& isxdigit(varname[4]) && isxdigit(varname[5])
+			&& isxdigit(varname[6]) && isxdigit(varname[7])) {
+		uefidump_info_bootdev(fw, var);
+		return;
+	}
+
 	/* otherwise just do a plain old hex dump */
 	uefidump_var_hexdump(fw, var);
 }