summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r--ShellPkg/Application/Shell/Shell.c8
-rw-r--r--ShellPkg/Application/Shell/ShellEnvVar.c30
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c6
3 files changed, 27 insertions, 17 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 483fe4d..ae3e943 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1262,9 +1262,11 @@ LocateStartupScript (
InternalEfiShellSetEnv (L"homefilesystem", StartupScriptPath, TRUE);
- StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, ((FILEPATH_DEVICE_PATH *)FileDevicePath)->PathName, 0);
- PathRemoveLastItem (StartupScriptPath);
- StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, mStartupScript, 0);
+ if ((DevicePathType (FileDevicePath) == MEDIA_DEVICE_PATH) && (DevicePathSubType (FileDevicePath) == MEDIA_FILEPATH_DP)) {
+ StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, ((FILEPATH_DEVICE_PATH *)FileDevicePath)->PathName, 0);
+ PathRemoveLastItem (StartupScriptPath);
+ StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, mStartupScript, 0);
+ }
}
//
diff --git a/ShellPkg/Application/Shell/ShellEnvVar.c b/ShellPkg/Application/Shell/ShellEnvVar.c
index b97cfe9..9e84d7f 100644
--- a/ShellPkg/Application/Shell/ShellEnvVar.c
+++ b/ShellPkg/Application/Shell/ShellEnvVar.c
@@ -285,19 +285,23 @@ SetEnvironmentVariableList (
//
// set all the variables from the list
//
- for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
- ; !IsNull (ListHead, &Node->Link)
- ; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
- )
- {
- Size = StrSize (Node->Val) - sizeof (CHAR16);
- if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
- Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
- } else {
- Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
- }
+ if ((ListHead != NULL) && !IsListEmpty (ListHead)) {
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
+ ; !IsNull (ListHead, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
+ )
+ {
+ if ((Node->Key != NULL) && (Node->Val != NULL)) {
+ Size = StrSize (Node->Val) - sizeof (CHAR16);
+ if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
+ } else {
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
+ }
- ASSERT_EFI_ERROR (Status);
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
}
FreeEnvironmentVariableList (ListHead);
@@ -441,7 +445,7 @@ ShellFindEnvVarInList (
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
)
{
- if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
+ if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0) && (Node->Val != NULL)) {
*Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
*ValueSize = StrSize (Node->Val);
if (Atts != NULL) {
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 3bc6239..646294d 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -2853,7 +2853,11 @@ EfiShellGetEnvEx (
; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
)
{
- ASSERT (Node->Key != NULL);
+ if (Node->Key == NULL) {
+ ASSERT (FALSE);
+ continue;
+ }
+
Size += StrSize (Node->Key);
}