]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Add checking for memory allocation and pointer returns from functions.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 17 Oct 2011 17:49:21 +0000 (17:49 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 17 Oct 2011 17:49:21 +0000 (17:49 +0000)
signed-off-by: jcarsey
reviewed-by: lgrosenb

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12542 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ShellParametersProtocol.c
ShellPkg/Application/Shell/ShellProtocol.c
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 55cf3c279eb74401d6d62ed64b3095094f80a42d..91a0f5f8a294db0626ce6ba23c6cf4535462cb01 100644 (file)
@@ -1040,7 +1040,7 @@ UpdateStdInStdOutStdErr(
             TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);\r
           }\r
           Size = 0;\r
-          if (((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {\r
+          if (TempHandle != NULL || ((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {\r
             Status = EFI_INVALID_PARAMETER;\r
           } else {\r
             ShellParameters->StdIn = TempHandle;\r
index 6b81918101b221f7e3790a1a3dda1c8c076e8454..00bbc358fa3c80fd361e1d07aa52af47cce0f186 100644 (file)
@@ -2249,9 +2249,7 @@ EfiShellFindFiles(
   MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);\r
   if (MapName == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  if (!EFI_ERROR(Status)) {\r
+  } else {\r
     RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy);\r
     if (RootDevicePath == NULL) {\r
       Status = EFI_INVALID_PARAMETER;\r
index b153d2fe452842df0e2412328eb4719cfeee8403..69193d5efa00794811d1b28e6eea6d7de674c69c 100644 (file)
@@ -163,8 +163,8 @@ ShellLevel2CommandsLibDestructor (
   @param[in] Path         The unknown Path Value\r
 \r
   @retval NULL            A memory allocation failed\r
-  @retval NULL            a fully qualified path could not be discovered.\r
-  @retval other           pointer to a fuly qualified path.\r
+  @retval NULL            A fully qualified path could not be discovered.\r
+  @retval other           An allocated pointer to a fuly qualified path.\r
 **/\r
 CHAR16*\r
 EFIAPI\r
@@ -194,6 +194,10 @@ GetFullyQualifiedPath(
 \r
   PathCleanUpDirectories(PathToReturn);\r
 \r
+  if (PathTpReturn == NULL) {\r
+    return NULL;\r
+  }\r
+\r
   while (PathToReturn[StrLen(PathToReturn)-1] == L'*') {\r
     PathToReturn[StrLen(PathToReturn)-1] = CHAR_NULL;\r
   }\r
index 508e9e0ec0dc56e709d14977ee507bd31b1edb65..d131f9b189ea920b1455f43713940cff03c0ffe1 100644 (file)
@@ -2865,9 +2865,10 @@ ShellPrintHiiEx(
 \r
   @param[in] DirName      Path to directory to test.\r
 \r
-  @retval EFI_SUCCESS     The Path represents a directory\r
-  @retval EFI_NOT_FOUND   The Path does not represent a directory\r
-  @return other           The path failed to open\r
+  @retval EFI_SUCCESS             The Path represents a directory\r
+  @retval EFI_NOT_FOUND           The Path does not represent a directory\r
+  @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
+  @return                         The path failed to open\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -2892,6 +2893,10 @@ ShellIsDirectory(
     //\r
     if (gEfiShellProtocol != NULL) {\r
       TempLocation  = StrnCatGrow(&TempLocation, NULL, DirName, 0);\r
+      if (TempLocation == NULL) {\r
+        ShellCloseFile(&Handle);\r
+        return (EFI_OUT_OF_RESOURCES);\r
+      }\r
       TempLocation2 = StrStr(TempLocation, L":");\r
       if (TempLocation2 != NULL && StrLen(StrStr(TempLocation, L":")) == 2) {\r
         *(TempLocation2+1) = CHAR_NULL;\r