summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2014-10-29 03:31:46 +0000
committerlzeng14 <lzeng14@Edk2>2014-10-29 03:31:46 +0000
commit4888d15e74628fd373605d5d853fa3b172aeadc3 (patch)
treed6ffe877cba7ccbcacc018f6e6c358885fc7683d /MdeModulePkg/Core/Dxe/FwVol/FwVol.c
parent24903bc48a324d42b284805ede9c5ee1db906e44 (diff)
downloadedk2-4888d15e74628fd373605d5d853fa3b172aeadc3.zip
edk2-4888d15e74628fd373605d5d853fa3b172aeadc3.tar.gz
edk2-4888d15e74628fd373605d5d853fa3b172aeadc3.tar.bz2
MdeModulePkg/IntelFrameworkModulePkg FwVol:
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
Diffstat (limited to 'MdeModulePkg/Core/Dxe/FwVol/FwVol.c')
-rw-r--r--MdeModulePkg/Core/Dxe/FwVol/FwVol.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
index a7b272b..585d243 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
@@ -173,6 +173,8 @@ ReadFvbData (
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS Successfully read volume header to the allocated
buffer.
+ @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or
+ the file system could not be understood.
**/
EFI_STATUS
@@ -200,6 +202,22 @@ GetFwVolHeader (
}
//
+ // Validate FV Header signature, if not as expected, continue.
+ //
+ if (TempFvh.Signature != EFI_FVH_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check to see that the file system is indeed formatted in a way we can
+ // understand it...
+ //
+ if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&
+ (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
// Allocate a buffer for the caller
//
*FwVolHeader = AllocatePool (TempFvh.HeaderLength);
@@ -658,29 +676,11 @@ NotifyFwVolBlock (
}
ASSERT (FwVolHeader != NULL);
- //
- // Validate FV Header signature, if not as expected, continue.
- //
- if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {
- CoreFreePool (FwVolHeader);
- continue;
- }
-
if (!VerifyFvHeaderChecksum (FwVolHeader)) {
CoreFreePool (FwVolHeader);
continue;
}
-
- //
- // Check to see that the file system is indeed formatted in a way we can
- // understand it...
- //
- if ((!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&
- (!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {
- continue;
- }
-
//
// Check if there is an FV protocol already installed in that handle
//