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>
Tue, 20 Aug 2013 21:18:48 +0000 (23:18 +0200)
Fixes out of array accesses
Fixes Ticket2844

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

index 9982b5e..f00bf21 100644 (file)
@@ -387,6 +387,10 @@ 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\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);