diff options
author | Shitiz Garg <mail@dragooon.net> | 2011-12-14 18:29:21 +0530 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-12-23 22:27:02 +0100 |
commit | d912a30c7d5cf9b8fdb26402804c9b0f999b4ff1 (patch) | |
tree | d085a1a150a57fbd653869bd3da8cbea9058550c /libavcodec/4xm.c | |
parent | 8dba5608dcf76032d8a9aa4bd8a3fc1392682281 (diff) | |
download | ffmpeg-d912a30c7d5cf9b8fdb26402804c9b0f999b4ff1.tar.gz |
4xm: Add a check in decode_i_frame to prevent buffer overreads
Fixes bugzilla #135
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
(cherry picked from commit 355d917c0bd8163a3f1c7d4a6866dac749efdb84)
Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec/4xm.c')
-rw-r--r-- | libavcodec/4xm.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 176feb94c0..ed832598b0 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -658,9 +658,18 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ uint16_t *dst= (uint16_t*)f->current_picture.data[0]; const int stride= f->current_picture.linesize[0]>>1; const unsigned int bitstream_size= AV_RL32(buf); - const int token_count av_unused = AV_RL32(buf + bitstream_size + 8); - unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4); - const uint8_t *prestream= buf + bitstream_size + 12; + int token_count av_unused; + unsigned int prestream_size; + const uint8_t *prestream; + + if (length < bitstream_size + 12) { + av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n"); + return AVERROR_INVALIDDATA; + } + + token_count = AV_RL32(buf + bitstream_size + 8); + prestream_size = 4 * AV_RL32(buf + bitstream_size + 4); + prestream = buf + bitstream_size + 12; if(prestream_size + bitstream_size + 12 != length || bitstream_size > (1<<26) |