diff options
| author | Evgenii Shatokhin <euspectre@gmail.com> | 2025-10-20 10:54:59 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2025-11-22 14:53:36 +0300 |
| commit | e93ee87643a30df3bffede2f4cdadfc7be88f0bd (patch) | |
| tree | 219a0129b764dc33717221e65fe3148f1fabc1aa /BaseTools/Source/Python | |
| parent | 83f41e81fc79c64a11b632e6bedb240a3022db68 (diff) | |
| download | edk2-e93ee87643a30df3bffede2f4cdadfc7be88f0bd.tar.xz | |
BaseTools: FMMT: Fix incorrect size calculation in ModifyTest()
There is another issue in FvHander.py similar to the one fixed by
a60334ad59eb ("BaseTools: Fix FMMT FvHandler Padding operation issue").
For a guided section (ParTree.Data.Type == 0x02), the length of
ParTree.Data.OriData is used to obtain the original size of the data even
after ParTree.Data.OriData has changed, which is incorrect.
This caused the following issue I observed. I built OVMF image for Aarch64
and then tried to add a couple FFS modules to it with 'FMMT -a [...]'. The
resulting image turned out to be invalid: the total size of the image was
less than the size of the firmware volume within it.
UEFITool failed to load such firmware image and complained:
"parseRawArea: one of objects inside overlaps the end of data".
This patch fixes the issue.
Signed-off-by: Evgenii Shatokhin <euspectre@gmail.com>
Diffstat (limited to 'BaseTools/Source/Python')
| -rw-r--r-- | BaseTools/Source/Python/FMMT/core/FvHandler.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py index 12d52c1ac3..6ecbffa245 100644 --- a/BaseTools/Source/Python/FMMT/core/FvHandler.py +++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py @@ -346,7 +346,8 @@ class FvHandler: raise Exception("Process Failed: GuidTool not found!")
# Recompress current data, and recalculate the needed space
CompressedData = guidtool.pack(ParTree.Data.Data)
- Needed_Space = len(CompressedData) - len(ParTree.Data.OriData)
+ Original_Data_Size = len(ParTree.Data.OriData)
+ Needed_Space = len(CompressedData) - Original_Data_Size
ParTree.Data.OriData = CompressedData
New_Size = ParTree.Data.HeaderLength + len(CompressedData)
ParTree.Data.Header.Size[0] = New_Size % (16**2)
@@ -367,12 +368,12 @@ class FvHandler: if Needed_Space < 0:
if ParTree.NextRel:
self.Remain_New_Free_Space = (
- len(ParTree.Data.OriData) + Original_Pad_Size -
+ Original_Data_Size + Original_Pad_Size -
len(CompressedData) - New_Pad_Size
)
else:
self.Remain_New_Free_Space = (
- len(ParTree.Data.OriData) - len(CompressedData)
+ Original_Data_Size - len(CompressedData)
)
# If current section is not guided section
elif Needed_Space:
|
