diff options
author | Janne Grunau <janne-libav@jannau.net> | 2012-11-26 22:18:31 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2012-12-07 11:43:28 +0100 |
commit | 8cc2fa1e5db0655c053b35c948ef05ba0fe13707 (patch) | |
tree | 0d941674dc103cf342a49ec58185a95d51237a4d /libavformat | |
parent | 80b6b31417c6791f9d4f1bc8c3c2a726d71e45e0 (diff) | |
download | ffmpeg-8cc2fa1e5db0655c053b35c948ef05ba0fe13707.tar.gz |
mov: validate number of DataReferenceBox entries against box size
Avoids a 2G memory allocation and parsing of random data in
mov_read_dref(). The fuzzed sample sample.mp4_s224424 triggers this.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mov.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index a0ede86882..8503a7ebdd 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -351,6 +351,7 @@ static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +#define MIN_DATA_ENTRY_BOX_SIZE 12 static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -364,7 +365,8 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_rb32(pb); // version + flags entries = avio_rb32(pb); - if (entries >= UINT_MAX / sizeof(*sc->drefs)) + if (entries > (atom.size - 1) / MIN_DATA_ENTRY_BOX_SIZE + 1 || + entries >= UINT_MAX / sizeof(*sc->drefs)) return AVERROR_INVALIDDATA; av_free(sc->drefs); sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); |