StandaloneMmPkg: Fix section data length returned larger than actual data
This change fixes an issue where the returned section data length is always 4 bytes larger than the actual section length. This could cause an issue where the caller accesses the final 4 bytes which would be invalid. Co-authored-by: Kun Qin <kuqin@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
parent
bef0d333dc
commit
051c7bb434
|
@ -87,7 +87,7 @@ FindFfsSectionInSections (
|
||||||
@param FfsFileHeader Pointer to the current file to search.
|
@param FfsFileHeader Pointer to the current file to search.
|
||||||
@param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
|
@param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
|
||||||
NULL if section not found
|
NULL if section not found
|
||||||
@param SectionDataSize The size of SectionData
|
@param SectionDataSize The size of SectionData, excluding the section header.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND No files matching the search criteria were found
|
@retval EFI_NOT_FOUND No files matching the search criteria were found
|
||||||
@retval EFI_SUCCESS
|
@retval EFI_SUCCESS
|
||||||
|
|
|
@ -338,11 +338,11 @@ FfsFindSection (
|
||||||
Given the input file pointer, search for the next matching section in the
|
Given the input file pointer, search for the next matching section in the
|
||||||
FFS volume.
|
FFS volume.
|
||||||
|
|
||||||
@param SearchType Filter to find only sections of this type.
|
@param[in] SectionType Filter to find only sections of this type.
|
||||||
@param FfsFileHeader Pointer to the current file to search.
|
@param[in] FfsFileHeader Pointer to the current file to search.
|
||||||
@param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
|
@param[in,out] SectionData Pointer to the Section matching SectionType in FfsFileHeader.
|
||||||
NULL if section not found
|
NULL if section not found
|
||||||
@param SectionDataSize The size of SectionData
|
@param[in,out] SectionDataSize The size of SectionData, excluding the section header.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND No files matching the search criteria were found
|
@retval EFI_NOT_FOUND No files matching the search criteria were found
|
||||||
@retval EFI_SUCCESS
|
@retval EFI_SUCCESS
|
||||||
|
@ -380,10 +380,10 @@ FfsFindSectionData (
|
||||||
if (Section->Type == SectionType) {
|
if (Section->Type == SectionType) {
|
||||||
if (IS_SECTION2 (Section)) {
|
if (IS_SECTION2 (Section)) {
|
||||||
*SectionData = (VOID *)((EFI_COMMON_SECTION_HEADER2 *)Section + 1);
|
*SectionData = (VOID *)((EFI_COMMON_SECTION_HEADER2 *)Section + 1);
|
||||||
*SectionDataSize = SECTION2_SIZE (Section);
|
*SectionDataSize = SECTION2_SIZE (Section) - sizeof (EFI_COMMON_SECTION_HEADER2);
|
||||||
} else {
|
} else {
|
||||||
*SectionData = (VOID *)(Section + 1);
|
*SectionData = (VOID *)(Section + 1);
|
||||||
*SectionDataSize = SECTION_SIZE (Section);
|
*SectionDataSize = SECTION_SIZE (Section) - sizeof (EFI_COMMON_SECTION_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue