ShellPkg: Add checking for memory allocation and pointer returns from functions.
signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12540 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -857,15 +857,19 @@ DoStartupScript(
|
|||||||
FileStringPath = NULL;
|
FileStringPath = NULL;
|
||||||
NewSize = 0;
|
NewSize = 0;
|
||||||
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, MapName, 0);
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, MapName, 0);
|
||||||
TempSpot = StrStr(FileStringPath, L";");
|
if (FileStringPath == NULL) {
|
||||||
if (TempSpot != NULL) {
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
*TempSpot = CHAR_NULL;
|
} else {
|
||||||
|
TempSpot = StrStr(FileStringPath, L";");
|
||||||
|
if (TempSpot != NULL) {
|
||||||
|
*TempSpot = CHAR_NULL;
|
||||||
|
}
|
||||||
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, ((FILEPATH_DEVICE_PATH*)FilePath)->PathName, 0);
|
||||||
|
PathRemoveLastItem(FileStringPath);
|
||||||
|
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, mStartupScript, 0);
|
||||||
|
Status = ShellInfoObject.NewEfiShellProtocol->OpenFileByName(FileStringPath, &FileHandle, EFI_FILE_MODE_READ);
|
||||||
|
FreePool(FileStringPath);
|
||||||
}
|
}
|
||||||
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, ((FILEPATH_DEVICE_PATH*)FilePath)->PathName, 0);
|
|
||||||
PathRemoveLastItem(FileStringPath);
|
|
||||||
FileStringPath = StrnCatGrow(&FileStringPath, &NewSize, mStartupScript, 0);
|
|
||||||
Status = ShellInfoObject.NewEfiShellProtocol->OpenFileByName(FileStringPath, &FileHandle, EFI_FILE_MODE_READ);
|
|
||||||
FreePool(FileStringPath);
|
|
||||||
}
|
}
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
NamePath = FileDevicePath (NULL, mStartupScript);
|
NamePath = FileDevicePath (NULL, mStartupScript);
|
||||||
@@ -1215,6 +1219,12 @@ RunSplitCommand(
|
|||||||
|
|
||||||
NextCommandLine = StrnCatGrow(&NextCommandLine, &Size1, StrStr(CmdLine, L"|")+1, 0);
|
NextCommandLine = StrnCatGrow(&NextCommandLine, &Size1, StrStr(CmdLine, L"|")+1, 0);
|
||||||
OurCommandLine = StrnCatGrow(&OurCommandLine , &Size2, CmdLine , StrStr(CmdLine, L"|") - CmdLine);
|
OurCommandLine = StrnCatGrow(&OurCommandLine , &Size2, CmdLine , StrStr(CmdLine, L"|") - CmdLine);
|
||||||
|
|
||||||
|
if (NextCommandLine == NULL || OurCommandLine == NULL) {
|
||||||
|
SHELL_FREE_NON_NULL(OurCommandLine);
|
||||||
|
SHELL_FREE_NON_NULL(NextCommandLine);
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
if (NextCommandLine[0] != CHAR_NULL &&
|
if (NextCommandLine[0] != CHAR_NULL &&
|
||||||
NextCommandLine[0] == L'a' &&
|
NextCommandLine[0] == L'a' &&
|
||||||
NextCommandLine[1] == L' '
|
NextCommandLine[1] == L' '
|
||||||
@@ -1334,6 +1344,9 @@ RunCommand(
|
|||||||
Split = NULL;
|
Split = NULL;
|
||||||
|
|
||||||
CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
|
CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
|
||||||
|
if (CleanOriginal == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
while (CleanOriginal[StrLen(CleanOriginal)-1] == L' ') {
|
while (CleanOriginal[StrLen(CleanOriginal)-1] == L' ') {
|
||||||
CleanOriginal[StrLen(CleanOriginal)-1] = CHAR_NULL;
|
CleanOriginal[StrLen(CleanOriginal)-1] = CHAR_NULL;
|
||||||
}
|
}
|
||||||
|
@@ -180,6 +180,10 @@ ManBufferFindSections(
|
|||||||
TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));
|
TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));
|
||||||
ASSERT(TempString == NULL);
|
ASSERT(TempString == NULL);
|
||||||
TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);
|
TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);
|
||||||
|
if (TempString == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
SectionName = TempString;
|
SectionName = TempString;
|
||||||
SectionLen = StrLen(SectionName);
|
SectionLen = StrLen(SectionName);
|
||||||
SectionName = StrStr(Sections, SectionName);
|
SectionName = StrStr(Sections, SectionName);
|
||||||
@@ -197,12 +201,24 @@ ManBufferFindSections(
|
|||||||
TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));
|
TempString2 = MIN(TempString2, StrStr(CurrentLocation, L"\n"));
|
||||||
ASSERT(TempString == NULL);
|
ASSERT(TempString == NULL);
|
||||||
TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);
|
TempString = StrnCatGrow(&TempString, NULL, CurrentLocation, TempString2==NULL?0:TempString2 - CurrentLocation);
|
||||||
|
if (TempString == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// copy and save the current line.
|
// copy and save the current line.
|
||||||
//
|
//
|
||||||
ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));
|
ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));
|
||||||
StrnCatGrow (HelpText, HelpSize, TempString, 0);
|
StrnCatGrow (HelpText, HelpSize, TempString, 0);
|
||||||
|
if (HelpText == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);
|
StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);
|
||||||
|
if (HelpText == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHELL_FREE_NON_NULL(TempString);
|
SHELL_FREE_NON_NULL(TempString);
|
||||||
|
@@ -577,6 +577,9 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandLineCopy = StrnCatGrow(&CommandLineCopy, NULL, NewCommandLine, 0);
|
CommandLineCopy = StrnCatGrow(&CommandLineCopy, NULL, NewCommandLine, 0);
|
||||||
|
if (CommandLineCopy == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
Split = NULL;
|
Split = NULL;
|
||||||
FirstLocation = CommandLineCopy + StrLen(CommandLineCopy);
|
FirstLocation = CommandLineCopy + StrLen(CommandLineCopy);
|
||||||
@@ -1030,16 +1033,19 @@ UpdateStdInStdOutStdErr(
|
|||||||
//
|
//
|
||||||
if (!EFI_ERROR(Status) && StdInVarName != NULL) {
|
if (!EFI_ERROR(Status) && StdInVarName != NULL) {
|
||||||
TempHandle = CreateFileInterfaceEnv(StdInVarName);
|
TempHandle = CreateFileInterfaceEnv(StdInVarName);
|
||||||
if (!InUnicode) {
|
if (TempHandle == NULL) {
|
||||||
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
}
|
|
||||||
Size = 0;
|
|
||||||
ASSERT(TempHandle != NULL);
|
|
||||||
if (((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
|
|
||||||
Status = EFI_INVALID_PARAMETER;
|
|
||||||
} else {
|
} else {
|
||||||
ShellParameters->StdIn = TempHandle;
|
if (!InUnicode) {
|
||||||
gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
|
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
|
||||||
|
}
|
||||||
|
Size = 0;
|
||||||
|
if (((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
|
||||||
|
Status = EFI_INVALID_PARAMETER;
|
||||||
|
} else {
|
||||||
|
ShellParameters->StdIn = TempHandle;
|
||||||
|
gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -488,10 +488,12 @@ EfiShellGetFilePathFromDevicePath(
|
|||||||
This function converts a file system style name to a device path, by replacing any
|
This function converts a file system style name to a device path, by replacing any
|
||||||
mapping references to the associated device path.
|
mapping references to the associated device path.
|
||||||
|
|
||||||
@param Path the pointer to the path
|
@param[in] Path The pointer to the path.
|
||||||
|
|
||||||
@return all The pointer of the file path. The file path is callee
|
@return The pointer of the file path. The file path is callee
|
||||||
allocated and should be freed by the caller.
|
allocated and should be freed by the caller.
|
||||||
|
@retval NULL The path could not be found.
|
||||||
|
@retval NULL There was not enough available memory.
|
||||||
**/
|
**/
|
||||||
EFI_DEVICE_PATH_PROTOCOL *
|
EFI_DEVICE_PATH_PROTOCOL *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@@ -525,7 +527,9 @@ EfiShellGetDevicePathFromFilePath(
|
|||||||
Size = StrSize(Cwd);
|
Size = StrSize(Cwd);
|
||||||
Size += StrSize(Path);
|
Size += StrSize(Path);
|
||||||
NewPath = AllocateZeroPool(Size);
|
NewPath = AllocateZeroPool(Size);
|
||||||
ASSERT(NewPath != NULL);
|
if (NewPath == NULL) {
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
StrCpy(NewPath, Cwd);
|
StrCpy(NewPath, Cwd);
|
||||||
if (*Path == L'\\') {
|
if (*Path == L'\\') {
|
||||||
Path++;
|
Path++;
|
||||||
@@ -543,8 +547,7 @@ EfiShellGetDevicePathFromFilePath(
|
|||||||
//
|
//
|
||||||
ASSERT((MapName == NULL && Size == 0) || (MapName != NULL));
|
ASSERT((MapName == NULL && Size == 0) || (MapName != NULL));
|
||||||
MapName = StrnCatGrow(&MapName, &Size, Path, (StrStr(Path, L":")-Path+1));
|
MapName = StrnCatGrow(&MapName, &Size, Path, (StrStr(Path, L":")-Path+1));
|
||||||
if (MapName[StrLen(MapName)-1] != L':') {
|
if (MapName == NULL || MapName[StrLen(MapName)-1] != L':') {
|
||||||
ASSERT(FALSE);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +567,6 @@ EfiShellGetDevicePathFromFilePath(
|
|||||||
//
|
//
|
||||||
DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath(DevicePath);
|
DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath(DevicePath);
|
||||||
if (DevicePathCopy == NULL) {
|
if (DevicePathCopy == NULL) {
|
||||||
ASSERT(FALSE);
|
|
||||||
FreePool(MapName);
|
FreePool(MapName);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@@ -1888,6 +1890,9 @@ EfiShellFindFilesInDir(
|
|||||||
TempString = NULL;
|
TempString = NULL;
|
||||||
Size = 0;
|
Size = 0;
|
||||||
TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0);
|
TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0);
|
||||||
|
if (TempString == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
TempSpot = StrStr(TempString, L";");
|
TempSpot = StrStr(TempString, L";");
|
||||||
|
|
||||||
if (TempSpot != NULL) {
|
if (TempSpot != NULL) {
|
||||||
@@ -1895,6 +1900,9 @@ EfiShellFindFilesInDir(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
|
TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
|
||||||
|
if (TempString == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
BasePath = TempString;
|
BasePath = TempString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2239,6 +2247,9 @@ EfiShellFindFiles(
|
|||||||
|
|
||||||
ASSERT(MapName == NULL);
|
ASSERT(MapName == NULL);
|
||||||
MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);
|
MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);
|
||||||
|
if (MapName == NULL) {
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy);
|
RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy);
|
||||||
@@ -2759,7 +2770,7 @@ EfiShellSetCurDir(
|
|||||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
||||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
|
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
|
||||||
if (MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {
|
if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {
|
||||||
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
|
||||||
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
|
||||||
}
|
}
|
||||||
|
@@ -978,7 +978,7 @@ ShellCommandRunBcfg (
|
|||||||
ShellStatus = BcfgAddDebug1(
|
ShellStatus = BcfgAddDebug1(
|
||||||
CurrentOperation.Number1,
|
CurrentOperation.Number1,
|
||||||
CurrentOperation.FileName,
|
CurrentOperation.FileName,
|
||||||
CurrentOperation.Description,
|
CurrentOperation.Description==NULL?L"":CurrentOperation.Description,
|
||||||
CurrentOperation.Order,
|
CurrentOperation.Order,
|
||||||
Length / sizeof(CurrentOperation.Order[0]),
|
Length / sizeof(CurrentOperation.Order[0]),
|
||||||
CurrentOperation.Target,
|
CurrentOperation.Target,
|
||||||
|
@@ -178,6 +178,7 @@ HFileImageRead (
|
|||||||
|
|
||||||
StatusBarSetStatusString (UnicodeBuffer);
|
StatusBarSetStatusString (UnicodeBuffer);
|
||||||
FreePool (UnicodeBuffer);
|
FreePool (UnicodeBuffer);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
HFileImageSetFileName (FileName);
|
HFileImageSetFileName (FileName);
|
||||||
|
@@ -303,6 +303,9 @@ ConvertStringToGuid (
|
|||||||
}
|
}
|
||||||
TempCopy = NULL;
|
TempCopy = NULL;
|
||||||
TempCopy = StrnCatGrow(&TempCopy, NULL, StringGuid, 0);
|
TempCopy = StrnCatGrow(&TempCopy, NULL, StringGuid, 0);
|
||||||
|
if (TempCopy == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Walker = TempCopy;
|
Walker = TempCopy;
|
||||||
TempSpot = StrStr(Walker, L"-");
|
TempSpot = StrStr(Walker, L"-");
|
||||||
if (TempSpot != NULL) {
|
if (TempSpot != NULL) {
|
||||||
|
@@ -978,7 +978,7 @@ ShellCommandRunBcfgInstall (
|
|||||||
ShellStatus = BcfgAddInstall1(
|
ShellStatus = BcfgAddInstall1(
|
||||||
CurrentOperation.Number1,
|
CurrentOperation.Number1,
|
||||||
CurrentOperation.FileName,
|
CurrentOperation.FileName,
|
||||||
CurrentOperation.Description,
|
CurrentOperation.Description==NULL?L"":CurrentOperation.Description,
|
||||||
CurrentOperation.Order,
|
CurrentOperation.Order,
|
||||||
Length / sizeof(CurrentOperation.Order[0]),
|
Length / sizeof(CurrentOperation.Order[0]),
|
||||||
CurrentOperation.Target,
|
CurrentOperation.Target,
|
||||||
|
@@ -376,29 +376,33 @@ ShellCommandRunFor (
|
|||||||
}
|
}
|
||||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
|
||||||
}
|
}
|
||||||
//
|
if (ArgSet == NULL) {
|
||||||
// set up for an 'in' for loop
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
//
|
|
||||||
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;
|
|
||||||
} else {
|
} 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);
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
Info->RemoveSubstAlias = TRUE;
|
||||||
|
}
|
||||||
|
CurrentScriptFile->CurrentCommand->Data = Info;
|
||||||
}
|
}
|
||||||
CurrentScriptFile->CurrentCommand->Data = Info;
|
|
||||||
} else if (gUnicodeCollation->StriColl(
|
} else if (gUnicodeCollation->StriColl(
|
||||||
gUnicodeCollation,
|
gUnicodeCollation,
|
||||||
L"run",
|
L"run",
|
||||||
@@ -413,80 +417,61 @@ ShellCommandRunFor (
|
|||||||
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);
|
||||||
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
// ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);
|
||||||
}
|
}
|
||||||
//
|
if (ArgSet == NULL) {
|
||||||
// set up for a 'run' for loop
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
//
|
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
TempSpot = StrStr(ArgSetWalker, L")");
|
//
|
||||||
if (TempSpot != NULL) {
|
// set up for a 'run' for loop
|
||||||
TempString = TempSpot+1;
|
//
|
||||||
if (*(TempString) != CHAR_NULL) {
|
Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||||
while(TempString != NULL && *TempString == L' ') {
|
ASSERT(Info != NULL);
|
||||||
TempString++;
|
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||||
}
|
Info->ReplacementName = Info->Set;
|
||||||
if (StrLen(TempString) > 0) {
|
Info->CurrentValue = NULL;
|
||||||
TempSpot = NULL;
|
ArgSetWalker = ArgSet;
|
||||||
}
|
if (ArgSetWalker[0] != L'(') {
|
||||||
}
|
|
||||||
}
|
|
||||||
if (TempSpot == NULL) {
|
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
NULL,
|
NULL,
|
||||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||||
gShellLevel1HiiHandle,
|
gShellLevel1HiiHandle,
|
||||||
|
ArgSet,
|
||||||
CurrentScriptFile!=NULL
|
CurrentScriptFile!=NULL
|
||||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
*TempSpot = CHAR_NULL;
|
TempSpot = StrStr(ArgSetWalker, L")");
|
||||||
ArgSetWalker++;
|
if (TempSpot != NULL) {
|
||||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
TempString = TempSpot+1;
|
||||||
ArgSetWalker++;
|
if (*(TempString) != CHAR_NULL) {
|
||||||
|
while(TempString != NULL && *TempString == L' ') {
|
||||||
|
TempString++;
|
||||||
|
}
|
||||||
|
if (StrLen(TempString) > 0) {
|
||||||
|
TempSpot = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!ShellIsValidForNumber(ArgSetWalker)) {
|
if (TempSpot == NULL) {
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
NULL,
|
NULL,
|
||||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||||
gShellLevel1HiiHandle,
|
gShellLevel1HiiHandle,
|
||||||
ArgSet,
|
|
||||||
CurrentScriptFile!=NULL
|
CurrentScriptFile!=NULL
|
||||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
if (ArgSetWalker[0] == L'-') {
|
*TempSpot = CHAR_NULL;
|
||||||
Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
|
ArgSetWalker++;
|
||||||
} else {
|
|
||||||
Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);
|
|
||||||
}
|
|
||||||
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
|
||||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||||
ArgSetWalker++;
|
ArgSetWalker++;
|
||||||
}
|
}
|
||||||
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
if (!ShellIsValidForNumber(ArgSetWalker)) {
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
@@ -500,73 +485,96 @@ ShellCommandRunFor (
|
|||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
if (ArgSetWalker[0] == L'-') {
|
if (ArgSetWalker[0] == L'-') {
|
||||||
Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
|
Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
|
||||||
} else {
|
} else {
|
||||||
Info->End = (INTN)ShellStrToUintn(ArgSetWalker);
|
Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);
|
||||||
}
|
}
|
||||||
if (Info->Current < Info->End) {
|
|
||||||
Info->Step = 1;
|
|
||||||
} else {
|
|
||||||
Info->Step = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
||||||
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||||
ArgSetWalker++;
|
ArgSetWalker++;
|
||||||
}
|
}
|
||||||
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
|
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
||||||
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
ShellPrintHiiEx(
|
||||||
ShellPrintHiiEx(
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
NULL,
|
||||||
NULL,
|
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
gShellLevel1HiiHandle,
|
||||||
gShellLevel1HiiHandle,
|
ArgSet,
|
||||||
ArgSet,
|
CurrentScriptFile!=NULL
|
||||||
CurrentScriptFile!=NULL
|
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
} else {
|
||||||
|
if (ArgSetWalker[0] == L'-') {
|
||||||
|
Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
|
||||||
} else {
|
} else {
|
||||||
if (*ArgSetWalker == L')') {
|
Info->End = (INTN)ShellStrToUintn(ArgSetWalker);
|
||||||
ASSERT(Info->Step == 1 || Info->Step == -1);
|
}
|
||||||
} else {
|
if (Info->Current < Info->End) {
|
||||||
if (ArgSetWalker[0] == L'-') {
|
Info->Step = 1;
|
||||||
Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
|
} else {
|
||||||
} else {
|
Info->Step = -1;
|
||||||
Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (StrStr(ArgSetWalker, L" ") != NULL) {
|
ArgSetWalker = StrStr(ArgSetWalker, L" ");
|
||||||
ShellPrintHiiEx(
|
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
|
||||||
-1,
|
ArgSetWalker++;
|
||||||
-1,
|
}
|
||||||
NULL,
|
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
|
||||||
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
|
||||||
gShellLevel1HiiHandle,
|
ShellPrintHiiEx(
|
||||||
ArgSet,
|
-1,
|
||||||
CurrentScriptFile!=NULL
|
-1,
|
||||||
&& CurrentScriptFile->CurrentCommand!=NULL
|
NULL,
|
||||||
? CurrentScriptFile->CurrentCommand->Line:0);
|
STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
gShellLevel1HiiHandle,
|
||||||
|
ArgSet,
|
||||||
|
CurrentScriptFile!=NULL
|
||||||
|
&& CurrentScriptFile->CurrentCommand!=NULL
|
||||||
|
? CurrentScriptFile->CurrentCommand->Line:0);
|
||||||
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
|
} else {
|
||||||
|
if (*ArgSetWalker == L')') {
|
||||||
|
ASSERT(Info->Step == 1 || Info->Step == -1);
|
||||||
|
} else {
|
||||||
|
if (ArgSetWalker[0] == L'-') {
|
||||||
|
Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+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 (ShellStatus == SHELL_SUCCESS) {
|
||||||
if (ShellStatus == SHELL_SUCCESS) {
|
if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
||||||
if (InternalIsAliasOnList(Info->ReplacementName, &CurrentScriptFile->SubstList)) {
|
Info->RemoveSubstAlias = FALSE;
|
||||||
Info->RemoveSubstAlias = FALSE;
|
} else {
|
||||||
} else {
|
Info->RemoveSubstAlias = TRUE;
|
||||||
Info->RemoveSubstAlias = TRUE;
|
}
|
||||||
|
}
|
||||||
|
if (CurrentScriptFile->CurrentCommand != NULL) {
|
||||||
|
CurrentScriptFile->CurrentCommand->Data = Info;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (CurrentScriptFile->CurrentCommand != NULL) {
|
|
||||||
CurrentScriptFile->CurrentCommand->Data = Info;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ShellPrintHiiEx(
|
ShellPrintHiiEx(
|
||||||
@@ -665,27 +673,30 @@ ShellCommandRunFor (
|
|||||||
//
|
//
|
||||||
ASSERT(TempString == NULL);
|
ASSERT(TempString == NULL);
|
||||||
TempString = StrnCatGrow(&TempString, NULL, Info->CurrentValue, 0);
|
TempString = StrnCatGrow(&TempString, NULL, Info->CurrentValue, 0);
|
||||||
TempSpot = StrStr(TempString, L"\" \"");
|
if (TempString == NULL) {
|
||||||
if (TempSpot != NULL) {
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
*TempSpot = CHAR_NULL;
|
} else {
|
||||||
}
|
TempSpot = StrStr(TempString, L"\" \"");
|
||||||
while (TempString[StrLen(TempString)-1] == L'\"') {
|
if (TempSpot != NULL) {
|
||||||
TempString[StrLen(TempString)-1] = CHAR_NULL;
|
*TempSpot = CHAR_NULL;
|
||||||
}
|
}
|
||||||
InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
while (TempString[StrLen(TempString)-1] == L'\"') {
|
||||||
Info->CurrentValue += StrLen(TempString);
|
TempString[StrLen(TempString)-1] = CHAR_NULL;
|
||||||
|
}
|
||||||
|
InternalUpdateAliasOnList(Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||||
|
Info->CurrentValue += StrLen(TempString);
|
||||||
|
|
||||||
if (Info->CurrentValue[0] == L'\"') {
|
if (Info->CurrentValue[0] == L'\"') {
|
||||||
Info->CurrentValue++;
|
Info->CurrentValue++;
|
||||||
|
}
|
||||||
|
while (Info->CurrentValue[0] == L' ') {
|
||||||
|
Info->CurrentValue++;
|
||||||
|
}
|
||||||
|
if (Info->CurrentValue[0] == L'\"') {
|
||||||
|
Info->CurrentValue++;
|
||||||
|
}
|
||||||
|
FreePool(TempString);
|
||||||
}
|
}
|
||||||
while (Info->CurrentValue[0] == L' ') {
|
|
||||||
Info->CurrentValue++;
|
|
||||||
}
|
|
||||||
if (Info->CurrentValue[0] == L'\"') {
|
|
||||||
Info->CurrentValue++;
|
|
||||||
}
|
|
||||||
FreePool(TempString);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
CurrentScriptFile->CurrentCommand->Data = NULL;
|
CurrentScriptFile->CurrentCommand->Data = NULL;
|
||||||
//
|
//
|
||||||
|
@@ -739,6 +739,9 @@ MoveToTagSpecial (
|
|||||||
//
|
//
|
||||||
CommandName = NULL;
|
CommandName = NULL;
|
||||||
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
|
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
|
||||||
|
if (CommandName == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
CommandWalker = CommandName;
|
CommandWalker = CommandName;
|
||||||
while (CommandWalker[0] == L' ') {
|
while (CommandWalker[0] == L' ') {
|
||||||
CommandWalker++;
|
CommandWalker++;
|
||||||
|
@@ -145,6 +145,10 @@ TestNodeForMove (
|
|||||||
//
|
//
|
||||||
CommandName = NULL;
|
CommandName = NULL;
|
||||||
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
|
CommandName = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);
|
||||||
|
if (CommandName == NULL) {
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
CommandNameWalker = CommandName;
|
CommandNameWalker = CommandName;
|
||||||
while(CommandNameWalker[0] == L' ') {
|
while(CommandNameWalker[0] == L' ') {
|
||||||
CommandNameWalker++;
|
CommandNameWalker++;
|
||||||
|
@@ -414,6 +414,9 @@ PerformSingleMappingDisplay(
|
|||||||
|
|
||||||
CurrentName = NULL;
|
CurrentName = NULL;
|
||||||
CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
|
CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
|
||||||
|
if (CurrentName == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
TempSpot = StrStr(CurrentName, L";");
|
TempSpot = StrStr(CurrentName, L";");
|
||||||
if (TempSpot != NULL) {
|
if (TempSpot != NULL) {
|
||||||
*TempSpot = CHAR_NULL;
|
*TempSpot = CHAR_NULL;
|
||||||
|
@@ -642,10 +642,15 @@ CheckAndSetTimeZone (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status = gRT->GetTime(&TheTime, NULL);
|
Status = gRT->GetTime(&TheTime, NULL);
|
||||||
ASSERT_EFI_ERROR(Status);
|
if (EFI_ERROR(Status)) {
|
||||||
|
return (SHELL_DEVICE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
TimeZoneCopy = NULL;
|
TimeZoneCopy = NULL;
|
||||||
TimeZoneCopy = StrnCatGrow(&TimeZoneCopy, NULL, TimeZoneString, 0);
|
TimeZoneCopy = StrnCatGrow(&TimeZoneCopy, NULL, TimeZoneString, 0);
|
||||||
|
if (TimeZoneCopy == NULL) {
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Walker = TimeZoneCopy;
|
Walker = TimeZoneCopy;
|
||||||
Walker2 = StrStr(Walker, L":");
|
Walker2 = StrStr(Walker, L":");
|
||||||
if (Walker2 != NULL && *Walker2 == L':') {
|
if (Walker2 != NULL && *Walker2 == L':') {
|
||||||
|
@@ -226,6 +226,10 @@ VerifyIntermediateDirectories (
|
|||||||
PathCopy = StrnCatGrow(&PathCopy, NULL, Path, 0);
|
PathCopy = StrnCatGrow(&PathCopy, NULL, Path, 0);
|
||||||
FileHandle = NULL;
|
FileHandle = NULL;
|
||||||
|
|
||||||
|
if (PathCopy == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
for (TempSpot = &PathCopy[StrLen(PathCopy)-1] ; *TempSpot != CHAR_NULL && *TempSpot != L'\\' ; TempSpot = &PathCopy[StrLen(PathCopy)-1]){
|
for (TempSpot = &PathCopy[StrLen(PathCopy)-1] ; *TempSpot != CHAR_NULL && *TempSpot != L'\\' ; TempSpot = &PathCopy[StrLen(PathCopy)-1]){
|
||||||
*TempSpot = CHAR_NULL;
|
*TempSpot = CHAR_NULL;
|
||||||
}
|
}
|
||||||
|
@@ -79,11 +79,16 @@ DoTouchByHandle (
|
|||||||
|
|
||||||
if (FS == NULL) {
|
if (FS == NULL) {
|
||||||
FS = StrnCatGrow(&FS, NULL, Name, 0);
|
FS = StrnCatGrow(&FS, NULL, Name, 0);
|
||||||
TempSpot = StrStr(FS, L"\\");
|
if (FS != NULL) {
|
||||||
if (TempSpot != NULL) {
|
TempSpot = StrStr(FS, L"\\");
|
||||||
*TempSpot = CHAR_NULL;
|
if (TempSpot != NULL) {
|
||||||
|
*TempSpot = CHAR_NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (FS == NULL) {
|
||||||
|
return (EFI_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// do it
|
// do it
|
||||||
|
Reference in New Issue
Block a user