pajoye Sun Dec 10 03:03:48 2006 UTC
Modified files:
/php-src/ext/gd gd.c
/php-src/ext/gd/tests bug39286.phpt bug38212.phpt
Log:
- MFB: #39286, misleading error message when invalid dimensions are given
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd.c?r1=1.362&r2=1.363&diff_format=u
Index: php-src/ext/gd/gd.c
diff -u php-src/ext/gd/gd.c:1.362 php-src/ext/gd/gd.c:1.363
--- php-src/ext/gd/gd.c:1.362 Sun Dec 10 01:28:01 2006
+++ php-src/ext/gd/gd.c Sun Dec 10 03:03:48 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.362 2006/12/10 01:28:01 pajoye Exp $ */
+/* $Id: gd.c,v 1.363 2006/12/10 03:03:48 pajoye Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -2125,6 +2125,10 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zllll",
&ppfilename, &srcx, &srcy, &width, &height) == FAILURE) {
return;
}
+ if (width < 1 || height < 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Zero width
or height not allowed");
+ RETURN_FALSE;
+ }
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z",
&ppfilename) == FAILURE) {
return;
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug39286.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/bug39286.phpt
diff -u /dev/null php-src/ext/gd/tests/bug39286.phpt:1.2
--- /dev/null Sun Dec 10 03:03:48 2006
+++ php-src/ext/gd/tests/bug39286.phpt Sun Dec 10 03:03:48 2006
@@ -0,0 +1,14 @@
+--TEST--
+Bug #39508 (imagefill crashes with small images 3 pixels or less)
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+ if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100);
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on
line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug38212.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/bug38212.phpt
diff -u php-src/ext/gd/tests/bug38212.phpt:1.1
php-src/ext/gd/tests/bug38212.phpt:1.2
--- php-src/ext/gd/tests/bug38212.phpt:1.1 Wed Jul 26 08:51:53 2006
+++ php-src/ext/gd/tests/bug38212.phpt Sun Dec 10 03:03:48 2006
@@ -1,5 +1,5 @@
--TEST--
-imagecopy doen't copy alpha, palette to truecolor
+Bzg #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
--SKIPIF--
<?php
if (!function_exists('imagecopy')) die("skip gd extension not
available\n");
@@ -14,4 +14,5 @@
unlink($file);
?>
--EXPECTF--
-Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in
%sbug38212.php on line %d
+
+Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on
line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php