Merge "fix(guid-partition): fix MBR header load" into integration

This commit is contained in:
Yann Gautier 2025-04-13 21:09:08 +02:00 committed by TrustedFirmware Code Review
commit 4d913df8f8

View file

@ -75,11 +75,6 @@ static int load_mbr_header(uintptr_t image_handle, mbr_entry_t *mbr_entry)
memcpy(&tmp, mbr_sector + MBR_PRIMARY_ENTRY_OFFSET, sizeof(tmp)); memcpy(&tmp, mbr_sector + MBR_PRIMARY_ENTRY_OFFSET, sizeof(tmp));
if (tmp.first_lba != 1) {
VERBOSE("MBR header may have an invalid first LBA\n");
return -EINVAL;
}
if ((tmp.sector_nums == 0) || (tmp.sector_nums == UINT32_MAX)) { if ((tmp.sector_nums == 0) || (tmp.sector_nums == UINT32_MAX)) {
VERBOSE("MBR header entry has an invalid number of sectors\n"); VERBOSE("MBR header entry has an invalid number of sectors\n");
return -EINVAL; return -EINVAL;
@ -421,6 +416,11 @@ int load_partition_table(unsigned int image_id)
goto out; goto out;
} }
if (mbr_entry.type == PARTITION_TYPE_GPT) { if (mbr_entry.type == PARTITION_TYPE_GPT) {
if (mbr_entry.first_lba != 1U) {
VERBOSE("MBR header may have an invalid first LBA\n");
return -EINVAL;
}
result = load_primary_gpt(image_handle, mbr_entry.first_lba); result = load_primary_gpt(image_handle, mbr_entry.first_lba);
if (result != 0) { if (result != 0) {
io_close(image_handle); io_close(image_handle);