diff options
author | Laurent Aimar <fenrir@videolan.org> | 2011-09-21 20:46:31 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-22 01:19:07 +0200 |
commit | 69b6248327a042155396177eaff009b65bc8fcc8 (patch) | |
tree | 084ecc618440b58032b6436a72cf382a4f23ca94 | |
parent | 533dbaa55b7d45d5ca76f9ed46f5690282f86ea9 (diff) | |
download | ffmpeg-69b6248327a042155396177eaff009b65bc8fcc8.tar.gz |
Check for invalid slices offsets in RV30/40 decoder.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit b64269ce5528bdbec8af671042f97af1242cf044)
-rw-r--r-- | libavcodec/rv34.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 1810263751..54fc29eca3 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1477,13 +1477,18 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, else size= get_slice_offset(avctx, slices_hdr, i+1) - offset; - if(offset < 0 || offset > buf_size || size < 0){ + if(offset < 0 || offset > buf_size){ av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); break; } r->si.end = s->mb_width * s->mb_height; if(i+1 < slice_count){ + if (get_slice_offset(avctx, slices_hdr, i+1) < 0 || + get_slice_offset(avctx, slices_hdr, i+1) > buf_size) { + av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n"); + break; + } init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8); if(r->parse_slice_header(r, &r->s.gb, &si) < 0){ if(i+2 < slice_count) @@ -1493,6 +1498,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, }else r->si.end = si.start; } + if (size < 0 || size > buf_size - offset) { + av_log(avctx, AV_LOG_ERROR, "Slice size is invalid\n"); + break; + } last = rv34_decode_slice(r, r->si.end, buf + offset, size); s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start; if(last) |