From 76e40d7be239893dbf9844515392779c3ab2fba0 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Mon, 6 May 2019 21:02:57 -0700 Subject: ShellPkg/UefiShellBcfgCommandLib: Fix '-opt' option For all other bcfg commands the "#" (option number) argument(s) are treated as hexedecimal values regardless of whether or not they are prefixed by "0x". This change fixes '-opt' to handle its "#" (option number) argument consistently with the other commands. Making this change removes a potential footgun whereby a user that has been using a number without a "0x" prefix with other bcfg commands finds that, on using that exact same number with '-opt', it has this time unexpectedly been interpreted as a decimal number and they have modified (corrupted) an unrelated load option. For example, a user may have been specifying "10" to other commands to have them act on the 16th option (because simply "10", without any prefix, is how 'bcfg boot dump' displayed the option number for the 16th option). Unfortunately for them, if they also use '-opt' with "10" it would unexpectedly and inconsistently act on the 10th option. CC: Jaben Carsey CC: Ray Ni Signed-off-by: Jonathan Watt Reviewed-by: Zhichao Gao Reviewed-by: Jaben Carsey Reviewed-by: Bi Dandan --- ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c') diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c index d033c7c1dc..e8b48b4990 100644 --- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c +++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c @@ -1019,7 +1019,7 @@ BcfgAddOpt( // // Get the index of the variable we are changing. // - Status = ShellConvertStringToUint64(Walker, &Intermediate, FALSE, TRUE); + Status = ShellConvertStringToUint64(Walker, &Intermediate, TRUE, TRUE); if (EFI_ERROR(Status) || (((UINT16)Intermediate) != Intermediate) || StrStr(Walker, L" ") == NULL || ((UINT16)Intermediate) > ((UINT16)OrderCount)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"Option Index"); ShellStatus = SHELL_INVALID_PARAMETER; -- cgit v1.2.3