]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Add the check of parameter number in "DrvCfg" command
authorDandan Bi <dandan.bi@intel.com>
Wed, 31 Aug 2016 05:09:26 +0000 (13:09 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 1 Sep 2016 08:38:06 +0000 (16:38 +0800)
In shell spec, the usage of "Drvcfg" command is: drvcfg [-l XXX] [-c]
[-f <Type>|-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 <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c

index 0d12f01199b3f924fa246d09a8fa40df6961d44f..cc1c9ca188a99ac307114c17da56b447acbceab5 100644 (file)
@@ -1212,6 +1212,11 @@ ShellCommandRunDrvCfg (
     }\r
   } \r
   if (ShellStatus == SHELL_SUCCESS) {\r
+    if (ShellCommandLineGetCount(Package) > 4) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drvcfg");\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+      goto Done;\r
+    }\r
     Lang = ShellCommandLineGetValue(Package, L"-l");\r
     if (Lang != NULL) {\r
       Language = AllocateZeroPool(StrSize(Lang));\r