flashsv: Check diff_start diff_height values
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 20 Aug 2013 21:18:48 +0000 (23:18 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 1 Nov 2013 18:38:53 +0000 (19:38 +0100)
Fix out of array accesses.

Found-by: ami_stuff
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/flashsv.c

index f0a8036..a237aa7 100644 (file)
@@ -383,6 +383,12 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
                     }
                     s->diff_start  = get_bits(&gb, 8);
                     s->diff_height = get_bits(&gb, 8);
+                    if (s->diff_start + s->diff_height > cur_blk_height) {
+                        av_log(avctx, AV_LOG_ERROR,
+                               "Block parameters invalid: %d + %d > %d\n",
+                               s->diff_start, s->diff_height, cur_blk_height);
+                        return AVERROR_INVALIDDATA;
+                    }
                     av_log(avctx, AV_LOG_DEBUG,
                            "%dx%d diff start %d height %d\n",
                            i, j, s->diff_start, s->diff_height);