mirror of
https://github.com/mhx/dwarfs.git
synced 2025-08-03 09:47:01 -04:00
fix(filesystem_parser): more section index discovery checks (gh #264)
This commit is contained in:
parent
661b951cfd
commit
abe06c6f5a
@ -263,18 +263,22 @@ void filesystem_parser::find_index() {
|
||||
|
||||
auto section = fs_section(*mm_, index_pos, version_);
|
||||
|
||||
if (!section.check_fast(*mm_)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (section.type() != section_type::SECTION_INDEX) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (section.compression() != compression_type::NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (section.length() % sizeof(uint64_t) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!section.check_fast(*mm_)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto const section_count = section.length() / sizeof(uint64_t);
|
||||
|
||||
// at least METADATA_V2_SCHEMA, METADATA_V2, and SECTION_INDEX
|
||||
@ -298,6 +302,12 @@ void filesystem_parser::find_index() {
|
||||
})) {
|
||||
// remove the index again if it is not sorted
|
||||
index_.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((index_.at(0) & section_offset_mask) != 0) {
|
||||
index_.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user