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