From: Michael Niedermayer Date: Fri, 3 Oct 2014 18:15:52 +0000 (+0200) Subject: gifdec: refactor interleave end handling X-Git-Tag: v11.4~134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eac49477aa95cf727d87d2741ee8e60be59d394b;p=platform%2Fupstream%2Flibav.git gifdec: refactor interleave end handling Fixes invalid writes with very small image heights. CC: libav-stable@libav.org Bug-ID: CVE-2014-8547 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Anton Khirnov (cherry picked from commit 0b39ac6f54505a538c21fe49a626de94c518c903) Signed-off-by: Anton Khirnov --- diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index cdb7f23..df5ab78 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -125,26 +125,21 @@ static int gif_read_image(GifState *s, AVFrame *frame) case 1: y1 += 8; ptr += linesize * 8; - if (y1 >= height) { - y1 = pass ? 2 : 4; - ptr = ptr1 + linesize * y1; - pass++; - } break; case 2: y1 += 4; ptr += linesize * 4; - if (y1 >= height) { - y1 = 1; - ptr = ptr1 + linesize; - pass++; - } break; case 3: y1 += 2; ptr += linesize * 2; break; } + while (y1 >= height) { + y1 = 4 >> pass; + ptr = ptr1 + linesize * y1; + pass++; + } } else { ptr += linesize; }