diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-10-04 16:24:30 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-10-04 16:24:30 +0000 |
commit | 3c865f2064d37eaccd1693b878596d5138b0b38e (patch) | |
tree | ffe10112e71c18c5c4ec56f37cc670258b22fd5b /ShellPkg/Application/Shell/ShellParametersProtocol.c | |
parent | aca84419c4b5128b69215b8f6e4d34c36efb1fbc (diff) | |
download | edk2-platforms-3c865f2064d37eaccd1693b878596d5138b0b38e.tar.xz |
1) Removing ASSERTs for proper return values.
2) Verifying that memory allocations were successful.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10904 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell/ShellParametersProtocol.c')
-rw-r--r-- | ShellPkg/Application/Shell/ShellParametersProtocol.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 914853fdbf..5e3e48b414 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -280,7 +280,9 @@ CreatePopulateInstallShellParametersProtocol ( // Allocate the new structure
//
*NewShellParameters = AllocateZeroPool(sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
- ASSERT(NewShellParameters != NULL);
+ if ((*NewShellParameters) == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
//
// get loaded image protocol
@@ -307,19 +309,22 @@ CreatePopulateInstallShellParametersProtocol ( // no parameters via environment... ok
//
} else {
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ return (Status);
+ }
}
if (Size == 0 && LoadedImage->LoadOptionsSize != 0) {
+ ASSERT(FullCommandLine == NULL);
//
// Now we need to include a NULL terminator in the size.
//
Size = LoadedImage->LoadOptionsSize + sizeof(FullCommandLine[0]);
FullCommandLine = AllocateZeroPool(Size);
}
- if (LoadedImage->LoadOptionsSize != 0){
- StrCpy(FullCommandLine, LoadedImage->LoadOptions);
- }
if (FullCommandLine != NULL) {
+ if (LoadedImage->LoadOptionsSize != 0){
+ StrCpy(FullCommandLine, LoadedImage->LoadOptions);
+ }
//
// Populate Argc and Argv
//
@@ -685,6 +690,8 @@ UpdateStdInStdOutStdErr( ||(StdInFileName != NULL && StdInVarName != NULL)
||(StdErrVarName != NULL && !IsVolatileEnv(StdErrVarName))
||(StdOutVarName != NULL && !IsVolatileEnv(StdOutVarName))
+ ||(StrStr(NewCommandLine, L"connect -r") != NULL
+ && (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
){
Status = EFI_INVALID_PARAMETER;
} else {
@@ -733,31 +740,34 @@ UpdateStdInStdOutStdErr( ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdOutFileName);
}
Status = ShellOpenFileByName(StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
- ASSERT(TempHandle != NULL);
- if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
- //
- // Write out the UnicodeFileTag
- //
- Size = sizeof(CHAR16);
- TagBuffer[0] = UnicodeFileTag;
- TagBuffer[1] = CHAR_NULL;
- ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
- } else if (OutAppend) {
- //
- // Move to end of file
- //
- Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize(TempHandle, &FileSize);
+ if (TempHandle == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ } else {
+ if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
+ //
+ // Write out the UnicodeFileTag
+ //
+ Size = sizeof(CHAR16);
+ TagBuffer[0] = UnicodeFileTag;
+ TagBuffer[1] = CHAR_NULL;
+ ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
+ } else if (OutAppend) {
+ //
+ // Move to end of file
+ //
+ Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize(TempHandle, &FileSize);
+ if (!EFI_ERROR(Status)) {
+ Status = ShellInfoObject.NewEfiShellProtocol->SetFilePosition(TempHandle, FileSize);
+ }
+ }
+ if (!OutUnicode && !EFI_ERROR(Status)) {
+ TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
+ ASSERT(TempHandle != NULL);
+ }
if (!EFI_ERROR(Status)) {
- Status = ShellInfoObject.NewEfiShellProtocol->SetFilePosition(TempHandle, FileSize);
+ ShellParameters->StdOut = TempHandle;
}
}
- if (!OutUnicode && !EFI_ERROR(Status)) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- ASSERT(TempHandle != NULL);
- }
- if (!EFI_ERROR(Status)) {
- ShellParameters->StdOut = TempHandle;
- }
}
//
|