diff --git a/src/reader/internal/filesystem_parser.cpp b/src/reader/internal/filesystem_parser.cpp index 70b81ab1..6d54a3f8 100644 --- a/src/reader/internal/filesystem_parser.cpp +++ b/src/reader/internal/filesystem_parser.cpp @@ -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; } }