From 6855763eb262f3d95dc0216d035cc7203b4e29cc Mon Sep 17 00:00:00 2001 From: Chris Phillips Date: Mon, 2 Dec 2013 21:45:28 +0000 Subject: [PATCH] ShellPkg: Fix pci command to parse seg, bus, dev, and func arguments as hex - Added STR_GEN_PARAM_INV_HEX string Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14926 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/UefiShellDebug1CommandsLib/Pci.c | 48 ++++++++++++++++-- .../UefiShellDebug1CommandsLib.uni | Bin 152966 -> 153292 bytes 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c index e67c93f95b..d20093902c 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -2049,6 +2049,7 @@ ShellCommandRunPci ( CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; CONST CHAR16 *Temp; + UINT64 RetVal; ShellStatus = SHELL_SUCCESS; Status = EFI_SUCCESS; @@ -2302,7 +2303,16 @@ ShellCommandRunPci ( Temp = ShellCommandLineGetValue(Package, L"-s"); if (Temp != NULL) { - Segment = (UINT16) ShellStrToUintn (Temp); + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + Segment = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } } // @@ -2311,7 +2321,17 @@ ShellCommandRunPci ( // Temp = ShellCommandLineGetRawValue(Package, 1); if (Temp != NULL) { - Bus = (UINT16)ShellStrToUintn(Temp); + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + Bus = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + if (Bus > MAX_BUS_NUMBER) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; @@ -2320,7 +2340,17 @@ ShellCommandRunPci ( } Temp = ShellCommandLineGetRawValue(Package, 2); if (Temp != NULL) { - Device = (UINT16) ShellStrToUintn(Temp); + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + Device = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + if (Device > MAX_DEVICE_NUMBER){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; @@ -2330,7 +2360,17 @@ ShellCommandRunPci ( Temp = ShellCommandLineGetRawValue(Package, 3); if (Temp != NULL) { - Func = (UINT16) ShellStrToUintn(Temp); + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + Func = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + if (Func > MAX_FUNCTION_NUMBER){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 2dfb808c0dce791fd00b17c34a5dbb9a30a4e578..66cb2c153a596cd171149f26c6b09aa71b2834b4 100644 GIT binary patch delta 163 zcmZo$&3R@m=LDxvV+I8V4~A5Ra)ulrSptN*3;_&@49N`HK(dG-1t{+Vlqmz^9EN;` z0)|{5D-Wnnfx#Kb&jpGk0{N8;IzSO020fr|y^W&U{JfqFehgs@@j%mE86qZM>@l4D vj88#O0jSECp_HK*Y(f%4>g2>n(v$B!=9{d*qtI-^-)_RsxZQ-GDaZ`~V|FDI delta 25 hcmX@Jma}a&=LDyXNB;3Ow+Xbj2{3MN6JT<40|1t23L*di