]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/IntelFrameworkModulePkg FwVol:
authorStar Zeng <star.zeng@intel.com>
Wed, 29 Oct 2014 03:31:46 +0000 (03:31 +0000)
committerlzeng14 <lzeng14@Edk2>
Wed, 29 Oct 2014 03:31:46 +0000 (03:31 +0000)
  Move the check of FV Header signature and file system to
  GetFwVolHeader() to avoid reading the whole unexpected FvHeader.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16255 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVol.c
IntelFrameworkModulePkg/Universal/FirmwareVolume/FwVolDxe/FwVolDriver.h
MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/FwVol/FwVol.c
MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h

index ecee616397c18414535f132a5bdceb1030d5cab6..2ba09c49b58ae2f125a232583ecda887a02588f1 100644 (file)
@@ -4,7 +4,7 @@
   Layers on top of Firmware Block protocol to produce a file abstraction\r
   of FV based files.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -34,6 +34,8 @@
   @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
                                 buffer.\r
   @retval EFI_ACCESS_DENIED     Read status of FV is not enabled.\r
+  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+                                the file system could not be understood.\r
 **/\r
 EFI_STATUS\r
 GetFwVolHeader (\r
@@ -90,6 +92,22 @@ GetFwVolHeader (
                     );\r
   }\r
 \r
+  //\r
+  // Validate FV Header signature, if not as expected, continue.\r
+  //\r
+  if (TempFvh.Signature != EFI_FVH_SIGNATURE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Check to see that the file system is indeed formatted in a way we can\r
+  // understand it...\r
+  //\r
+  if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
+      (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   *FwVolHeader = AllocatePool (TempFvh.HeaderLength);\r
   if (*FwVolHeader == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -669,15 +687,6 @@ FwVolDriverInit (
       continue;\r
     }\r
     ASSERT (FwVolHeader != NULL);\r
-    //\r
-    // Check to see that the file system is indeed formatted in a way we can\r
-    // understand it...\r
-    //\r
-    if ((!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
-        (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
-      FreePool (FwVolHeader);\r
-      continue;\r
-    }\r
     FreePool (FwVolHeader);\r
 \r
     Reinstall = FALSE;\r
index e424f9572da61069affc6dcedf1e9ce7af30e01d..3f637c16eab54758cfd3a4c5bcf720a797aebd01 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common defines and definitions for a FwVolDxe driver.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions\r
@@ -484,6 +484,8 @@ IsValidFFSFile (
   @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
                                 buffer.\r
   @retval EFI_ACCESS_DENIED     Read status of FV is not enabled.\r
+  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+                                the file system could not be understood.\r
 **/\r
 EFI_STATUS\r
 GetFwVolHeader (\r
index f4db06d43e9a3f34aa21e7cbbef3cea613d70992..75542b343298b611acdf04d64c8981759ed51c17 100644 (file)
@@ -2595,6 +2595,8 @@ ReadFvbData (
   @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
   @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
                                 buffer.\r
+  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+                                the file system could not be understood.\r
 \r
 **/\r
 EFI_STATUS\r
index a7b272b4d697518b9a62e7e02ac209d93e61be53..585d2437dc246851ccc401818bf49b61de357a04 100644 (file)
@@ -173,6 +173,8 @@ ReadFvbData (
   @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
   @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
                                 buffer.\r
+  @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
+                                the file system could not be understood.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -199,6 +201,22 @@ GetFwVolHeader (
     return Status;\r
   }\r
 \r
+  //\r
+  // Validate FV Header signature, if not as expected, continue.\r
+  //\r
+  if (TempFvh.Signature != EFI_FVH_SIGNATURE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Check to see that the file system is indeed formatted in a way we can\r
+  // understand it...\r
+  //\r
+  if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
+      (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   // Allocate a buffer for the caller\r
   //\r
@@ -658,29 +676,11 @@ NotifyFwVolBlock (
     }\r
     ASSERT (FwVolHeader != NULL);\r
 \r
-    //\r
-    // Validate FV Header signature, if not as expected, continue.\r
-    //\r
-    if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {\r
-      CoreFreePool (FwVolHeader);\r
-      continue;\r
-    }\r
-\r
     if (!VerifyFvHeaderChecksum (FwVolHeader)) {\r
       CoreFreePool (FwVolHeader);\r
       continue;\r
     }\r
 \r
-\r
-    //\r
-    // Check to see that the file system is indeed formatted in a way we can\r
-    // understand it...\r
-    //\r
-    if ((!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&\r
-        (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {\r
-      continue;\r
-    }\r
-\r
     //\r
     // Check if there is an FV protocol already installed in that handle\r
     //\r
index 514c6ed211ad3108c3a7a7123306733e8102a94d..96cbde37d5696249d63c5ecd8d57b02df476f1d0 100644 (file)
@@ -405,25 +405,4 @@ IsValidFfsFile (
   IN EFI_FFS_FILE_HEADER  *FfsHeader\r
   );\r
 \r
-\r
-/**\r
-  given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
-  copy the volume header into it.\r
-\r
-  @param  Fvb                   The FW_VOL_BLOCK_PROTOCOL instance from which to\r
-                                read the volume header\r
-  @param  FwVolHeader           Pointer to pointer to allocated buffer in which\r
-                                the volume header is returned.\r
-\r
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer could be allocated.\r
-  @retval EFI_SUCCESS           Successfully read volume header to the allocated\r
-                                buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-GetFwVolHeader (\r
-  IN     EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *Fvb,\r
-  OUT    EFI_FIRMWARE_VOLUME_HEADER             **FwVolHeader\r
-  );\r
-\r
 #endif\r