X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel1CommandsLib%2FFor.c;h=9824977149193ebab07c8c1420e80a991340c67b;hp=b8e4805d922e4a81068271a527ad90ad1c7cc7a5;hb=7162fdb037fb9385f6bd7d0dc55d54029b810de2;hpb=cbdd109b43c8386d74a7bb40d892e5c2485f71f9 diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index b8e4805d92..9824977149 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -1,7 +1,8 @@ /** @file Main file for endfor and for shell level 1 functions. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
+ 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 @@ -24,7 +25,6 @@ @retval FALSE The number is not valid. **/ BOOLEAN -EFIAPI ShellIsValidForNumber ( IN CONST CHAR16 *Number ) @@ -42,7 +42,7 @@ ShellIsValidForNumber ( } if (StrLen(Number) >= 7) { - if (StrStr(Number, L" ") != NULL && (StrStr(Number, L" ") - Number) >= 7) { + if ((StrStr(Number, L" ") == NULL) || (((StrStr(Number, L" ") != NULL) && (StrStr(Number, L" ") - Number) >= 7))) { return (FALSE); } } @@ -75,12 +75,12 @@ ShellCommandRunEndFor ( ASSERT_EFI_ERROR(Status); if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"EndFor"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"endfor"); return (SHELL_UNSUPPORTED); } if (gEfiShellParametersProtocol->Argc > 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"endfor"); return (SHELL_INVALID_PARAMETER); } @@ -120,15 +120,14 @@ typedef struct { /** Update the value of a given alias on the list. If the alias is not there then add it. - @param[in] Alias The alias to test for. - @param[in] CommandString The updated command string. - @param[in,out] List The list to search. + @param[in] Alias The alias to test for. + @param[in] CommandString The updated command string. + @param[in, out] List The list to search. @retval EFI_SUCCESS The operation was completed successfully. @retval EFI_OUT_OF_RESOURCES There was not enough free memory. **/ EFI_STATUS -EFIAPI InternalUpdateAliasOnList( IN CONST CHAR16 *Alias, IN CONST CHAR16 *CommandString, @@ -184,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 @@ -216,11 +214,10 @@ InternalIsAliasOnList( /** Remove an alias from the given list. - @param[in] Alias The alias to remove. - @param[in,out] List The list to search. + @param[in] Alias The alias to remove. + @param[in, out] List The list to search. **/ BOOLEAN -EFIAPI InternalRemoveAliasFromList( IN CONST CHAR16 *Alias, IN OUT LIST_ENTRY *List @@ -253,6 +250,28 @@ InternalRemoveAliasFromList( return (FALSE); } +/** + Function to determine whether a string is decimal or hex representation of a number + and return the number converted from the string. + + @param[in] String String representation of a number + + @return the number + @retval (UINTN)(-1) An error ocurred. +**/ +UINTN +ReturnUintn( + IN CONST CHAR16 *String + ) +{ + UINT64 RetVal; + + if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, TRUE))) { + return ((UINTN)RetVal); + } + return ((UINTN)(-1)); +} + /** Function for 'for' command. @@ -271,6 +290,7 @@ ShellCommandRunFor ( SCRIPT_FILE *CurrentScriptFile; CHAR16 *ArgSet; CHAR16 *ArgSetWalker; + CHAR16 *Parameter; UINTN ArgSize; UINTN LoopVar; SHELL_FOR_INFO *Info; @@ -286,6 +306,7 @@ ShellCommandRunFor ( ShellStatus = SHELL_SUCCESS; ArgSetWalker = NULL; TempString = NULL; + Parameter = NULL; FirstPass = FALSE; // @@ -298,19 +319,19 @@ ShellCommandRunFor ( ASSERT_EFI_ERROR(Status); if (!gEfiShellProtocol->BatchIsActive()) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"For"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"for"); return (SHELL_UNSUPPORTED); } if (gEfiShellParametersProtocol->Argc < 4) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"for"); return (SHELL_INVALID_PARAMETER); } CurrentScriptFile = ShellCommandGetCurrentScriptFile(); ASSERT(CurrentScriptFile != NULL); - if (CurrentScriptFile->CurrentCommand->Data == NULL) { + if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) { FirstPass = TRUE; // @@ -325,8 +346,7 @@ ShellCommandRunFor ( gShellLevel1HiiHandle, L"EndFor", L"For", - CurrentScriptFile->CurrentCommand!=NULL - ?CurrentScriptFile->CurrentCommand->Line:0); + CurrentScriptFile->CurrentCommand->Line); return (SHELL_DEVICE_ERROR); } @@ -347,11 +367,6 @@ ShellCommandRunFor ( gEfiShellParametersProtocol->Argv[2]) == 0) { for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) { ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL)); - if (ArgSet == NULL) { - // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); - } else { - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0); - } if (StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"*") != NULL ||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"?") != NULL ||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"[") != NULL @@ -359,7 +374,9 @@ ShellCommandRunFor ( FileList = NULL; Status = ShellOpenFileMetaArg ((CHAR16*)gEfiShellParametersProtocol->Argv[LoopVar], EFI_FILE_MODE_READ, &FileList); if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) { + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0); ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); } else { for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link) ; !IsNull(&FileList->Link, &Node->Link) @@ -372,39 +389,58 @@ ShellCommandRunFor ( ShellCloseFileMetaArg(&FileList); } } else { - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0); + Parameter = gEfiShellParametersProtocol->Argv[LoopVar]; + if (Parameter[0] == L'\"' && Parameter[StrLen(Parameter)-1] == L'\"') { + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0); + } else { + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, Parameter, 0); + ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); + } } - ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0); } - // - // set up for an 'in' for loop - // - NewSize = StrSize(ArgSet); - NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]); - Info = AllocateZeroPool(NewSize); - ASSERT(Info != NULL); - Info->Signature = SHELL_FOR_INFO_SIGNATURE; - CopyMem(Info->Set, ArgSet, StrSize(ArgSet)); - NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]); - CopyMem(Info->Set+(StrSize(ArgSet)/sizeof(Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize); - Info->ReplacementName = Info->Set+StrSize(ArgSet)/sizeof(Info->Set[0]); - Info->CurrentValue = (CHAR16*)Info->Set; - Info->Step = 0; - Info->Current = 0; - Info->End = 0; - - if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) { - Info->RemoveSubstAlias = FALSE; + if (ArgSet == NULL) { + ShellStatus = SHELL_OUT_OF_RESOURCES; } else { - Info->RemoveSubstAlias = TRUE; + // + // set up for an 'in' for loop + // + NewSize = StrSize(ArgSet); + NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]); + Info = AllocateZeroPool(NewSize); + 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]); + CopyMem(Info->Set+(StrSize(ArgSet)/sizeof(Info->Set[0])), gEfiShellParametersProtocol->Argv[1], NewSize); + Info->ReplacementName = Info->Set+StrSize(ArgSet)/sizeof(Info->Set[0]); + Info->CurrentValue = (CHAR16*)Info->Set; + Info->Step = 0; + Info->Current = 0; + Info->End = 0; + + if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) { + Info->RemoveSubstAlias = FALSE; + } else { + Info->RemoveSubstAlias = TRUE; + } + CurrentScriptFile->CurrentCommand->Data = Info; } - CurrentScriptFile->CurrentCommand->Data = Info; } else if (gUnicodeCollation->StriColl( gUnicodeCollation, L"run", 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 { @@ -413,80 +449,61 @@ ShellCommandRunFor ( ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0); // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0); } - // - // set up for a 'run' for loop - // - Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1])); - ASSERT(Info != NULL); - CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1])); - Info->ReplacementName = Info->Set; - Info->CurrentValue = NULL; - ArgSetWalker = ArgSet; - if (ArgSetWalker[0] != L'(') { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - ShellStatus = SHELL_INVALID_PARAMETER; + if (ArgSet == NULL) { + ShellStatus = SHELL_OUT_OF_RESOURCES; } else { - TempSpot = StrStr(ArgSetWalker, L")"); - if (TempSpot != NULL) { - TempString = TempSpot+1; - if (*(TempString) != CHAR_NULL) { - while(TempString != NULL && *TempString == L' ') { - TempString++; - } - if (StrLen(TempString) > 0) { - TempSpot = NULL; - } - } + // + // set up for a 'run' for loop + // + Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1])); + if (Info == NULL) { + FreePool (ArgSet); + return SHELL_OUT_OF_RESOURCES; } - if (TempSpot == NULL) { + Info->Signature = SHELL_FOR_INFO_SIGNATURE; + CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1])); + Info->ReplacementName = Info->Set; + Info->CurrentValue = NULL; + ArgSetWalker = ArgSet; + if (ArgSetWalker[0] != L'(') { ShellPrintHiiEx( -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); + ArgSet, + CurrentScriptFile->CurrentCommand->Line); ShellStatus = SHELL_INVALID_PARAMETER; } else { - *TempSpot = CHAR_NULL; - ArgSetWalker++; - while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { - ArgSetWalker++; + TempSpot = StrStr(ArgSetWalker, L")"); + if (TempSpot != NULL) { + TempString = TempSpot+1; + if (*(TempString) != CHAR_NULL) { + while(TempString != NULL && *TempString == L' ') { + TempString++; + } + if (StrLen(TempString) > 0) { + TempSpot = NULL; + } + } } - if (!ShellIsValidForNumber(ArgSetWalker)) { + if (TempSpot == NULL) { ShellPrintHiiEx( -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); + CurrentScriptFile->CurrentCommand->Line); ShellStatus = SHELL_INVALID_PARAMETER; } else { - if (ArgSetWalker[0] == L'-') { - Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); - } else { - Info->Current = (INTN)ShellStrToUintn(ArgSetWalker); - } - ArgSetWalker = StrStr(ArgSetWalker, L" "); + *TempSpot = CHAR_NULL; + ArgSetWalker++; while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { ArgSetWalker++; } - if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ + if (!ShellIsValidForNumber(ArgSetWalker)) { ShellPrintHiiEx( -1, -1, @@ -494,79 +511,94 @@ ShellCommandRunFor ( STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); + CurrentScriptFile->CurrentCommand->Line); ShellStatus = SHELL_INVALID_PARAMETER; } else { if (ArgSetWalker[0] == L'-') { - Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); - } else { - Info->End = (INTN)ShellStrToUintn(ArgSetWalker); - } - if (Info->Current < Info->End) { - Info->Step = 1; + Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1); } else { - Info->Step = -1; + Info->Current = (INTN)ReturnUintn(ArgSetWalker); } - ArgSetWalker = StrStr(ArgSetWalker, L" "); while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { ArgSetWalker++; } - if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) { - if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - ShellStatus = SHELL_INVALID_PARAMETER; + if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), + gShellLevel1HiiHandle, + ArgSet, + CurrentScriptFile->CurrentCommand->Line); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + if (ArgSetWalker[0] == L'-') { + Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1); } else { - if (*ArgSetWalker == L')') { - ASSERT(Info->Step == 1 || Info->Step == -1); + Info->End = (INTN)ReturnUintn(ArgSetWalker); + } + if (Info->Current < Info->End) { + Info->Step = 1; + } else { + Info->Step = -1; + } + + ArgSetWalker = StrStr(ArgSetWalker, L" "); + while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') { + ArgSetWalker++; + } + if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) { + if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){ + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), + gShellLevel1HiiHandle, + ArgSet, + CurrentScriptFile->CurrentCommand->Line); + ShellStatus = SHELL_INVALID_PARAMETER; } else { - if (ArgSetWalker[0] == L'-') { - Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1); + if (*ArgSetWalker == L')') { + ASSERT(Info->Step == 1 || Info->Step == -1); } else { - Info->Step = (INTN)ShellStrToUintn(ArgSetWalker); - } - - if (StrStr(ArgSetWalker, L" ") != NULL) { - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), - gShellLevel1HiiHandle, - ArgSet, - CurrentScriptFile!=NULL - && CurrentScriptFile->CurrentCommand!=NULL - ? CurrentScriptFile->CurrentCommand->Line:0); - ShellStatus = SHELL_INVALID_PARAMETER; + if (ArgSetWalker[0] == L'-') { + Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1); + } else { + Info->Step = (INTN)ReturnUintn(ArgSetWalker); + } + + if (StrStr(ArgSetWalker, L" ") != NULL) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), + gShellLevel1HiiHandle, + ArgSet, + CurrentScriptFile->CurrentCommand->Line); + ShellStatus = SHELL_INVALID_PARAMETER; + } } } + } - } } } } - } - if (ShellStatus == SHELL_SUCCESS) { - if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) { - Info->RemoveSubstAlias = FALSE; - } else { - Info->RemoveSubstAlias = TRUE; + if (ShellStatus == SHELL_SUCCESS) { + if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) { + Info->RemoveSubstAlias = FALSE; + } else { + Info->RemoveSubstAlias = TRUE; + } + } + if (CurrentScriptFile->CurrentCommand != NULL) { + CurrentScriptFile->CurrentCommand->Data = Info; } - } - if (CurrentScriptFile->CurrentCommand != NULL) { - CurrentScriptFile->CurrentCommand->Data = Info; } } else { ShellPrintHiiEx( @@ -589,11 +621,18 @@ ShellCommandRunFor ( ASSERT(ArgSet == NULL); } - Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data; - if (CurrentScriptFile->CurrentCommand->Reset) { - Info->CurrentValue = (CHAR16*)Info->Set; - FirstPass = TRUE; - CurrentScriptFile->CurrentCommand->Reset = FALSE; + if (CurrentScriptFile != NULL && CurrentScriptFile->CurrentCommand != NULL) { + Info = (SHELL_FOR_INFO*)CurrentScriptFile->CurrentCommand->Data; + if (CurrentScriptFile->CurrentCommand->Reset) { + if (Info != NULL) { + Info->CurrentValue = (CHAR16*)Info->Set; + } + FirstPass = TRUE; + CurrentScriptFile->CurrentCommand->Reset = FALSE; + } + } else { + ShellStatus = SHELL_UNSUPPORTED; + Info = NULL; } if (ShellStatus == SHELL_SUCCESS) { ASSERT(Info != NULL); @@ -646,12 +685,9 @@ ShellCommandRunFor ( // ASSERT(Info->Set != NULL); if (Info->CurrentValue != NULL && *Info->CurrentValue != CHAR_NULL) { - if (Info->CurrentValue[0] == L'\"') { + if (Info->CurrentValue[0] == L' ') { Info->CurrentValue++; } -// while (Info->CurrentValue[0] == L' ') { -// Info->CurrentValue++; -// } if (Info->CurrentValue[0] == L'\"') { Info->CurrentValue++; } @@ -660,27 +696,24 @@ ShellCommandRunFor ( // ASSERT(TempString == NULL); TempString = StrnCatGrow(&TempString, NULL, Info->CurrentValue, 0); - TempSpot = StrStr(TempString, L"\" \""); - if (TempSpot != NULL) { - *TempSpot = CHAR_NULL; - } - while (TempString[StrLen(TempString)-1] == L'\"') { - TempString[StrLen(TempString)-1] = CHAR_NULL; - } - InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList); - Info->CurrentValue += StrLen(TempString); + if (TempString == NULL) { + ShellStatus = SHELL_OUT_OF_RESOURCES; + } else { + TempSpot = StrStr(TempString, L"\" \""); + if (TempSpot != NULL) { + *TempSpot = CHAR_NULL; + } + while (TempString[StrLen(TempString)-1] == L'\"') { + TempString[StrLen(TempString)-1] = CHAR_NULL; + } + InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList); + Info->CurrentValue += StrLen(TempString); - if (Info->CurrentValue[0] == L'\"') { - Info->CurrentValue++; - } - while (Info->CurrentValue[0] == L' ') { - Info->CurrentValue++; - } - if (Info->CurrentValue[0] == L'\"') { - Info->CurrentValue++; + if (Info->CurrentValue[0] == L'\"') { + Info->CurrentValue++; + } + FreePool(TempString); } - FreePool(TempString); - } else { CurrentScriptFile->CurrentCommand->Data = NULL; //