From 295a7c0238e84b0ffa8f21ed938d45f51f54a4cd Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Thu, 5 Jan 2012 01:28:21 +0530 Subject: 4xm: Prevent buffer overreads. 4xm decoder while decoding i2 frames can overread the buffer if proper checks are not made. Signed-off-by: Ronald S. Bultje --- libavcodec/4xm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libavcodec/4xm.c') diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index cfb8279870..d16c232fbf 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -614,16 +614,24 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length){ int x, y, x2, y2; const int width= f->avctx->width; const int height= f->avctx->height; + const int mbs = FFALIGN(width, 16) * FFALIGN(height, 16); uint16_t *dst= (uint16_t*)f->current_picture.data[0]; const int stride= f->current_picture.linesize[0]>>1; + GetByteContext g3; + + if(length < mbs * 8) { + av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n"); + return AVERROR_INVALIDDATA; + } + bytestream2_init(&g3, buf, length); for(y=0; y>2) + 8*(y2>>2); -- cgit v1.2.3