aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/lzw.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-03-28 17:06:00 -0700
committerRonald S. Bultje <rsbultje@gmail.com>2012-03-28 17:38:51 -0700
commitddcf67c8a51c67b122a826d8b5819e96d591d813 (patch)
treec4ccddb8402aaa482b87f9d96f1dc5522d79bd37 /libavcodec/lzw.c
parent28e8c4d59a7c1a7b2b3b3a2e499b3e67fed1844b (diff)
downloadffmpeg-ddcf67c8a51c67b122a826d8b5819e96d591d813.tar.gz
lzw: prevent buffer overreads.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
Diffstat (limited to 'libavcodec/lzw.c')
-rw-r--r--libavcodec/lzw.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c
index 873b31445b..b674d4e296 100644
--- a/libavcodec/lzw.c
+++ b/libavcodec/lzw.c
@@ -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;