Check a mod's table counts against the file before sizing anything by them

A corrupt count was trusted for allocations, so a damaged mod was left out with a vague "bad allocation" or briefly committed gigabytes.
This commit is contained in:
xThrasherrr committed 2026-10-06 10:29:44 -06:00
1 parent be92c9d14c
commit de20b8e1ae
2 files changed
+13 -1

No files matched your search

+2
View File
@@ -167,6 +167,8 @@ BinaryBundle read_binary_bundle(const std::span<const std::byte> data) {
const auto metadataOffset = reader.u32(endian);
const auto metadataSize = reader.u32(endian);
if (strings > data.size()) throw std::out_of_range("Binary bundle string table is out of range");
const auto tables = std::uint64_t{ebxCount} * 28 + std::uint64_t{resourceCount} * 56 + std::uint64_t{chunkCount} * 44; // SHA-1 plus entry bytes
if (tables > reader.remaining()) throw std::out_of_range("Binary bundle asset counts exceed the file");
std::vector<Sha1> hashes(total);
for (auto& hash : hashes) hash = reader.sha1();