mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-24 08:58:23 +08:00
Fix a possible crash of MeParser in case there are no valid FPT partition table entries
This commit is contained in:
parent
a4a455d0ff
commit
011647aa30
@ -431,6 +431,12 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regions can not be empty here
|
||||||
|
if (regions.empty()) {
|
||||||
|
msg(usprintf("%s: descriptor parsing failed, no regions found", __FUNCTION__));
|
||||||
|
return U_INVALID_FLASH_DESCRIPTOR;
|
||||||
|
}
|
||||||
|
|
||||||
// Sort regions in ascending order
|
// Sort regions in ascending order
|
||||||
std::sort(regions.begin(), regions.end());
|
std::sort(regions.begin(), regions.end());
|
||||||
|
|
||||||
@ -4057,18 +4063,14 @@ USTATUS FfsParser::parseBpdtRegion(const UByteArray & region, const UINT32 local
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add padding if there's no partions to add
|
// Check for empty set of partitions
|
||||||
if (partitions.size() == 0) {
|
if (partitions.empty()) {
|
||||||
UByteArray partition = region.mid(ptSize);
|
// Add a single padding partition in this case
|
||||||
|
BPDT_PARTITION_INFO padding = {};
|
||||||
// Get info
|
padding.ptEntry.Offset = offset;
|
||||||
name = UString("Padding");
|
padding.ptEntry.Size = (UINT32)(region.size() - padding.ptEntry.Offset);
|
||||||
info = usprintf("Full size: %Xh (%u)",
|
padding.type = Types::Padding;
|
||||||
(UINT32)partition.size(), (UINT32)partition.size());
|
partitions.push_back(padding);
|
||||||
|
|
||||||
// Add tree item
|
|
||||||
model->addItem(localOffset + ptSize, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
make_partition_table_consistent:
|
make_partition_table_consistent:
|
||||||
|
@ -212,8 +212,18 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
|
|||||||
partitions.push_back(partition);
|
partitions.push_back(partition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check for empty set of partitions
|
||||||
|
if (partitions.empty()) {
|
||||||
|
// Add a single padding partition in this case
|
||||||
|
FPT_PARTITION_INFO padding = {};
|
||||||
|
padding.ptEntry.Offset = offset;
|
||||||
|
padding.ptEntry.Size = (UINT32)(region.size() - padding.ptEntry.Offset);
|
||||||
|
padding.type = Types::Padding;
|
||||||
|
partitions.push_back(padding);
|
||||||
|
}
|
||||||
|
|
||||||
make_partition_table_consistent:
|
make_partition_table_consistent:
|
||||||
|
|
||||||
// Sort partitions by offset
|
// Sort partitions by offset
|
||||||
std::sort(partitions.begin(), partitions.end());
|
std::sort(partitions.begin(), partitions.end());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user