mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-19 16:55:21 +02:00
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:
1 parent
be92c9d14c
commit
de20b8e1ae
2 files changed
+13
-1
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user