Core: Enforce max mVL block size

This commit is contained in:
Vicki Pfau 2017-04-24 14:01:14 -07:00
parent 909886d2e1
commit 6a14c30e3b
1 changed files with 7 additions and 0 deletions

View File

@ -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;
} }