public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
@ 2016-08-31  5:26 Dandan Bi
  2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Dandan Bi @ 2016-08-31  5:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Jaben Carsey

When user uses the command "bcfg driver|boot [dump [-v]]",
the number of command line value parameters (doesn't include the
flag) must be three. We can add this point to check whether using
this command correctly.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   | 4 ++++
 ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
index 9baeecc..e2306bf 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
     if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
       for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) {
         CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber);
         if        (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0)    {
           CurrentOperation.Type = BcfgTypeDump;
+          if (ShellCommandLineGetCount(Package) > 3) {
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellBcfgHiiHandle, L"bcfg");
+            ShellStatus = SHELL_INVALID_PARAMETER;
+          }
         } else if (ShellCommandLineGetFlag(Package, L"-v")) {
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");  
           ShellStatus = SHELL_INVALID_PARAMETER;
         } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"add") == 0)     {
           if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
index 282494b..7668e49 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
@@ -1,9 +1,9 @@
 // /**
 //
 // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
-// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD License
 // which accompanies this distribution. The full text of the license may be found at
 // http://opensource.org/licenses/bsd-license.php
 //
@@ -30,10 +30,11 @@
 #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing argument for flag - '%H%s%N'\r\n"
 #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid argument - '%H%s%N'\r\n"
 #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver or Boot must be selected.\r\n"
 #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must be selected for hot key options.\r\n"
 #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few arguments.\r\n"
+#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many arguments\r\n"
 #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot open file - '%H%s%N'\r\n"
 #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found - '%H%s%N'\r\n"
 #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory allocation was not successful.\r\n"
 #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to write to '%H%s%N'\r\n"
 #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to read from '%H%s%N'\r\n"
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command
  2016-08-31  5:26 [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Dandan Bi
@ 2016-08-31  5:26 ` Dandan Bi
  2016-08-31 14:23   ` Shah, Tapan
  2016-09-01  1:34   ` Ni, Ruiyu
  2016-08-31 14:23 ` [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Shah, Tapan
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Dandan Bi @ 2016-08-31  5:26 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Jaben Carsey

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 <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
  2016-08-31  5:26 [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Dandan Bi
  2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
@ 2016-08-31 14:23 ` Shah, Tapan
  2016-08-31 16:11 ` Carsey, Jaben
  2016-09-01  1:58 ` Ni, Ruiyu
  3 siblings, 0 replies; 10+ messages in thread
From: Shah, Tapan @ 2016-08-31 14:23 UTC (permalink / raw)
  To: Dandan Bi, edk2-devel@lists.01.org; +Cc: Ruiyu Ni, Jaben Carsey

Reviewed-by: Tapan Shah <tapandshah@hpe.com>


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi
Sent: Wednesday, August 31, 2016 12:27 AM
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>; Jaben Carsey <jaben.carsey@intel.com>
Subject: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command

When user uses the command "bcfg driver|boot [dump [-v]]", the number of command line value parameters (doesn't include the
flag) must be three. We can add this point to check whether using this command correctly.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   | 4 ++++
 ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
index 9baeecc..e2306bf 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
     if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {
       for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) {
         CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber);
         if        (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0)    {
           CurrentOperation.Type = BcfgTypeDump;
+          if (ShellCommandLineGetCount(Package) > 3) {
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellBcfgHiiHandle, L"bcfg");
+            ShellStatus = SHELL_INVALID_PARAMETER;
+          }
         } else if (ShellCommandLineGetFlag(Package, L"-v")) {
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");  
           ShellStatus = SHELL_INVALID_PARAMETER;
         } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"add") == 0)     {
           if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) { diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
index 282494b..7668e49 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.u
+++ ni
@@ -1,9 +1,9 @@
 // /**
 //
 // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR> -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2010 - 2016, Intel Corporation. All rights 
+reserved.<BR>
 // This program and the accompanying materials  // are licensed and made available under the terms and conditions of the BSD License  // which accompanies this distribution. The full text of the license may be found at  // http://opensource.org/licenses/bsd-license.php
 //
@@ -30,10 +30,11 @@
 #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing argument for flag - '%H%s%N'\r\n"
 #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid argument - '%H%s%N'\r\n"
 #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver or Boot must be selected.\r\n"
 #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must be selected for hot key options.\r\n"
 #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few arguments.\r\n"
+#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many arguments\r\n"
 #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot open file - '%H%s%N'\r\n"
 #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found - '%H%s%N'\r\n"
 #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory allocation was not successful.\r\n"
 #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to write to '%H%s%N'\r\n"
 #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to read from '%H%s%N'\r\n"
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command
  2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
@ 2016-08-31 14:23   ` Shah, Tapan
  2016-08-31 16:10     ` Carsey, Jaben
  2016-09-01  1:34   ` Ni, Ruiyu
  1 sibling, 1 reply; 10+ messages in thread
From: Shah, Tapan @ 2016-08-31 14:23 UTC (permalink / raw)
  To: Dandan Bi, edk2-devel@lists.01.org; +Cc: Ruiyu Ni, Jaben Carsey

Reviewed-by: Tapan Shah <tapandshah@hpe.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi
Sent: Wednesday, August 31, 2016 12:27 AM
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>; Jaben Carsey <jaben.carsey@intel.com>
Subject: [edk2] [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 <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 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
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command
  2016-08-31 14:23   ` Shah, Tapan
@ 2016-08-31 16:10     ` Carsey, Jaben
  0 siblings, 0 replies; 10+ messages in thread
From: Carsey, Jaben @ 2016-08-31 16:10 UTC (permalink / raw)
  To: Shah, Tapan, Bi, Dandan, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, Carsey, Jaben

Seems like a good check.

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Shah, Tapan [mailto:tapandshah@hpe.com]
> Sent: Wednesday, August 31, 2016 7:24 AM
> To: Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: RE: [edk2] [patch] ShellPkg: Add the check of parameter number in
> "DrvCfg" command
> Importance: High
> 
> Reviewed-by: Tapan Shah <tapandshah@hpe.com>
> 
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Dandan Bi
> Sent: Wednesday, August 31, 2016 12:27 AM
> To: edk2-devel@lists.01.org
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>; Jaben Carsey <jaben.carsey@intel.com>
> Subject: [edk2] [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 <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  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
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
  2016-08-31  5:26 [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Dandan Bi
  2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
  2016-08-31 14:23 ` [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Shah, Tapan
@ 2016-08-31 16:11 ` Carsey, Jaben
  2016-09-01  1:08   ` Bi, Dandan
  2016-09-01  1:58 ` Ni, Ruiyu
  3 siblings, 1 reply; 10+ messages in thread
From: Carsey, Jaben @ 2016-08-31 16:11 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, Carsey, Jaben

Should we check for too few also?  What if the user sends 2 params?

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Dandan Bi
> Sent: Tuesday, August 30, 2016 10:27 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> command
> Importance: High
> 
> When user uses the command "bcfg driver|boot [dump [-v]]",
> the number of command line value parameters (doesn't include the
> flag) must be three. We can add this point to check whether using
> this command correctly.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   |
> 4 ++++
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni |
> 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> index 9baeecc..e2306bf 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> @@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
>      if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target <
> BcfgTargetMax) {
>        for (ParamNumber = 2 ; ParamNumber <
> ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS;
> ParamNumber++) {
>          CurrentParam = ShellCommandLineGetRawValue(Package,
> ParamNumber);
>          if        (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"dump") == 0)    {
>            CurrentOperation.Type = BcfgTypeDump;
> +          if (ShellCommandLineGetCount(Package) > 3) {
> +            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> gShellBcfgHiiHandle, L"bcfg");
> +            ShellStatus = SHELL_INVALID_PARAMETER;
> +          }
>          } else if (ShellCommandLineGetFlag(Package, L"-v")) {
>            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
> gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");
>            ShellStatus = SHELL_INVALID_PARAMETER;
>          } else if (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"add") == 0)     {
>            if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {
> diff --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> index 282494b..7668e49 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> @@ -1,9 +1,9 @@
>  // /**
>  //
>  // (C) Copyright 2014-2015 Hewlett-Packard Development Company,
> L.P.<BR>
> -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
> +// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
>  // This program and the accompanying materials
>  // are licensed and made available under the terms and conditions of the
> BSD License
>  // which accompanies this distribution. The full text of the license may be
> found at
>  // http://opensource.org/licenses/bsd-license.php
>  //
> @@ -30,10 +30,11 @@
>  #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing
> argument for flag - '%H%s%N'\r\n"
>  #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid
> argument - '%H%s%N'\r\n"
>  #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver
> or Boot must be selected.\r\n"
>  #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must
> be selected for hot key options.\r\n"
>  #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few
> arguments.\r\n"
> +#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many
> arguments\r\n"
>  #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot
> open file - '%H%s%N'\r\n"
>  #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found
> - '%H%s%N'\r\n"
>  #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory
> allocation was not successful.\r\n"
>  #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to
> write to '%H%s%N'\r\n"
>  #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to
> read from '%H%s%N'\r\n"
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
  2016-08-31 16:11 ` Carsey, Jaben
@ 2016-09-01  1:08   ` Bi, Dandan
  2016-09-01  1:44     ` Carsey, Jaben
  0 siblings, 1 reply; 10+ messages in thread
From: Bi, Dandan @ 2016-09-01  1:08 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu

Our codes have already checked for "too few " case, and it will print " Too few arguments" in this situation.

Thanks,
Dandan

-----Original Message-----
From: Carsey, Jaben 
Sent: Thursday, September 1, 2016 12:12 AM
To: Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
Subject: RE: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command

Should we check for too few also?  What if the user sends 2 params?

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of 
> Dandan Bi
> Sent: Tuesday, August 30, 2016 10:27 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben 
> <jaben.carsey@intel.com>
> Subject: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> command
> Importance: High
> 
> When user uses the command "bcfg driver|boot [dump [-v]]", the number 
> of command line value parameters (doesn't include the
> flag) must be three. We can add this point to check whether using this 
> command correctly.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   |
> 4 ++++
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni 
> |
> 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> index 9baeecc..e2306bf 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> @@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
>      if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target <
> BcfgTargetMax) {
>        for (ParamNumber = 2 ; ParamNumber <
> ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS;
> ParamNumber++) {
>          CurrentParam = ShellCommandLineGetRawValue(Package,
> ParamNumber);
>          if        (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"dump") == 0)    {
>            CurrentOperation.Type = BcfgTypeDump;
> +          if (ShellCommandLineGetCount(Package) > 3) {
> +            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN 
> + (STR_GEN_TOO_MANY),
> gShellBcfgHiiHandle, L"bcfg");
> +            ShellStatus = SHELL_INVALID_PARAMETER;
> +          }
>          } else if (ShellCommandLineGetFlag(Package, L"-v")) {
>            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN 
> (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");
>            ShellStatus = SHELL_INVALID_PARAMETER;
>          } else if (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"add") == 0)     {
>            if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) 
> { diff --git 
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> index 282494b..7668e49 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> @@ -1,9 +1,9 @@
>  // /**
>  //
>  // (C) Copyright 2014-2015 Hewlett-Packard Development Company, 
> L.P.<BR> -// Copyright (c) 2010 - 2014, Intel Corporation. All rights 
> reserved.<BR>
> +// Copyright (c) 2010 - 2016, Intel Corporation. All rights 
> +reserved.<BR>
>  // This program and the accompanying materials  // are licensed and 
> made available under the terms and conditions of the BSD License  // 
> which accompanies this distribution. The full text of the license may 
> be found at  // http://opensource.org/licenses/bsd-license.php
>  //
> @@ -30,10 +30,11 @@
>  #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing
> argument for flag - '%H%s%N'\r\n"
>  #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid
> argument - '%H%s%N'\r\n"
>  #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver
> or Boot must be selected.\r\n"
>  #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must
> be selected for hot key options.\r\n"
>  #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few
> arguments.\r\n"
> +#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many
> arguments\r\n"
>  #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot
> open file - '%H%s%N'\r\n"
>  #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found
> - '%H%s%N'\r\n"
>  #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory
> allocation was not successful.\r\n"
>  #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to
> write to '%H%s%N'\r\n"
>  #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to
> read from '%H%s%N'\r\n"
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command
  2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
  2016-08-31 14:23   ` Shah, Tapan
@ 2016-09-01  1:34   ` Ni, Ruiyu
  1 sibling, 0 replies; 10+ messages in thread
From: Ni, Ruiyu @ 2016-09-01  1:34 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Carsey, Jaben



Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, August 31, 2016 1:27 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> 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 <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
  2016-09-01  1:08   ` Bi, Dandan
@ 2016-09-01  1:44     ` Carsey, Jaben
  0 siblings, 0 replies; 10+ messages in thread
From: Carsey, Jaben @ 2016-09-01  1:44 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, Carsey, Jaben

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Wednesday, August 31, 2016 6:09 PM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: RE: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> command
> Importance: High
> 
> Our codes have already checked for "too few " case, and it will print " Too few
> arguments" in this situation.
> 
> Thanks,
> Dandan
> 
> -----Original Message-----
> From: Carsey, Jaben
> Sent: Thursday, September 1, 2016 12:12 AM
> To: Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: RE: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> command
> 
> Should we check for too few also?  What if the user sends 2 params?
> 
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > Dandan Bi
> > Sent: Tuesday, August 30, 2016 10:27 PM
> > To: edk2-devel@lists.01.org
> > Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben
> > <jaben.carsey@intel.com>
> > Subject: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> > command
> > Importance: High
> >
> > When user uses the command "bcfg driver|boot [dump [-v]]", the number
> > of command line value parameters (doesn't include the
> > flag) must be three. We can add this point to check whether using this
> > command correctly.
> >
> > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > Cc: Jaben Carsey <jaben.carsey@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> > ---
> >  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   |
> > 4 ++++
> >  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> > |
> > 3 ++-
> >  2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git
> > a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> > b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> > index 9baeecc..e2306bf 100644
> > ---
> > a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> > +++
> > b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> > @@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
> >      if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target <
> > BcfgTargetMax) {
> >        for (ParamNumber = 2 ; ParamNumber <
> > ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS;
> > ParamNumber++) {
> >          CurrentParam = ShellCommandLineGetRawValue(Package,
> > ParamNumber);
> >          if        (gUnicodeCollation->StriColl(gUnicodeCollation,
> > (CHAR16*)CurrentParam, L"dump") == 0)    {
> >            CurrentOperation.Type = BcfgTypeDump;
> > +          if (ShellCommandLineGetCount(Package) > 3) {
> > +            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> > + (STR_GEN_TOO_MANY),
> > gShellBcfgHiiHandle, L"bcfg");
> > +            ShellStatus = SHELL_INVALID_PARAMETER;
> > +          }
> >          } else if (ShellCommandLineGetFlag(Package, L"-v")) {
> >            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> > (STR_GEN_PARAM_INV), gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");
> >            ShellStatus = SHELL_INVALID_PARAMETER;
> >          } else if (gUnicodeCollation->StriColl(gUnicodeCollation,
> > (CHAR16*)CurrentParam, L"add") == 0)     {
> >            if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package))
> > { diff --git
> > a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> > b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> > index 282494b..7668e49 100644
> > ---
> > a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> > +++
> > b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> > @@ -1,9 +1,9 @@
> >  // /**
> >  //
> >  // (C) Copyright 2014-2015 Hewlett-Packard Development Company,
> > L.P.<BR> -// Copyright (c) 2010 - 2014, Intel Corporation. All rights
> > reserved.<BR>
> > +// Copyright (c) 2010 - 2016, Intel Corporation. All rights
> > +reserved.<BR>
> >  // This program and the accompanying materials  // are licensed and
> > made available under the terms and conditions of the BSD License  //
> > which accompanies this distribution. The full text of the license may
> > be found at  // http://opensource.org/licenses/bsd-license.php
> >  //
> > @@ -30,10 +30,11 @@
> >  #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing
> > argument for flag - '%H%s%N'\r\n"
> >  #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid
> > argument - '%H%s%N'\r\n"
> >  #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver
> > or Boot must be selected.\r\n"
> >  #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must
> > be selected for hot key options.\r\n"
> >  #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few
> > arguments.\r\n"
> > +#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many
> > arguments\r\n"
> >  #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot
> > open file - '%H%s%N'\r\n"
> >  #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found
> > - '%H%s%N'\r\n"
> >  #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory
> > allocation was not successful.\r\n"
> >  #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to
> > write to '%H%s%N'\r\n"
> >  #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to
> > read from '%H%s%N'\r\n"
> > --
> > 1.9.5.msysgit.1
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command
  2016-08-31  5:26 [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Dandan Bi
                   ` (2 preceding siblings ...)
  2016-08-31 16:11 ` Carsey, Jaben
@ 2016-09-01  1:58 ` Ni, Ruiyu
  3 siblings, 0 replies; 10+ messages in thread
From: Ni, Ruiyu @ 2016-09-01  1:58 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Carsey, Jaben



Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Dandan Bi
> Sent: Wednesday, August 31, 2016 1:27 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2] [patch] ShellPkg: Add check for "dump" parameter in "bcfg"
> command
> 
> When user uses the command "bcfg driver|boot [dump [-v]]", the number
> of command line value parameters (doesn't include the
> flag) must be three. We can add this point to check whether using this
> command correctly.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c   |
> 4 ++++
>  ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni |
> 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> index 9baeecc..e2306bf 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
> @@ -1294,10 +1294,14 @@ ShellCommandRunBcfg (
>      if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target <
> BcfgTargetMax) {
>        for (ParamNumber = 2 ; ParamNumber <
> ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS;
> ParamNumber++) {
>          CurrentParam = ShellCommandLineGetRawValue(Package,
> ParamNumber);
>          if        (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"dump") == 0)    {
>            CurrentOperation.Type = BcfgTypeDump;
> +          if (ShellCommandLineGetCount(Package) > 3) {
> +            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> gShellBcfgHiiHandle, L"bcfg");
> +            ShellStatus = SHELL_INVALID_PARAMETER;
> +          }
>          } else if (ShellCommandLineGetFlag(Package, L"-v")) {
>            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
> gShellBcfgHiiHandle, L"bcfg", L"-v (without dump)");
>            ShellStatus = SHELL_INVALID_PARAMETER;
>          } else if (gUnicodeCollation->StriColl(gUnicodeCollation,
> (CHAR16*)CurrentParam, L"add") == 0)     {
>            if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) { diff
> --git
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> index 282494b..7668e49 100644
> ---
> a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.uni
> +++
> b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.u
> +++ ni
> @@ -1,9 +1,9 @@
>  // /**
>  //
>  // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
> -// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
> +// Copyright (c) 2010 - 2016, Intel Corporation. All rights
> +reserved.<BR>
>  // This program and the accompanying materials  // are licensed and made
> available under the terms and conditions of the BSD License  // which
> accompanies this distribution. The full text of the license may be found at  //
> http://opensource.org/licenses/bsd-license.php
>  //
> @@ -30,10 +30,11 @@
>  #string STR_GEN_NO_VALUE          #language en-US "%H%s%N: Missing
> argument for flag - '%H%s%N'\r\n"
>  #string STR_GEN_PARAM_INV         #language en-US "%H%s%N: Invalid
> argument - '%H%s%N'\r\n"
>  #string STR_GEN_NO_DRIVER_BOOT    #language en-US "%H%s%N: Driver
> or Boot must be selected.\r\n"
>  #string STR_GEN_BOOT_ONLY         #language en-US "%H%s%N: Boot must
> be selected for hot key options.\r\n"
>  #string STR_GEN_TOO_FEW           #language en-US "%H%s%N: Too few
> arguments.\r\n"
> +#string STR_GEN_TOO_MANY          #language en-US "%H%s%N: Too many
> arguments\r\n"
>  #string STR_GEN_FILE_OPEN_FAIL    #language en-US "%H%s%N: Cannot
> open file - '%H%s%N'\r\n"
>  #string STR_GEN_FIND_FAIL         #language en-US "%H%s%N: File not found
> - '%H%s%N'\r\n"
>  #string STR_GEN_OUT_MEM           #language en-US "%H%s%N: Memory
> allocation was not successful.\r\n"
>  #string STR_BCFG_WRITE_FAIL       #language en-US "%H%s%N: Unable to
> write to '%H%s%N'\r\n"
>  #string STR_BCFG_READ_FAIL        #language en-US "%H%s%N: Unable to
> read from '%H%s%N'\r\n"
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-01  1:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31  5:26 [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Dandan Bi
2016-08-31  5:26 ` [patch] ShellPkg: Add the check of parameter number in "DrvCfg" command Dandan Bi
2016-08-31 14:23   ` Shah, Tapan
2016-08-31 16:10     ` Carsey, Jaben
2016-09-01  1:34   ` Ni, Ruiyu
2016-08-31 14:23 ` [patch] ShellPkg: Add check for "dump" parameter in "bcfg" command Shah, Tapan
2016-08-31 16:11 ` Carsey, Jaben
2016-09-01  1:08   ` Bi, Dandan
2016-09-01  1:44     ` Carsey, Jaben
2016-09-01  1:58 ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox