mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
ShellPkg: Shell: CodeQL Fixes
Includes changes across the module for the following CodeQL rules: - cpp/comparison-with-wider-type - cpp/overflow-buffer - cpp/redundant-null-check-param - cpp/uselesstest Co-authored-by: Taylor Beebe <taylor.d.beebe@gmail.com> Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
This commit is contained in:
parent
c69e5e647d
commit
875202bf85
5 changed files with 151 additions and 39 deletions
|
|
@ -354,7 +354,11 @@ CreatePopulateInstallShellParametersProtocol (
|
|||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
FullCommandLine = AllocateZeroPool (Size + LoadedImage->LoadOptionsSize);
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
|
||||
if (FullCommandLine == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
|
||||
}
|
||||
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
|
|
@ -738,6 +742,7 @@ UpdateStdInStdOutStdErr (
|
|||
OutAppend = FALSE;
|
||||
CommandLineCopy = NULL;
|
||||
FirstLocation = NULL;
|
||||
TempHandle = NULL;
|
||||
|
||||
if ((ShellParameters == NULL) || (SystemTableInfo == NULL) || (OldStdIn == NULL) || (OldStdOut == NULL) || (OldStdErr == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
|
|
@ -1176,7 +1181,10 @@ UpdateStdInStdOutStdErr (
|
|||
|
||||
if (!ErrUnicode && !EFI_ERROR (Status)) {
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
ASSERT (TempHandle != NULL);
|
||||
if (TempHandle == NULL) {
|
||||
ASSERT (TempHandle != NULL);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
|
@ -1223,7 +1231,10 @@ UpdateStdInStdOutStdErr (
|
|||
|
||||
if (!OutUnicode && !EFI_ERROR (Status)) {
|
||||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
ASSERT (TempHandle != NULL);
|
||||
if (TempHandle == NULL) {
|
||||
ASSERT (TempHandle != NULL);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
|
@ -1245,9 +1256,13 @@ UpdateStdInStdOutStdErr (
|
|||
}
|
||||
|
||||
TempHandle = CreateFileInterfaceEnv (StdOutVarName);
|
||||
ASSERT (TempHandle != NULL);
|
||||
ShellParameters->StdOut = TempHandle;
|
||||
gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
|
||||
if (TempHandle == NULL) {
|
||||
ASSERT (TempHandle != NULL);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
ShellParameters->StdOut = TempHandle;
|
||||
gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1262,9 +1277,13 @@ UpdateStdInStdOutStdErr (
|
|||
}
|
||||
|
||||
TempHandle = CreateFileInterfaceEnv (StdErrVarName);
|
||||
ASSERT (TempHandle != NULL);
|
||||
ShellParameters->StdErr = TempHandle;
|
||||
gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
|
||||
if (TempHandle == NULL) {
|
||||
ASSERT (TempHandle != NULL);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
ShellParameters->StdErr = TempHandle;
|
||||
gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -1307,8 +1326,12 @@ UpdateStdInStdOutStdErr (
|
|||
TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
|
||||
}
|
||||
|
||||
ShellParameters->StdIn = TempHandle;
|
||||
gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
|
||||
if (TempHandle == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
} else {
|
||||
ShellParameters->StdIn = TempHandle;
|
||||
gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue