diff options
4 files changed, 59 insertions, 33 deletions
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);
}
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index b0c77e4..44c2ed9 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -398,7 +398,11 @@ ShellCommandIsCommandOnInternalList ( ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
)
{
- ASSERT (Node->CommandString != NULL);
+ if (Node->CommandString == NULL) {
+ ASSERT (FALSE);
+ continue;
+ }
+
if (gUnicodeCollation->StriColl (
gUnicodeCollation,
(CHAR16 *)CommandString,
@@ -485,7 +489,11 @@ ShellCommandGetInternalCommandHelp ( ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
)
{
- ASSERT (Node->CommandString != NULL);
+ if (Node->CommandString == NULL) {
+ ASSERT (FALSE);
+ continue;
+ }
+
if (gUnicodeCollation->StriColl (
gUnicodeCollation,
(CHAR16 *)CommandString,
@@ -672,23 +680,25 @@ ShellCommandRegisterCommandName ( //
// Get Lexical Comparison Value between PrevCommand and Command list entry
//
- LexicalMatchValue = gUnicodeCollation->StriColl (
- gUnicodeCollation,
- PrevCommand->CommandString,
- Command->CommandString
- );
+ if ((PrevCommand->CommandString != NULL) && (Command->CommandString != NULL)) {
+ LexicalMatchValue = gUnicodeCollation->StriColl (
+ gUnicodeCollation,
+ PrevCommand->CommandString,
+ Command->CommandString
+ );
- //
- // Swap PrevCommand and Command list entry if PrevCommand list entry
- // is alphabetically greater than Command list entry
- //
- if (LexicalMatchValue > 0) {
- Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)SwapListEntries (&PrevCommand->Link, &Command->Link);
- } else if (LexicalMatchValue < 0) {
//
- // PrevCommand entry is lexically lower than Command entry
+ // Swap PrevCommand and Command list entry if PrevCommand list entry
+ // is alphabetically greater than Command list entry
//
- break;
+ if (LexicalMatchValue > 0) {
+ Command = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)SwapListEntries (&PrevCommand->Link, &Command->Link);
+ } else if (LexicalMatchValue < 0) {
+ //
+ // PrevCommand entry is lexically lower than Command entry
+ //
+ break;
+ }
}
}
@@ -758,7 +768,11 @@ ShellCommandRunCommandHandler ( ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
)
{
- ASSERT (Node->CommandString != NULL);
+ if (Node->CommandString == NULL) {
+ ASSERT (FALSE);
+ continue;
+ }
+
if (gUnicodeCollation->StriColl (
gUnicodeCollation,
(CHAR16 *)CommandString,
@@ -831,7 +845,11 @@ ShellCommandGetManFileNameHandler ( ; Node = (SHELL_COMMAND_INTERNAL_LIST_ENTRY *)GetNextNode (&mCommandList.Link, &Node->Link)
)
{
- ASSERT (Node->CommandString != NULL);
+ if (Node->CommandString == NULL) {
+ ASSERT (FALSE);
+ continue;
+ }
+
if (gUnicodeCollation->StriColl (
gUnicodeCollation,
(CHAR16 *)CommandString,
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c index 42d766e..bf68eb1 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c @@ -3011,7 +3011,7 @@ DisplayMmBankConnections ( //
// Divide it to high and low
//
- High = (UINT8)(BankConnections & 0xF0);
+ High = (UINT8)((BankConnections & 0xF0)>>4);
Low = (UINT8)(BankConnections & 0x0F);
if (High != 0xF) {
if (Low != 0xF) {
|