avcodec/indeo2: check ctab
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 Aug 2016 11:07:14 +0000 (13:07 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 Aug 2016 12:24:13 +0000 (14:24 +0200)
Fixes out of array access
Fixes: 6b73fa392ac808f02e95a4e0a5770026/asan_static-oob_1b15f9a_1969_e7778535e5f27225fe0d6ded14721430.AVI

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/indeo2.c

index a58dfa0..c898452 100644 (file)
@@ -172,6 +172,12 @@ static int ir2_decode_frame(AVCodecContext *avctx,
 
     ltab = buf[0x22] & 3;
     ctab = buf[0x22] >> 2;
+
+    if (ctab > 3) {
+        av_log(avctx, AV_LOG_ERROR, "ctab %d is invalid\n", ctab);
+        return AVERROR_INVALIDDATA;
+    }
+
     if (s->decode_delta) { /* intraframe */
         if ((ret = ir2_decode_plane(s, avctx->width, avctx->height,
                                     p->data[0], p->linesize[0],