]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/DxeServicesLib: Return NULL GetFileBufferByFilePath reads directory
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 18 Jun 2015 02:21:57 +0000 (02:21 +0000)
committerniruiyu <niruiyu@Edk2>
Thu, 18 Jun 2015 02:21:57 +0000 (02:21 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17655 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/DxeServicesLib/DxeServicesLib.c

index ef7c9ba9b288f393093d593ce13404bc4e05ce27..c8f0014d7a61c1408803189252ff7a747f3600bf 100644 (file)
@@ -2,7 +2,7 @@
   MDE DXE Services Library provides functions that simplify the development of DXE Drivers.  \r
   These functions help access data from sections of FFS files or from file path.\r
 \r
   MDE DXE Services Library provides functions that simplify the development of DXE Drivers.  \r
   These functions help access data from sections of FFS files or from file path.\r
 \r
-  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2015, 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
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -796,18 +796,20 @@ GetFileBufferByFilePath (
           }\r
           \r
           if (!EFI_ERROR (Status) && (FileInfo != NULL)) {\r
           }\r
           \r
           if (!EFI_ERROR (Status) && (FileInfo != NULL)) {\r
-            //\r
-            // Allocate space for the file\r
-            //\r
-            ImageBuffer = AllocatePool ((UINTN)FileInfo->FileSize);\r
-            if (ImageBuffer == NULL) {\r
-              Status = EFI_OUT_OF_RESOURCES;\r
-            } else {\r
+            if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == 0) {\r
               //\r
               //\r
-              // Read the file into the buffer we allocated\r
+              // Allocate space for the file\r
               //\r
               //\r
-              ImageBufferSize = (UINTN)FileInfo->FileSize;\r
-              Status          = FileHandle->Read (FileHandle, &ImageBufferSize, ImageBuffer);\r
+              ImageBuffer = AllocatePool ((UINTN)FileInfo->FileSize);\r
+              if (ImageBuffer == NULL) {\r
+                Status = EFI_OUT_OF_RESOURCES;\r
+              } else {\r
+                //\r
+                // Read the file into the buffer we allocated\r
+                //\r
+                ImageBufferSize = (UINTN)FileInfo->FileSize;\r
+                Status          = FileHandle->Read (FileHandle, &ImageBufferSize, ImageBuffer);\r
+              }\r
             }\r
           }\r
         }\r
             }\r
           }\r
         }\r