summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLevel1CommandsLib
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-03-30 19:33:03 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-03-30 19:33:03 +0000
commit33c031ee2092282a069ce07d30202082ceaf61fe (patch)
treeaf76c06a5c4f476e9dfe23096ff2bc0295beaee1 /ShellPkg/Library/UefiShellLevel1CommandsLib
parent6b825919f1c16b07b5cac7fc5e298fbeb530d888 (diff)
downloadedk2-platforms-33c031ee2092282a069ce07d30202082ceaf61fe.tar.xz
pointer verification (not NULL) and buffer overrun fixes.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11459 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellLevel1CommandsLib')
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c23
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c12
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c60
3 files changed, 87 insertions, 8 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index 006ce6c675..ddcfd45de3 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -86,7 +86,17 @@ ShellCommandRunEndFor (
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
if (!Found) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"For", L"EndFor", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"For",
+ L"EndFor",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_NOT_FOUND);
}
return (SHELL_SUCCESS);
@@ -305,7 +315,16 @@ ShellCommandRunFor (
// Make sure that an End exists.
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndFor",
+ L"For",
+ CurrentScriptFile->CurrentCommand!=NULL
+ ?CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
index 8213fae7ac..3e5a59c575 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
@@ -79,7 +79,17 @@ ShellCommandRunGoto (
// Check forwards and then backwards for a label...
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, CompareString, L"Goto", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ CompareString,
+ L"Goto",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
ShellStatus = SHELL_NOT_FOUND;
}
FreePool(CompareString);
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index 59069e568f..a3c4482bb3 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -844,7 +844,17 @@ ShellCommandRunIf (
// Make sure that an End exists.
//
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EnfIf", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EnfIf",
+ L"If",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -983,16 +993,46 @@ ShellCommandRunElse (
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"If",
+ L"Else",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"If",
+ L"Else",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndIf", "Else", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndIf",
+ "Else",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -1025,7 +1065,17 @@ ShellCommandRunEndIf (
}
if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"If", L"EndIf", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"If",
+ L"EndIf",
+ ShellCommandGetCurrentScriptFile()!=NULL
+ &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
+ ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}