lzw: check for overread

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-04-15 18:13:50 +02:00
parent a63c813797
commit 44c4170c52

View File

@ -190,6 +190,10 @@ int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
if ((--l) == 0) if ((--l) == 0)
goto the_end; goto the_end;
} }
if (s->ebuf < s->pbuf) {
av_log(0, AV_LOG_ERROR, "lzw overread\n");
goto the_end;
}
c = lzw_get_code(s); c = lzw_get_code(s);
if (c == s->end_code) { if (c == s->end_code) {
break; break;