Verify memory allocations were successful.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10909 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -103,8 +103,11 @@ typedef struct {
|
|||||||
@param[in] Alias The alias to test for.
|
@param[in] Alias The alias to test for.
|
||||||
@param[in] CommandString The updated command string.
|
@param[in] CommandString The updated command string.
|
||||||
@param[in,out] List The list to search.
|
@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.
|
||||||
**/
|
**/
|
||||||
VOID
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InternalUpdateAliasOnList(
|
InternalUpdateAliasOnList(
|
||||||
IN CONST CHAR16 *Alias,
|
IN CONST CHAR16 *Alias,
|
||||||
@ -139,12 +142,16 @@ InternalUpdateAliasOnList(
|
|||||||
}
|
}
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
Node = AllocateZeroPool(sizeof(ALIAS_LIST));
|
Node = AllocateZeroPool(sizeof(ALIAS_LIST));
|
||||||
|
if (Node == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
ASSERT(Node->Alias == NULL);
|
ASSERT(Node->Alias == NULL);
|
||||||
Node->Alias = StrnCatGrow(&Node->Alias, NULL, Alias, 0);
|
Node->Alias = StrnCatGrow(&Node->Alias, NULL, Alias, 0);
|
||||||
ASSERT(Node->CommandString == NULL);
|
ASSERT(Node->CommandString == NULL);
|
||||||
Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
|
Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);
|
||||||
InsertTailList(List, &Node->Link);
|
InsertTailList(List, &Node->Link);
|
||||||
}
|
}
|
||||||
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,10 +186,19 @@ ShellCommandRunCd (
|
|||||||
// change directory on other drive letter
|
// change directory on other drive letter
|
||||||
//
|
//
|
||||||
Drive = AllocateZeroPool(StrSize(Param1));
|
Drive = AllocateZeroPool(StrSize(Param1));
|
||||||
|
if (Drive == NULL) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
|
||||||
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
Drive = StrCpy(Drive, Param1);
|
Drive = StrCpy(Drive, Param1);
|
||||||
Path = StrStr(Drive, L":");
|
Path = StrStr(Drive, L":");
|
||||||
*(++Path) = CHAR_NULL;
|
*(++Path) = CHAR_NULL;
|
||||||
|
if (Path == Drive + StrLen(Drive)) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
||||||
|
ShellStatus = SHELL_NOT_FOUND;
|
||||||
|
} else {
|
||||||
Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);
|
Status = gEfiShellProtocol->SetCurDir(Drive, ++Path);
|
||||||
|
}
|
||||||
|
|
||||||
if (Status == EFI_NOT_FOUND) {
|
if (Status == EFI_NOT_FOUND) {
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);
|
||||||
@ -201,6 +210,7 @@ ShellCommandRunCd (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Drive != NULL) {
|
if (Drive != NULL) {
|
||||||
FreePool(Drive);
|
FreePool(Drive);
|
||||||
|
@ -287,6 +287,13 @@ ValidateAndCopyFiles(
|
|||||||
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);
|
||||||
DestPath = AllocatePool(PathLen);
|
DestPath = AllocatePool(PathLen);
|
||||||
|
|
||||||
|
if (HiiOutput == NULL || HiiOutput == NULL || HiiResultOk == NULL) {
|
||||||
|
SHELL_FREE_NON_NULL(DestPath);
|
||||||
|
SHELL_FREE_NON_NULL(HiiOutput);
|
||||||
|
SHELL_FREE_NON_NULL(HiiResultOk);
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Go through the list of files to copy...
|
// Go through the list of files to copy...
|
||||||
//
|
//
|
||||||
|
@ -349,6 +349,10 @@ PrintLsOutput(
|
|||||||
|
|
||||||
if (Rec){
|
if (Rec){
|
||||||
DirectoryName = AllocatePool(LongestPath + 2*sizeof(CHAR16));
|
DirectoryName = AllocatePool(LongestPath + 2*sizeof(CHAR16));
|
||||||
|
if (DirectoryName == NULL) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
|
||||||
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
|
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)
|
||||||
; !IsNull(&ListHead->Link, &Node->Link)
|
; !IsNull(&ListHead->Link, &Node->Link)
|
||||||
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
|
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)
|
||||||
@ -374,6 +378,7 @@ PrintLsOutput(
|
|||||||
}
|
}
|
||||||
FreePool(DirectoryName);
|
FreePool(DirectoryName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreePool(CorrectedPath);
|
FreePool(CorrectedPath);
|
||||||
ShellCloseFileMetaArg(&ListHead);
|
ShellCloseFileMetaArg(&ListHead);
|
||||||
|
@ -99,7 +99,7 @@ UpdateMapping (
|
|||||||
//
|
//
|
||||||
// Find each handle with Simple File System
|
// Find each handle with Simple File System
|
||||||
//
|
//
|
||||||
HandleList = GetHandleListByPotocol(&gEfiSimpleFileSystemProtocolGuid);
|
HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);
|
||||||
if (HandleList != NULL) {
|
if (HandleList != NULL) {
|
||||||
//
|
//
|
||||||
// Do a count of the handles
|
// Do a count of the handles
|
||||||
@ -503,6 +503,9 @@ PerformMappingDisplay(
|
|||||||
HandleBuffer);
|
HandleBuffer);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
HandleBuffer = AllocatePool(BufferSize);
|
HandleBuffer = AllocatePool(BufferSize);
|
||||||
|
if (HandleBuffer == NULL) {
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Status = gBS->LocateHandle(
|
Status = gBS->LocateHandle(
|
||||||
ByProtocol,
|
ByProtocol,
|
||||||
&gEfiDevicePathProtocolGuid,
|
&gEfiDevicePathProtocolGuid,
|
||||||
@ -542,6 +545,9 @@ PerformMappingDisplay(
|
|||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
FreePool(HandleBuffer);
|
FreePool(HandleBuffer);
|
||||||
HandleBuffer = AllocatePool(BufferSize);
|
HandleBuffer = AllocatePool(BufferSize);
|
||||||
|
if (HandleBuffer == NULL) {
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Status = gBS->LocateHandle(
|
Status = gBS->LocateHandle(
|
||||||
ByProtocol,
|
ByProtocol,
|
||||||
&gEfiBlockIoProtocolGuid,
|
&gEfiBlockIoProtocolGuid,
|
||||||
@ -549,8 +555,7 @@ PerformMappingDisplay(
|
|||||||
&BufferSize,
|
&BufferSize,
|
||||||
HandleBuffer);
|
HandleBuffer);
|
||||||
}
|
}
|
||||||
ASSERT_EFI_ERROR(Status);
|
if (!EFI_ERROR(Status)) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the map name(s) for each one.
|
// Get the map name(s) for each one.
|
||||||
//
|
//
|
||||||
@ -580,6 +585,7 @@ PerformMappingDisplay(
|
|||||||
HandleBuffer[LoopVar]);
|
HandleBuffer[LoopVar]);
|
||||||
}
|
}
|
||||||
FreePool(HandleBuffer);
|
FreePool(HandleBuffer);
|
||||||
|
}
|
||||||
return (SHELL_SUCCESS);
|
return (SHELL_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,10 @@ GetDestinationLocation(
|
|||||||
NewSize = StrSize(Cwd);
|
NewSize = StrSize(Cwd);
|
||||||
NewSize += StrSize(DestDir);
|
NewSize += StrSize(DestDir);
|
||||||
DestPath = AllocateZeroPool(NewSize);
|
DestPath = AllocateZeroPool(NewSize);
|
||||||
|
if (DestPath == NULL) {
|
||||||
|
ShellCloseFileMetaArg(&DestList);
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
StrCpy(DestPath, Cwd);
|
StrCpy(DestPath, Cwd);
|
||||||
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
|
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
|
||||||
StrCat(DestPath, L"\\");
|
StrCat(DestPath, L"\\");
|
||||||
@ -162,6 +166,10 @@ GetDestinationLocation(
|
|||||||
} else {
|
} else {
|
||||||
ASSERT(DestPath == NULL);
|
ASSERT(DestPath == NULL);
|
||||||
DestPath = StrnCatGrow(&DestPath, NULL, DestDir, 0);
|
DestPath = StrnCatGrow(&DestPath, NULL, DestDir, 0);
|
||||||
|
if (DestPath == NULL) {
|
||||||
|
ShellCloseFileMetaArg(&DestList);
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
|
Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&DestList->Link);
|
||||||
@ -175,6 +183,10 @@ GetDestinationLocation(
|
|||||||
}
|
}
|
||||||
if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS) {
|
if (ShellIsDirectory(Node->FullName)==EFI_SUCCESS) {
|
||||||
DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
|
DestPath = AllocateZeroPool(StrSize(Node->FullName)+sizeof(CHAR16));
|
||||||
|
if (DestPath == NULL) {
|
||||||
|
ShellCloseFileMetaArg(&DestList);
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
StrCpy(DestPath, Node->FullName);
|
StrCpy(DestPath, Node->FullName);
|
||||||
StrCat(DestPath, L"\\");
|
StrCat(DestPath, L"\\");
|
||||||
} else {
|
} else {
|
||||||
@ -287,7 +299,10 @@ ValidateAndMoveFiles(
|
|||||||
NewSize = StrSize(DestPath);
|
NewSize = StrSize(DestPath);
|
||||||
NewSize += StrSize(Node->FileName) + sizeof(EFI_FILE_INFO) + sizeof(CHAR16);
|
NewSize += StrSize(Node->FileName) + sizeof(EFI_FILE_INFO) + sizeof(CHAR16);
|
||||||
NewFileInfo = AllocateZeroPool(NewSize);
|
NewFileInfo = AllocateZeroPool(NewSize);
|
||||||
ASSERT(NewFileInfo != NULL);
|
if (NewFileInfo == NULL) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);
|
||||||
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
||||||
|
} else {
|
||||||
CopyMem(NewFileInfo, Node->Info, sizeof(EFI_FILE_INFO));
|
CopyMem(NewFileInfo, Node->Info, sizeof(EFI_FILE_INFO));
|
||||||
if (DestPath[0] != L'\\') {
|
if (DestPath[0] != L'\\') {
|
||||||
StrCpy(NewFileInfo->FileName, L"\\");
|
StrCpy(NewFileInfo->FileName, L"\\");
|
||||||
@ -344,6 +359,7 @@ ValidateAndMoveFiles(
|
|||||||
} else {
|
} else {
|
||||||
ShellPrintEx(-1, -1, L"%s", HiiResultOk);
|
ShellPrintEx(-1, -1, L"%s", HiiResultOk);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // for loop
|
} // for loop
|
||||||
|
|
||||||
FreePool(DestPath);
|
FreePool(DestPath);
|
||||||
|
@ -41,6 +41,9 @@ PrintAllShellAlias(
|
|||||||
return (SHELL_SUCCESS);
|
return (SHELL_SUCCESS);
|
||||||
}
|
}
|
||||||
Alias = AllocateZeroPool(StrSize(ConstAllAliasList));
|
Alias = AllocateZeroPool(StrSize(ConstAllAliasList));
|
||||||
|
if (Alias == NULL) {
|
||||||
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
Walker = (CHAR16*)ConstAllAliasList;
|
Walker = (CHAR16*)ConstAllAliasList;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
Reference in New Issue
Block a user