[FFmpeg-cvslog] gifdec: refactor interleave end handling

Michael Niedermayer git at videolan.org
Wed Mar 11 22:37:44 CET 2015


ffmpeg | branch: release/0.10 | Michael Niedermayer <michaelni at gmx.at> | Fri Oct  3 20:15:52 2014 +0200| [9ae3cd6e7271a3d6b8cd92a4d35ebb16d2e03f1a] | committer: Anton Khirnov

gifdec: refactor interleave end handling

Fixes invalid writes with very small image heights.

CC: libav-stable at libav.org
Bug-ID: CVE-2014-8547
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 0b39ac6f54505a538c21fe49a626de94c518c903)
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit eac49477aa95cf727d87d2741ee8e60be59d394b)
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 92888e9ed4ea4e761ae953bbe28c85cc658abc8f)
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 02de44073a8e116ea177b53081219d32ef135ad8)
Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ae3cd6e7271a3d6b8cd92a4d35ebb16d2e03f1a
---

 libavcodec/gifdec.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 9bac254..4b30e50 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -125,26 +125,21 @@ static int gif_read_image(GifState *s)
             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;
         }



More information about the ffmpeg-cvslog mailing list