mattias Thu Aug 9 12:09:30 2007 UTC
Modified files:
/php-src/ext/gd/libgd xbm.c
/php-src/ext/gd/tests libgd00094.phpt libgd00094.xbm
Log:
-MFB: libgd #94, imagecreatefromxbm can crash if gdImageCreate fails
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/xbm.c?r1=1.10&r2=1.11&diff_format=u
Index: php-src/ext/gd/libgd/xbm.c
diff -u php-src/ext/gd/libgd/xbm.c:1.10 php-src/ext/gd/libgd/xbm.c:1.11
--- php-src/ext/gd/libgd/xbm.c:1.10 Mon Jan 1 09:29:24 2007
+++ php-src/ext/gd/libgd/xbm.c Thu Aug 9 12:09:30 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xbm.c,v 1.10 2007/01/01 09:29:24 sebastian Exp $ */
+/* $Id: xbm.c,v 1.11 2007/08/09 12:09:30 mattias Exp $ */
#include <stdio.h>
#include <math.h>
@@ -96,7 +96,9 @@
return 0;
}
- im = gdImageCreate(width, height);
+ if(!(im = gdImageCreate(width, height))) {
+ return 0;
+ }
gdImageColorAllocate(im, 255, 255, 255);
gdImageColorAllocate(im, 0, 0, 0);
h[2] = '\0';
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/libgd00094.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/libgd00094.phpt
diff -u /dev/null php-src/ext/gd/tests/libgd00094.phpt:1.2
--- /dev/null Thu Aug 9 12:09:30 2007
+++ php-src/ext/gd/tests/libgd00094.phpt Thu Aug 9 12:09:30 2007
@@ -0,0 +1,19 @@
+--TEST--
+libgd #94 (imagecreatefromxbm can crash if gdImageCreate fails)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die("skip requires bundled GD library\n");
+?>
+--FILE--
+<?php
+$im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094.xbm');
+var_dump($im);
+?>
+--EXPECTF--
+Warning: imagecreatefromxbm(): gd warning: product of memory allocation
multiplication would exceed INT_MAX, failing operation gracefully
+ in %slibgd00094.php on line %d
+
+Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in
%slibgd00094.php on line %d
+bool(false)
+
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/libgd00094.xbm?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/libgd00094.xbm
diff -u /dev/null php-src/ext/gd/tests/libgd00094.xbm:1.2
--- /dev/null Thu Aug 9 12:09:30 2007
+++ php-src/ext/gd/tests/libgd00094.xbm Thu Aug 9 12:09:30 2007
@@ -0,0 +1,3 @@
+#define width 255
+#define height 1073741824
+static unsigned char bla = {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php