]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
ShellPkg/pci: Fix extended register dumping for MFVC capability
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / SetVar.c
index e711d22729e08fb0fcff11913b11176b4d7791b5..d98a3469a31ddf2d951c403d99ef8c110f1baeb6 100644 (file)
@@ -23,6 +23,34 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {NULL, TypeMax}\r
   };\r
 \r
+\r
+/**\r
+  Check if the input is a (potentially empty) string of hexadecimal nibbles.\r
+\r
+  @param[in] String  The CHAR16 string to check.\r
+\r
+  @retval FALSE  A character has been found in String for which\r
+                 ShellIsHexaDecimalDigitCharacter() returned FALSE.\r
+\r
+  @retval TRUE   Otherwise. (Note that this covers the case when String is\r
+                 empty.)\r
+**/\r
+BOOLEAN\r
+IsStringOfHexNibbles (\r
+  IN CONST CHAR16  *String\r
+  )\r
+{\r
+  CONST CHAR16 *Pos;\r
+\r
+  for (Pos = String; *Pos != L'\0'; ++Pos) {\r
+    if (!ShellIsHexaDecimalDigitCharacter (*Pos)) {\r
+      return FALSE;\r
+    }\r
+  }\r
+  return TRUE;\r
+}\r
+\r
+\r
 /**\r
   Function for 'setvar' command.\r
 \r
@@ -135,6 +163,7 @@ ShellCommandRunSetVar (
 \r
         ASSERT(Data[0] == L'=');\r
         Data++;\r
+        ASSERT(Data[0] != L'\0');\r
 \r
         //\r
         // Determine if the variable exists and get the attributes\r
@@ -166,7 +195,7 @@ ShellCommandRunSetVar (
         //\r
         // What type is the new data.\r
         //\r
-        if (ShellIsHexOrDecimalNumber(Data, TRUE, FALSE)) {\r
+        if (IsStringOfHexNibbles(Data)) {\r
           if (StrLen(Data) % 2 != 0) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", Data);  \r
             ShellStatus = SHELL_INVALID_PARAMETER;\r