X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=ShellPkg%2FLibrary%2FUefiShellLevel1CommandsLib%2FFor.c;h=9824977149193ebab07c8c1420e80a991340c67b;hb=7162fdb037fb9385f6bd7d0dc55d54029b810de2;hp=2ecc5cd9ef4860fb3a2901de2a4013a1bc13201b;hpb=c011b6c9e2baf57fc0557117e9875ceb3dca55a3;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index 2ecc5cd9ef..9824977149 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -2,7 +2,7 @@ Main file for endfor and for shell level 1 functions. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
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 @@ -25,7 +25,6 @@ @retval FALSE The number is not valid. **/ BOOLEAN -EFIAPI ShellIsValidForNumber ( IN CONST CHAR16 *Number ) @@ -129,7 +128,6 @@ typedef struct { @retval EFI_OUT_OF_RESOURCES There was not enough free memory. **/ EFI_STATUS -EFIAPI InternalUpdateAliasOnList( IN CONST CHAR16 *Alias, IN CONST CHAR16 *CommandString, @@ -185,7 +183,6 @@ InternalUpdateAliasOnList( @retval FALSE The alias is not on the list. **/ BOOLEAN -EFIAPI InternalIsAliasOnList( IN CONST CHAR16 *Alias, IN CONST LIST_ENTRY *List @@ -221,7 +218,6 @@ InternalIsAliasOnList( @param[in, out] List The list to search. **/ BOOLEAN -EFIAPI InternalRemoveAliasFromList( IN CONST CHAR16 *Alias, IN OUT LIST_ENTRY *List @@ -264,7 +260,6 @@ InternalRemoveAliasFromList( @retval (UINTN)(-1) An error ocurred. **/ UINTN -EFIAPI ReturnUintn( IN CONST CHAR16 *String ) @@ -414,7 +409,10 @@ ShellCommandRunFor ( NewSize = StrSize(ArgSet); NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]); Info = AllocateZeroPool(NewSize); - ASSERT(Info != NULL); + if (Info == NULL) { + FreePool (ArgSet); + return SHELL_OUT_OF_RESOURCES; + } Info->Signature = SHELL_FOR_INFO_SIGNATURE; CopyMem(Info->Set, ArgSet, StrSize(ArgSet)); NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]); @@ -438,6 +436,11 @@ ShellCommandRunFor ( gEfiShellParametersProtocol->Argv[2]) == 0) { for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) { ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL)); + if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L")") != NULL && + (LoopVar + 1) < gEfiShellParametersProtocol->Argc + ) { + return (SHELL_INVALID_PARAMETER); + } if (ArgSet == NULL) { // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); } else { @@ -453,7 +456,10 @@ ShellCommandRunFor ( // set up for a 'run' for loop // Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1])); - ASSERT(Info != NULL); + if (Info == NULL) { + FreePool (ArgSet); + return SHELL_OUT_OF_RESOURCES; + } Info->Signature = SHELL_FOR_INFO_SIGNATURE; CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1])); Info->ReplacementName = Info->Set; @@ -618,7 +624,9 @@ ShellCommandRunFor ( if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) { Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data; if (CurrentScriptFile->CurrentCommand->Reset) { - Info->CurrentValue = (CHAR16*)Info->Set; + if (Info != NULL) { + Info->CurrentValue = (CHAR16*)Info->Set; + } FirstPass = TRUE; CurrentScriptFile->CurrentCommand->Reset = FALSE; }