]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix Shell does not support ASCII pipe(|a).
authorQiu Shumin <shumin.qiu@intel.com>
Tue, 15 Sep 2015 00:58:59 +0000 (00:58 +0000)
committershenshushi <shenshushi@Edk2>
Tue, 15 Sep 2015 00:58:59 +0000 (00:58 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18452 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index 78a64de19eae2d606def95b7ca57f003a9662588..03f5e4f05fe8756ad922fdd5e2537f3b53121d9b 100644 (file)
@@ -1578,11 +1578,18 @@ RunSplitCommand(
     SHELL_FREE_NON_NULL(OurCommandLine);\r
     SHELL_FREE_NON_NULL(NextCommandLine);\r
     return (EFI_INVALID_PARAMETER);\r
-  } else if (NextCommandLine[0] != CHAR_NULL &&\r
-      NextCommandLine[0] == L'a' &&\r
-      NextCommandLine[1] == L' '\r
-     ){\r
+  } else if (NextCommandLine[0] == L'a' &&\r
+             (NextCommandLine[1] == L' ' || NextCommandLine[1] == CHAR_NULL)\r
+            ){\r
     CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));\r
+    while (NextCommandLine[0] == L' ') {\r
+      CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));\r
+    }\r
+    if (NextCommandLine[0] == CHAR_NULL) {\r
+      SHELL_FREE_NON_NULL(OurCommandLine);\r
+      SHELL_FREE_NON_NULL(NextCommandLine);\r
+      return (EFI_INVALID_PARAMETER);\r
+    }\r
     Unicode = FALSE;\r
   } else {\r
     Unicode = TRUE;\r
@@ -1884,24 +1891,31 @@ VerifySplit(
   EFI_STATUS    Status;\r
 \r
   //\r
-  // Verify up to the pipe or end character\r
+  // If this was the only item, then get out\r
   //\r
-  Status = IsValidSplit(CmdLine);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
+  if (!ContainsSplit(CmdLine)) {\r
+    return (EFI_SUCCESS);\r
   }\r
 \r
   //\r
-  // If this was the only item, then get out\r
+  // Verify up to the pipe or end character\r
   //\r
-  if (!ContainsSplit(CmdLine)) {\r
-    return (EFI_SUCCESS);\r
+  Status = IsValidSplit(CmdLine);\r
+  if (EFI_ERROR(Status)) {\r
+    return (Status);\r
   }\r
 \r
   //\r
   // recurse to verify the next item\r
   //\r
   TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;\r
+  if (*TempSpot == L'a' && \r
+      (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)\r
+     ) {\r
+    // If it's an ASCII pipe '|a'\r
+    TempSpot += 1;\r
+  }\r
+  \r
   return (VerifySplit(TempSpot));\r
 }\r
 \r