Check partitions size before erasing to avoid memory corruption

This commit is contained in:
yeggor 2023-03-17 02:10:32 +04:00 committed by Nikolaj Schlej
parent aa3e790fb1
commit 6875968d97
2 changed files with 15 additions and 1 deletions

View File

@ -4220,6 +4220,9 @@ USTATUS FfsParser::parseBpdtRegion(const UByteArray & region, const UINT32 local
}
make_partition_table_consistent:
if (partitions.empty()) {
return U_INVALID_ME_PARTITION_TABLE;
}
// Sort partitions by offset
std::sort(partitions.begin(), partitions.end());
@ -4521,6 +4524,9 @@ USTATUS FfsParser::parseCpdRegion(const UByteArray & region, const UINT32 localO
}
make_partition_table_consistent:
if (partitions.empty()) {
return U_INVALID_ME_PARTITION_TABLE;
}
// Sort partitions by offset
std::sort(partitions.begin(), partitions.end());

View File

@ -223,7 +223,9 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
}
make_partition_table_consistent:
if (partitions.empty()) {
return U_INVALID_ME_PARTITION_TABLE;
}
// Sort partitions by offset
std::sort(partitions.begin(), partitions.end());
@ -384,6 +386,9 @@ USTATUS MeParser::parseIfwi16Region(const UByteArray & region, const UModelIndex
}
make_partition_table_consistent:
if (partitions.empty()) {
return U_INVALID_ME_PARTITION_TABLE;
}
// Sort partitions by offset
std::sort(partitions.begin(), partitions.end());
@ -565,6 +570,9 @@ USTATUS MeParser::parseIfwi17Region(const UByteArray & region, const UModelIndex
}
make_partition_table_consistent:
if (partitions.empty()) {
return U_INVALID_ME_PARTITION_TABLE;
}
// Sort partitions by offset
std::sort(partitions.begin(), partitions.end());