Reviewed-by: Ruiyu Ni <[email protected]>
> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, August 31, 2016 1:27 PM
> To: [email protected]
> Cc: Ni, Ruiyu <[email protected]>; Carsey, Jaben <[email protected]>
> Subject: [patch] 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.
> 
> Cc: Ruiyu Ni <[email protected]>
> Cc: Jaben Carsey <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <[email protected]>
> ---
>  ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
> index 0d12f01..cc1c9ca 100644
> --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
> +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
> @@ -1210,10 +1210,15 @@ ShellCommandRunDrvCfg (
>          ASSERT(FALSE);
>        }
>      }
>    }
>    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));
>        AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
>      } else if (ShellCommandLineGetFlag(Package, L"-l")){
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to