mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdePkg/FvLib: Need section alignment for FindFfsSectionInSections
In FvLib library, FindFsSectionInSection function may not find the ffs section where the second (or later) is located. It is due to a wrong section address that does not consider section alignment. Support the alignment to check multiple ffs sections correctly. Signed-off-by: Phil Noh <Phil.Noh@amd.com>
This commit is contained in:
parent
454e1fc40f
commit
f82d1fa48e
1 changed files with 10 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
|
||||
Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
|
|
@ -253,14 +254,18 @@ FindFfsSectionInSections (
|
|||
//
|
||||
// Loop through the FFS file sections
|
||||
//
|
||||
EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
|
||||
EndOfSections = EndOfSection + SizeOfSections;
|
||||
EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
|
||||
EndOfSections = EndOfSection + SizeOfSections;
|
||||
CurrentAddress = EndOfSection;
|
||||
|
||||
for ( ; ;) {
|
||||
if (EndOfSection == EndOfSections) {
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentAddress = EndOfSection;
|
||||
if (CurrentAddress >= EndOfSections) {
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
|
||||
|
||||
|
|
@ -274,7 +279,8 @@ FindFfsSectionInSections (
|
|||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
|
||||
Size = GET_OCCUPIED_SIZE (Size, 4);
|
||||
Size = GET_OCCUPIED_SIZE (Size, 4);
|
||||
CurrentAddress = CurrentAddress + Size;
|
||||
|
||||
//
|
||||
// Look for the requested section type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue