vc1dec: check that coded slice positions and interlacing match.
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 28 Jul 2012 11:14:50 +0000 (17:14 +0600)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 28 Jul 2012 11:34:05 +0000 (13:34 +0200)
This fixes out of array writes

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
libavcodec/vc1dec.c

index f49fff8..5726c0a 100644 (file)
@@ -5569,6 +5569,12 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
         mb_height = s->mb_height >> v->field_mode;
         for (i = 0; i <= n_slices; i++) {
             if (i > 0 &&  slices[i - 1].mby_start >= mb_height) {
+                if (v->field_mode <= 0) {
+                    av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond "
+                           "picture boundary (%d >= %d)\n", i,
+                           slices[i - 1].mby_start, mb_height);
+                    continue;
+                }
                 v->second_field = 1;
                 v->blocks_off   = s->mb_width  * s->mb_height << 1;
                 v->mb_off       = s->mb_stride * s->mb_height >> 1;