summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLevel1CommandsLib
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Library/UefiShellLevel1CommandsLib')
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c11
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c5
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c17
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c5
4 files changed, 35 insertions, 3 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index 8a6a940..9cd45c2 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -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,12 @@ ShellCommandRunFor (
}
TempString = AllocateZeroPool (50*sizeof (CHAR16));
+ if (TempString == NULL) {
+ SHELL_FREE_NON_NULL (ArgSet);
+ SHELL_FREE_NON_NULL (Info);
+ return (SHELL_OUT_OF_RESOURCES);
+ }
+
UnicodeSPrint (TempString, 50*sizeof (CHAR16), L"%d", Info->Current);
InternalUpdateAliasOnList (Info->ReplacementName, TempString, &CurrentScriptFile->SubstList);
FreePool (TempString);
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
index c0b9a01..1773f6a 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
@@ -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...
//
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index b4a6966..f1953a7 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -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,
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
index 4c0debe..d550682 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Shift.c
@@ -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");