mirror of https://github.com/acidanthera/audk.git
ShellPkg: UefiShellLevel1CommandsLib: 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
17ad30ae23
commit
86d91f4454
|
@ -334,7 +334,10 @@ ShellCommandRunFor (
|
|||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
if (CurrentScriptFile == NULL) {
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if ((CurrentScriptFile->CurrentCommand != NULL) && (CurrentScriptFile->CurrentCommand->Data == NULL)) {
|
||||
FirstPass = TRUE;
|
||||
|
@ -687,6 +690,10 @@ ShellCommandRunFor (
|
|||
}
|
||||
|
||||
TempString = AllocateZeroPool (50*sizeof (CHAR16));
|
||||
if (TempString == NULL) {
|
||||
return (SHELL_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
||||
UnicodeSPrint (TempString, 50*sizeof (CHAR16), L"%d", Info->Current);
|
||||
InternalUpdateAliasOnList (Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
|
||||
FreePool (TempString);
|
||||
|
|
|
@ -71,6 +71,11 @@ ShellCommandRunGoto (
|
|||
ASSERT ((CompareString == NULL && Size == 0) || (CompareString != NULL));
|
||||
CompareString = StrnCatGrow (&CompareString, &Size, L":", 0);
|
||||
CompareString = StrnCatGrow (&CompareString, &Size, ShellCommandLineGetRawValue (Package, 1), 0);
|
||||
if (CompareString == NULL) {
|
||||
ShellCommandLineFreeVarList (Package);
|
||||
return SHELL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Check forwards and then backwards for a label...
|
||||
//
|
||||
|
|
|
@ -99,7 +99,11 @@ IsValidProfile (
|
|||
CONST CHAR16 *TempLocation;
|
||||
|
||||
ProfilesString = ShellGetEnvironmentVariable (L"profiles");
|
||||
ASSERT (ProfilesString != NULL);
|
||||
if (ProfilesString == NULL) {
|
||||
ASSERT (ProfilesString != NULL);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
TempLocation = StrStr (ProfilesString, String);
|
||||
if ((TempLocation != NULL) && (*(TempLocation-1) == L';') && (*(TempLocation+StrLen (String)) == L';')) {
|
||||
return (TRUE);
|
||||
|
@ -895,6 +899,10 @@ ShellCommandRunIf (
|
|||
// Make sure that an End exists.
|
||||
//
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
if (CurrentScriptFile == NULL) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (!MoveToTag (GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
|
@ -1076,6 +1084,9 @@ ShellCommandRunElse (
|
|||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
if (CurrentScriptFile == NULL) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (!MoveToTag (GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
|
@ -1158,6 +1169,10 @@ ShellCommandRunEndIf (
|
|||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
if (CurrentScriptFile == NULL) {
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (!MoveToTag (GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
|
||||
ShellPrintHiiEx (
|
||||
-1,
|
||||
|
|
|
@ -35,7 +35,10 @@ ShellCommandRunShift (
|
|||
}
|
||||
|
||||
CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
if (CurrentScriptFile == NULL) {
|
||||
ASSERT (CurrentScriptFile != NULL);
|
||||
return (SHELL_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (CurrentScriptFile->Argc < 2) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
|
||||
|
|
Loading…
Reference in New Issue