Skip to content

Commit

Permalink
limit number of unknown chunks in bnk
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Dec 7, 2024
1 parent c87728d commit 89896c4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/fileTypeUtils/audio/bnkIO.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class BnkFile extends ChunkWithSize {
BnkFile(this.chunks);

BnkFile.read(ByteDataWrapper bytes) {
int unknownChunkCount = 0;
while (bytes.position < bytes.length) {
var chunk = _makeNextChunk(bytes);
if (chunk is BnkHeader) {
Expand All @@ -45,6 +46,13 @@ class BnkFile extends ChunkWithSize {
throw Exception("Unsupported BNK version ${chunk.version}");
}
}
else if (chunk is BnkUnknownChunk) {
unknownChunkCount++;
if (unknownChunkCount > 10) {
showToast("Warning: More than 10 unknown chunks found. Stopping parsing.");
throw Exception("Too many unknown chunks");
}
}
chunks.add(chunk);
}
}
Expand Down

0 comments on commit 89896c4

Please sign in to comment.