Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > media > main-updates-src > by-pkgid > db223b1691dea1acce40dbf83477cf1c > files > 9

gimp-2.6.12-0.1.src.rpm

From e973045809f3fc7aebdf6cbfc9daff05c53837d0 Mon Sep 17 00:00:00 2001
From: Nils Philippsen <nils@redhat.com>
Date: Thu, 16 Aug 2012 15:23:41 +0200
Subject: [PATCH] patch: CVE-2012-3481

Squashed commit of the following:

commit 407606bdbb404c0a1bf14751a394459e1bedfc08
Author: Nils Philippsen <nils@redhat.com>
Date:   Tue Aug 14 15:27:39 2012 +0200

    file-gif-load: fix type overflow (CVE-2012-3481)

    Cast variables properly to avoid overflowing when computing how much
    memory to allocate.

commit 4ec417c50d4cce935a87b5beab051e85cbfcec45
Author: Jan Lieskovsky <jlieskov@redhat.com>
Date:   Tue Aug 14 12:18:22 2012 +0200

    file-gif-load: limit len and height (CVE-2012-3481)

    Ensure values of len and height can't overflow g_malloc() argument type.
---
 plug-ins/common/file-gif-load.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index 8460ec0..295c351 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -1028,10 +1028,17 @@ ReadImage (FILE        *fd,
   cur_progress = 0;
   max_progress = height;
 
+  if (len > (G_MAXSIZE / height / (alpha_frame ? (promote_to_rgb ? 4 : 2) : 1)))
+  {
+    g_message ("'%s' has a larger image size than GIMP can handle.",
+               gimp_filename_to_utf8 (filename));
+    return -1;
+  }
+
   if (alpha_frame)
-    dest = (guchar *) g_malloc (len * height * (promote_to_rgb ? 4 : 2));
+    dest = (guchar *) g_malloc ((gsize)len * (gsize)height * (promote_to_rgb ? 4 : 2));
   else
-    dest = (guchar *) g_malloc (len * height);
+    dest = (guchar *) g_malloc ((gsize)len * (gsize)height);
 
 #ifdef GIFDEBUG
     g_print ("GIF: reading %d by %d%s GIF image, ncols=%d\n",
-- 
1.7.11.4