OSDN Git Service

avcodec/zmbv: Check len before reading in decode_frame()
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 11:29:10 +0000 (12:29 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 11:30:04 +0000 (12:30 +0100)
Fixes out of array read
Fixes: asan_heap-oob_4d4eb0_3994_cov_3169972261_zmbv_15bit.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/zmbv.c

index c16d912..82ae169 100644 (file)
@@ -410,11 +410,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
     int hi_ver, lo_ver, ret;
 
     /* parse header */
+    if (len < 1)
+        return AVERROR_INVALIDDATA;
     c->flags = buf[0];
     buf++; len--;
     if (c->flags & ZMBV_KEYFRAME) {
         void *decode_intra = NULL;
         c->decode_intra= NULL;
+
+        if (len < 6)
+            return AVERROR_INVALIDDATA;
         hi_ver = buf[0];
         lo_ver = buf[1];
         c->comp = buf[2];