From: Pierre Joye Date: Sun, 10 Dec 2006 03:03:48 +0000 (+0000) Subject: - MFB: #39286, misleading error message when invalid dimensions are given X-Git-Tag: RELEASE_1_0_0RC1~734 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80ecfc354efa9783df8f55892e60efcbb62432aa;p=php - MFB: #39286, misleading error message when invalid dimensions are given --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index ac73d3e89a..efdc399cfe 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2125,6 +2125,10 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, 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; diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt index 0094712a55..04c89fece4 100644 --- a/ext/gd/tests/bug38212.phpt +++ b/ext/gd/tests/bug38212.phpt @@ -1,5 +1,5 @@ --TEST-- -imagecopy doen't copy alpha, palette to truecolor +Bzg #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters) --SKIPIF-- --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 diff --git a/ext/gd/tests/bug39286.phpt b/ext/gd/tests/bug39286.phpt new file mode 100644 index 0000000000..3f2a178125 --- /dev/null +++ b/ext/gd/tests/bug39286.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #39508 (imagefill crashes with small images 3 pixels or less) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- + +Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d