mirror of https://git.ffmpeg.org/ffmpeg.git synced 2024-12-25 08:42:39 +00:00

lzw: prevent buffer overreads.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
This commit is contained in:
Ronald S. Bultje 2012-03-28 17:06:00 -07:00
parent 28e8c4d59a
commit ddcf67c8a5

View File

@ -101,9 +101,14 @@ void ff_lzw_decode_tail(LZWState *p)
struct LZWState *s = (struct LZWState *)p;
if(s->mode == FF_LZW_GIF) {
while(s->pbuf < s->ebuf && s->bs>0){
s->pbuf += s->bs;
s->bs = *s->pbuf++;
while (s->bs > 0) {
if (s->pbuf + s->bs >= s->ebuf) {
s->pbuf = s->ebuf;
break;
} else {
s->pbuf += s->bs;
s->bs = *s->pbuf++;
}
}
}else
s->pbuf= s->ebuf;