]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
ShellPkg: Update Guid usage in ShellLib INF to match source code logic
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / For.c
index 2ecc5cd9ef4860fb3a2901de2a4013a1bc13201b..3db4bb58d388fecb1cffdebc600c2207184de9d1 100644 (file)
@@ -2,7 +2,7 @@
   Main file for endfor and for shell level 1 functions.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -25,7 +25,6 @@
   @retval FALSE   The number is not valid.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 ShellIsValidForNumber (\r
   IN CONST CHAR16 *Number\r
   )\r
@@ -129,7 +128,6 @@ typedef struct {
   @retval EFI_OUT_OF_RESOURCES  There was not enough free memory.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 InternalUpdateAliasOnList(\r
   IN CONST CHAR16       *Alias,\r
   IN CONST CHAR16       *CommandString,\r
@@ -185,7 +183,6 @@ InternalUpdateAliasOnList(
   @retval FALSE                 The alias is not on the list.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 InternalIsAliasOnList(\r
   IN CONST CHAR16       *Alias,\r
   IN CONST LIST_ENTRY   *List\r
@@ -221,7 +218,6 @@ InternalIsAliasOnList(
   @param[in, out] List           The list to search.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 InternalRemoveAliasFromList(\r
   IN CONST CHAR16       *Alias,\r
   IN OUT LIST_ENTRY     *List\r
@@ -264,7 +260,6 @@ InternalRemoveAliasFromList(
   @retval (UINTN)(-1) An error ocurred.\r
 **/\r
 UINTN\r
-EFIAPI\r
 ReturnUintn(\r
   IN CONST CHAR16 *String\r
   )\r
@@ -414,7 +409,10 @@ ShellCommandRunFor (
         NewSize = StrSize(ArgSet);\r
         NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);\r
         Info = AllocateZeroPool(NewSize);\r
-        ASSERT(Info != NULL);\r
+        if (Info == NULL) {\r
+          FreePool (ArgSet);\r
+          return SHELL_OUT_OF_RESOURCES;\r
+        }\r
         Info->Signature = SHELL_FOR_INFO_SIGNATURE;\r
         CopyMem(Info->Set, ArgSet, StrSize(ArgSet));\r
         NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);\r
@@ -438,6 +436,11 @@ ShellCommandRunFor (
         gEfiShellParametersProtocol->Argv[2]) == 0) {\r
       for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {\r
         ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));\r
+        if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L")") != NULL &&\r
+            (LoopVar + 1) < gEfiShellParametersProtocol->Argc\r
+           ) {\r
+          return (SHELL_INVALID_PARAMETER);\r
+        }\r
         if (ArgSet == NULL) {\r
 //        ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);\r
         } else {\r
@@ -453,7 +456,10 @@ ShellCommandRunFor (
         // set up for a 'run' for loop\r
         //\r
         Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));\r
-        ASSERT(Info != NULL);\r
+        if (Info == NULL) {\r
+          FreePool (ArgSet);\r
+          return SHELL_OUT_OF_RESOURCES;\r
+        }\r
         Info->Signature = SHELL_FOR_INFO_SIGNATURE;\r
         CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));\r
         Info->ReplacementName = Info->Set;\r