summaryrefslogtreecommitdiff
path: root/libavcodec/msrledec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-11-02 01:19:12 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-11-02 01:19:12 +0000
commit742978310101b435c57e7f0adaa8ab6d345d8eb7 (patch)
treebc326792e416d00ea64cbabbac9e6b51abb24728 /libavcodec/msrledec.c
parent81a646140f80c3e15c1e68883a5ecfb9b2bc8a6a (diff)
Fix possibly exploitable buffer overrun in msrle_decode_8_16_24_32().
Issue has been reported to me by Gynvael Coldwind Originally committed as revision 25632 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/msrledec.c')
-rw-r--r--libavcodec/msrledec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c
index d3d3601756..098e7d857a 100644
--- a/libavcodec/msrledec.c
+++ b/libavcodec/msrledec.c
@@ -136,6 +136,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
int p1, p2, line=avctx->height - 1, pos=0, i;
uint16_t av_uninit(pix16);
uint32_t av_uninit(pix32);
+ unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3);
output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
output_end = pic->data[0] + (avctx->height) * pic->linesize[0];
@@ -157,11 +158,11 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
p1 = *src++;
p2 = *src++;
line -= p2;
- if (line < 0){
+ pos += p1;
+ if (line < 0 || pos >= width){
av_log(avctx, AV_LOG_ERROR, "Skip beyond picture bounds\n");
return -1;
}
- pos += p1;
output = pic->data[0] + line * pic->linesize[0] + pos * (depth >> 3);
continue;
}