boot: impose section limit when loading PE from memory too
pe_section_table_from_file already checks with SECTION_TABLE_BYTES_MAX,
do the same in pe_section_table_from_base() just in case.
Originally reported on yeswehack.com as:
YWH-PGM9780-117
Follow-up for f4e081051d
This commit is contained in:
+7
-1
@@ -570,8 +570,14 @@ EFI_STATUS pe_section_table_from_base(
|
||||
if (!verify_pe(dos, pe, /* allow_compatibility= */ false))
|
||||
return EFI_LOAD_ERROR;
|
||||
|
||||
assert_cc(sizeof(pe->FileHeader.NumberOfSections) == sizeof(uint16_t)); /* multiplication below cannot overflow */
|
||||
|
||||
size_t n_section_table = pe->FileHeader.NumberOfSections;
|
||||
if (n_section_table * sizeof(PeSectionHeader) > SECTION_TABLE_BYTES_MAX)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
*ret_section_table = (const PeSectionHeader*) ((const uint8_t*) base + section_table_offset(dos, pe));
|
||||
*ret_n_section_table = pe->FileHeader.NumberOfSections;
|
||||
*ret_n_section_table = n_section_table;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user