]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Always remove non-defined environment variable
authorJaben Carsey <Jaben.carsey@intel.com>
Tue, 27 Jan 2015 18:53:27 +0000 (18:53 +0000)
committerjcarsey <jcarsey@Edk2>
Tue, 27 Jan 2015 18:53:27 +0000 (18:53 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com>
Reviewed-by: Joe Peterson <joe.peterson@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16672 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index 695880197b0b362fd4f6c34c655d101ec7768767..a570b7b1254cc32eb2c67d407eb0fb2c06053505 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This is THE shell (application)\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1381,8 +1381,8 @@ StripUnreplacedEnvironmentVariables(
       break;\r
     }\r
 \r
-    if (FirstQuote < FirstPercent) {\r
-      SecondQuote = FirstQuote!= NULL?FindNextInstance(FirstQuote+1, L"\"", TRUE):NULL;\r
+    if (FirstQuote!= NULL && FirstQuote < FirstPercent) {\r
+      SecondQuote = FindNextInstance(FirstQuote+1, L"\"", TRUE);\r
       //\r
       // Quote is first found\r
       //\r
@@ -1400,8 +1400,8 @@ StripUnreplacedEnvironmentVariables(
       }\r
       continue;\r
     }\r
-    ASSERT(FirstPercent < FirstQuote);\r
-    if (SecondPercent < FirstQuote) {\r
+    \r
+    if (FirstQuote == NULL || SecondPercent < FirstQuote) {\r
       if (IsValidEnvironmentVariableName(FirstPercent, SecondPercent)) {\r
         //\r
         // We need to remove from FirstPercent to SecondPercent\r
@@ -1415,7 +1415,6 @@ StripUnreplacedEnvironmentVariables(
       }\r
       continue;\r
     }\r
-    ASSERT(FirstQuote < SecondPercent);\r
     CurrentLocator = FirstQuote;\r
   }\r
   return (EFI_SUCCESS);\r
@@ -1530,13 +1529,13 @@ ShellConvertVariables (
     ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, AliasListNode->Alias, AliasListNode->CommandString, TRUE, FALSE);\r
     StrnCpy(NewCommandLine1, NewCommandLine2, NewSize/sizeof(CHAR16)-1);\r
     }\r
-\r
-    //\r
-    // Remove non-existant environment variables in scripts only\r
-    //\r
-    StripUnreplacedEnvironmentVariables(NewCommandLine1);\r
   }\r
 \r
+  //\r
+  // Remove non-existant environment variables\r
+  //\r
+  StripUnreplacedEnvironmentVariables(NewCommandLine1);\r
+\r
   //\r
   // Now cleanup any straggler intentionally ignored "%" characters\r
   //\r