avcodec/flashsv: check diff_start/height
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 20 Aug 2013 21:18:48 +0000 (23:18 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 28 Aug 2013 23:29:35 +0000 (01:29 +0200)
Fixes out of array accesses
Fixes Ticket2844

Found-by: ami_stuff
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 880c73cd76109697447fbfbaa8e5ee5683309446)

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

index 1d94efd..db956cb 100644 (file)
@@ -373,6 +373,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
                 if (has_diff) {
                     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\n");
+                        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);