ShellPkg: Add the check of parameter number in "DrvCfg" command

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>
This commit is contained in:
Dandan Bi 2016-08-31 13:09:26 +08:00 committed by Ruiyu Ni
parent d653d8062e
commit c6fc823413
1 changed files with 5 additions and 0 deletions

View File

@ -1212,6 +1212,11 @@ ShellCommandRunDrvCfg (
} }
} }
if (ShellStatus == SHELL_SUCCESS) { 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"); Lang = ShellCommandLineGetValue(Package, L"-l");
if (Lang != NULL) { if (Lang != NULL) {
Language = AllocateZeroPool(StrSize(Lang)); Language = AllocateZeroPool(StrSize(Lang));