mirror of https://github.com/mgba-emu/mgba.git
Core: Enforce max mVL block size
This commit is contained in:
parent
909886d2e1
commit
6a14c30e3b
|
@ -22,6 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFFER_BASE_SIZE 0x20000
|
#define BUFFER_BASE_SIZE 0x20000
|
||||||
|
#define MAX_BLOCK_SIZE 0x800000
|
||||||
|
|
||||||
const char mVL_MAGIC[] = "mVL\0";
|
const char mVL_MAGIC[] = "mVL\0";
|
||||||
|
|
||||||
|
@ -530,6 +531,12 @@ bool _readBlockHeader(struct mVideoLogContext* context, struct mVLBlockHeader* h
|
||||||
LOAD_32LE(header->length, 0, &buffer.length);
|
LOAD_32LE(header->length, 0, &buffer.length);
|
||||||
LOAD_32LE(header->channelId, 0, &buffer.channelId);
|
LOAD_32LE(header->channelId, 0, &buffer.channelId);
|
||||||
LOAD_32LE(header->flags, 0, &buffer.flags);
|
LOAD_32LE(header->flags, 0, &buffer.flags);
|
||||||
|
|
||||||
|
if (header->length > MAX_BLOCK_SIZE) {
|
||||||
|
// Pre-emptively reject blocks that are too big.
|
||||||
|
// If we encounter one, the file is probably corrupted.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue