avformat/vividas: Check buffer size before allocation
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 13 Jul 2019 17:57:21 +0000 (19:57 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 3 Aug 2019 15:44:23 +0000 (17:44 +0200)
Fixes: out of array access
Fixes: 15365/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5716153105645568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/vividas.c

index c0d39f0..184d24f 100644 (file)
@@ -251,6 +251,9 @@ static uint8_t *read_sb_block(AVIOContext *src, unsigned *size,
         *key = tmpkey;
     }
 
+    if (n < 8)
+        return NULL;
+
     buf = av_malloc(n);
     if (!buf)
         return NULL;