Skip to content

Commit

Permalink
4xm: Add a check in decode_i_frame to prevent buffer overreads
Browse files Browse the repository at this point in the history
Fixes bugzilla FFmpeg#135

Signed-off-by: Janne Grunau <[email protected]>
  • Loading branch information
Dragooon authored and Janne Grunau committed Dec 22, 2011
1 parent 01a01bf commit 355d917
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libavcodec/4xm.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,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)
Expand Down

0 comments on commit 355d917

Please sign in to comment.