From c6fc823413861c6bcafbb21bae9aab66b8ee5a24 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Wed, 31 Aug 2016 13:09:26 +0800 Subject: ShellPkg: Add the check of parameter number in "DrvCfg" command In shell spec, the usage of "Drvcfg" command is: drvcfg [-l XXX] [-c] [-f |-v|-s] [DriverHandle [DeviceHandle [ChildHandle]]] [-i filename] [-o filename]. The parameter number(doesn't include the flags) cannot exceed 4, now we add this point to check whether using the command correctly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni Reviewed-by: Jaben Carsey Reviewed-by: Tapan Shah --- ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c index 0d12f01199..cc1c9ca188 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c @@ -1212,6 +1212,11 @@ ShellCommandRunDrvCfg ( } } if (ShellStatus == SHELL_SUCCESS) { + if (ShellCommandLineGetCount(Package) > 4) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drvcfg"); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } Lang = ShellCommandLineGetValue(Package, L"-l"); if (Lang != NULL) { Language = AllocateZeroPool(StrSize(Lang)); -- cgit v1.2.3