d2399a
From cf4753691dc55999373d1c576f62ecb298723420 Mon Sep 17 00:00:00 2001
d2399a
From: Remi Collet <remi@php.net>
d2399a
Date: Mon, 4 Aug 2014 10:42:39 +0200
d2399a
Subject: [PATCH] Fixed Bug #66901 php-gd 'c_color' NULL pointer dereference
d2399a
d2399a
Upstream https://bitbucket.org/libgd/gd-libgd/commits/463c3bd09bfe8e924e19acad7a2a6af16953a704
d2399a
d2399a
Notice: this fix don't manage monochrome/monovisual values
d2399a
but just fix the security issue CVE-2014-2497
d2399a
failing when trying to load such an image
d2399a
---
d2399a
 ext/gd/libgd/gdxpm.c | 7 ++++++-
d2399a
 1 file changed, 6 insertions(+), 1 deletion(-)
d2399a
d2399a
diff --git a/ext/gd/libgd/gdxpm.c b/ext/gd/libgd/gdxpm.c
d2399a
index 73f86e5..b69414e 100644
d2399a
--- a/ext/gd/libgd/gdxpm.c
d2399a
+++ b/ext/gd/libgd/gdxpm.c
d2399a
@@ -31,12 +31,17 @@ gdImagePtr gdImageCreateFromXpm (char *filename)
d2399a
 	if (ret != XpmSuccess) {
d2399a
 		return 0;
d2399a
 	}
d2399a
+	number = image.ncolors;
d2399a
+	for(i = 0; i < number; i++) {
d2399a
+		if (!image.colorTable[i].c_color) {
d2399a
+			goto done;
d2399a
+		}
d2399a
+	}
d2399a
 
d2399a
 	if (!(im = gdImageCreate(image.width, image.height))) {
d2399a
 		goto done;
d2399a
 	}
d2399a
 
d2399a
-	number = image.ncolors;
d2399a
 	colors = (int *) safe_emalloc(number, sizeof(int), 0);
d2399a
 	for (i = 0; i < number; i++) {
d2399a
 		switch (strlen (image.colorTable[i].c_color)) {
d2399a
-- 
d2399a
1.9.2
d2399a