]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
ShellPkg/Dp: Add null pointer check
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / UefiShellLevel1CommandsLib.c
index bae834f1646fa0639a0683dfad6961410c86739b..2b8a104da323e01308029e2f6fc0dd162281bda3 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Main file for NULL named library for level 1 shell command functions.\r
 \r
+  (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
 STATIC CONST CHAR16 mFileName[] = L"ShellCommands";\r
 EFI_HANDLE gShellLevel1HiiHandle = NULL;\r
-CONST EFI_GUID gShellLevel1HiiGuid = \\r
-  { \\r
-    0xdec5daa4, 0x6781, 0x4820, { 0x9c, 0x63, 0xa7, 0xb0, 0xe4, 0xf1, 0xdb, 0x31 }\r
-  };\r
-\r
 \r
 /**\r
   Return the help text filename.  Only used if no HII information found.\r
@@ -58,7 +54,7 @@ ShellLevel1CommandsLibConstructor (
   // if shell level is less than 2 do nothing\r
   //\r
   if (PcdGet8(PcdShellSupportLevel) < 1) {\r
-    return (EFI_UNSUPPORTED);\r
+    return (EFI_SUCCESS);\r
   }\r
 \r
   gShellLevel1HiiHandle = HiiAddPackages (&gShellLevel1HiiGuid, gImageHandle, UefiShellLevel1CommandsLibStrings, NULL);\r
@@ -112,20 +108,19 @@ ShellLevel1CommandsLibDestructor (
 \r
   If label is used it will be used instead of the count.\r
 \r
-  @param[in] Function         The function to use to enumerate through the \r
-                              list.  Normally GetNextNode or GetPreviousNode.\r
-  @param[in] DecrementerTag   The tag to decrement the count at.\r
-  @param[in] IncrementerTag   The tag to increment the count at.\r
-  @param[in] Label            A label to look for.\r
-  @param[in,out] ScriptFile   The pointer to the current script file structure.\r
-  @param[in] MovePast         TRUE makes function return 1 past the found \r
-                              location.\r
-  @param[in] FindOnly         TRUE to not change the ScriptFile.\r
-  @param[in] CommandNode      The pointer to the Node to test.\r
-  @param[in,out] TargetCount  The pointer to the current count.\r
+  @param[in] Function          The function to use to enumerate through the \r
+                               list.  Normally GetNextNode or GetPreviousNode.\r
+  @param[in] DecrementerTag    The tag to decrement the count at.\r
+  @param[in] IncrementerTag    The tag to increment the count at.\r
+  @param[in] Label             A label to look for.\r
+  @param[in, out] ScriptFile   The pointer to the current script file structure.\r
+  @param[in] MovePast          TRUE makes function return 1 past the found \r
+                               location.\r
+  @param[in] FindOnly          TRUE to not change the ScriptFile.\r
+  @param[in] CommandNode       The pointer to the Node to test.\r
+  @param[in, out] TargetCount  The pointer to the current count.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 TestNodeForMove (\r
   IN CONST LIST_MANIP_FUNC      Function,\r
   IN CONST CHAR16               *DecrementerTag,\r
@@ -150,8 +145,16 @@ TestNodeForMove (
   //\r
   CommandName   = NULL;\r
   CommandName   = StrnCatGrow(&CommandName, NULL, CommandNode->Cl, 0);\r
+  if (CommandName == NULL) {\r
+    return (FALSE);\r
+  }\r
+\r
   CommandNameWalker = CommandName;\r
-  while(CommandNameWalker[0] == L' ') {\r
+\r
+  //\r
+  // Skip leading spaces and tabs.\r
+  //\r
+  while ((CommandNameWalker[0] == L' ') || (CommandNameWalker[0] == L'\t')) {\r
     CommandNameWalker++;\r
   }\r
   TempLocation  = StrStr(CommandNameWalker, L" ");\r
@@ -229,20 +232,19 @@ TestNodeForMove (
 \r
   If label is used it will be used instead of the count.\r
 \r
-  @param[in] Function         The function to use to enumerate through the \r
-                              list.  Normally GetNextNode or GetPreviousNode.\r
-  @param[in] DecrementerTag   The tag to decrement the count at.\r
-  @param[in] IncrementerTag   The tag to increment the count at.\r
-  @param[in] Label            A label to look for.\r
-  @param[in,out] ScriptFile   The pointer to the current script file structure.\r
-  @param[in] MovePast         TRUE makes function return 1 past the found \r
-                              location.\r
-  @param[in] FindOnly         TRUE to not change the ScriptFile.\r
-  @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in \r
-                              searching.\r
+  @param[in] Function          The function to use to enumerate through the \r
+                               list.  Normally GetNextNode or GetPreviousNode.\r
+  @param[in] DecrementerTag    The tag to decrement the count at.\r
+  @param[in] IncrementerTag    The tag to increment the count at.\r
+  @param[in] Label             A label to look for.\r
+  @param[in, out] ScriptFile   The pointer to the current script file structure.\r
+  @param[in] MovePast          TRUE makes function return 1 past the found \r
+                               location.\r
+  @param[in] FindOnly          TRUE to not change the ScriptFile.\r
+  @param[in] WrapAroundScript  TRUE to wrap end-to-begining or vise versa in \r
+                               searching.\r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 MoveToTag (\r
   IN CONST LIST_MANIP_FUNC      Function,\r
   IN CONST CHAR16               *DecrementerTag,\r