From 931aae946fd301cc0b49a60edcde7680d5ceaf45 Mon Sep 17 00:00:00 2001 From: Dong Guo Date: Wed, 31 Dec 2014 01:47:39 +0000 Subject: [PATCH] Remove the FV header assumption in variable driver. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dong Guo Reviewed-by: Gao Liming Reviewed-by: Zeng Star git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16565 6f19259b-4bc3-4df7-8a09-765794883524 --- .../VariableAuthenticated/RuntimeDxe/Variable.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c index ac043d9a17..04b992d5bf 100644 --- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c +++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c @@ -3883,8 +3883,9 @@ GetFvbInfoByAddress ( UINTN Index; EFI_PHYSICAL_ADDRESS FvbBaseAddress; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb; - EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; EFI_FVB_ATTRIBUTES_2 Attributes; + UINTN BlockSize; + UINTN NumberOfBlocks; HandleBuffer = NULL; // @@ -3922,8 +3923,15 @@ GetFvbInfoByAddress ( continue; } - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress); - if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + FwVolHeader->FvLength))) { + // + // Assume one FVB has one type of BlockSize. + // + Status = Fvb->GetBlockSize (Fvb, 0, &BlockSize, &NumberOfBlocks); + if (EFI_ERROR (Status)) { + continue; + } + + if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + BlockSize * NumberOfBlocks))) { if (FvbHandle != NULL) { *FvbHandle = HandleBuffer[Index]; } -- 2.39.2