diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-14 19:21:13 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-14 19:21:13 +0000 |
commit | 532691c8ba90e5022174503ab0781322c6f79cab (patch) | |
tree | 7c598451898c979b99cdfa0ec1573d509d5ee1ff /ShellPkg/Application/Shell/ShellParametersProtocol.c | |
parent | de2a15eebbf467c335f3e28ff0ba0ca6dd0ddcf2 (diff) | |
download | edk2-platforms-532691c8ba90e5022174503ab0781322c6f79cab.tar.xz |
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
Diffstat (limited to 'ShellPkg/Application/Shell/ShellParametersProtocol.c')
-rw-r--r-- | ShellPkg/Application/Shell/ShellParametersProtocol.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 5beaadab2e..55cf3c279e 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -577,6 +577,9 @@ UpdateStdInStdOutStdErr( }
CommandLineCopy = StrnCatGrow(&CommandLineCopy, NULL, NewCommandLine, 0);
+ if (CommandLineCopy == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
Status = EFI_SUCCESS;
Split = NULL;
FirstLocation = CommandLineCopy + StrLen(CommandLineCopy);
@@ -1030,16 +1033,19 @@ UpdateStdInStdOutStdErr( //
if (!EFI_ERROR(Status) && StdInVarName != NULL) {
TempHandle = CreateFileInterfaceEnv(StdInVarName);
- if (!InUnicode) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- }
- Size = 0;
- ASSERT(TempHandle != NULL);
- if (((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
- Status = EFI_INVALID_PARAMETER;
+ if (TempHandle == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
} else {
- ShellParameters->StdIn = TempHandle;
- gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
+ if (!InUnicode) {
+ 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);
+ }
}
}
|