I agree this change. Reviewed-by: Liming Gao <liming....@intel.com>

-----Original Message-----
From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org] 
Sent: Monday, August 17, 2015 10:25 PM
To: edk2-devel@lists.01.org; Liu, Yingke D
Cc: Gao, Liming; Justen, Jordan L; wp...@windriver.com; sc...@notabs.org; 
dw...@infradead.org; Ard Biesheuvel
Subject: [PATCH v2 02/16] BaseTools/GenFv: use PE/COFF virtual section size if 
raw size is larger

When copying the relocated sections into the FFS file, we need to take care 
that we don't overrun the end of the file. Since, unlike the virtual size, the 
PE/COFF raw section size must be a multiple of the file alignment, which means 
its size may exceed the virtual size.
So use the minimum of the two.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 6d2d5d1f8c67..b0135bf0155a 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -3329,7 +3329,7 @@ Returns:
       CopyMem (
         (UINT8 *) CurrentPe32Section.Pe32Section + CurSecHdrSize + 
SectionHeader->PointerToRawData, 
         (VOID*) (UINTN) (ImageContext.ImageAddress + 
SectionHeader->VirtualAddress), 
-        SectionHeader->SizeOfRawData
+        MIN(SectionHeader->SizeOfRawData, 
+ SectionHeader->Misc.VirtualSize)
         );
     }
 
--
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to