shorten: fix "off by padding" bug
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 22 May 2013 15:39:22 +0000 (17:39 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 22 May 2013 15:40:12 +0000 (17:40 +0200)
Fixes array overread

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/shorten.c

index 23c5d7c..3bba10c 100644 (file)
@@ -437,7 +437,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
         buf_size       = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
         input_buf_size = buf_size;
 
-        if (s->bitstream_index + s->bitstream_size + buf_size >
+        if (s->bitstream_index + s->bitstream_size + buf_size + FF_INPUT_BUFFER_PADDING_SIZE >
             s->allocated_bitstream_size) {
             memmove(s->bitstream, &s->bitstream[s->bitstream_index],
                     s->bitstream_size);