summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-03-18 22:44:02 +0100
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-03-23 18:59:04 +0100
commit01b266aac405c3c4c677d46f348dc6b227b69f7f (patch)
treed1c68e09fa5f200542b2424c084bc25bb2a5397f /ext/gd
parentd7b73de8c9299ef1e7c55f22449dff3e0833f68e (diff)
downloadphp-git-01b266aac405c3c4c677d46f348dc6b227b69f7f.tar.gz
Improve error messages of various extensions
Closes GH-5278
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/gd.c16
-rw-r--r--ext/gd/tests/bug67248.phpt14
-rw-r--r--ext/gd/tests/imagebmp_nullbyte_injection.phpt2
-rw-r--r--ext/gd/tests/imagegif_nullbyte_injection.phpt2
-rw-r--r--ext/gd/tests/imagejpeg_nullbyte_injection.phpt2
-rw-r--r--ext/gd/tests/imagepng_nullbyte_injection.phpt2
-rw-r--r--ext/gd/tests/imagewbmp_nullbyte_injection.phpt2
-rw-r--r--ext/gd/tests/imagewebp_nullbyte_injection.phpt2
8 files changed, 21 insertions, 21 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 1775ae4627..8435d765b6 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -3885,7 +3885,7 @@ PHP_FUNCTION(imageaffine)
src = php_gd_libgdimageptr_from_zval_p(IM);
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
- zend_value_error("Affine array must have six elements");
+ zend_argument_value_error(2, "must have 6 elements");
RETURN_THROWS();
}
@@ -3902,7 +3902,7 @@ PHP_FUNCTION(imageaffine)
affine[i] = zval_get_double(zval_affine_elem);
break;
default:
- zend_type_error("Invalid type for element %i", i);
+ zend_argument_type_error(3, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
@@ -3970,7 +3970,7 @@ PHP_FUNCTION(imageaffinematrixget)
case GD_AFFINE_SCALE: {
double x, y;
if (!options || Z_TYPE_P(options) != IS_ARRAY) {
- zend_type_error("Array expected as options when using translate or scale");
+ zend_argument_type_error(1, "must be of type array when using translate or scale");
RETURN_THROWS();
}
@@ -4002,7 +4002,7 @@ PHP_FUNCTION(imageaffinematrixget)
double angle;
if (!options) {
- zend_type_error("Number is expected as option when using rotate or shear");
+ zend_argument_type_error(2, "must be of type int|double when using rotate or shear");
RETURN_THROWS();
}
@@ -4019,7 +4019,7 @@ PHP_FUNCTION(imageaffinematrixget)
}
default:
- zend_value_error("Invalid type for element " ZEND_LONG_FMT, type);
+ zend_argument_value_error(1, "must be a valid element type");
RETURN_THROWS();
}
@@ -4068,7 +4068,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
m1[i] = zval_get_double(tmp);
break;
default:
- zend_type_error("Matrix 1 contains invalid type for element %i", i);
+ zend_argument_type_error(1, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
@@ -4085,7 +4085,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
m2[i] = zval_get_double(tmp);
break;
default:
- zend_type_error("Matrix 2 contains invalid type for element %i", i);
+ zend_argument_type_error(2, "contains invalid type for element %i", i);
RETURN_THROWS();
}
}
@@ -4299,7 +4299,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
close_stream = 0;
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
if (CHECK_ZVAL_NULL_PATH(to_zval)) {
- zend_type_error("Invalid 2nd parameter, filename must not contain null bytes");
+ zend_argument_type_error(2, "must not contain null bytes");
RETURN_THROWS();
}
diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt
index c5b54354f1..b54a20ba8e 100644
--- a/ext/gd/tests/bug67248.phpt
+++ b/ext/gd/tests/bug67248.phpt
@@ -16,10 +16,10 @@ for($i=0;$i<7;$i++) {
}
?>
--EXPECT--
-!! [TypeError] Array expected as options when using translate or scale
-!! [TypeError] Array expected as options when using translate or scale
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [TypeError] Number is expected as option when using rotate or shear
-!! [ValueError] Invalid type for element 5
-!! [ValueError] Invalid type for element 6
+!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|double when using rotate or shear
+!! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type
+!! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type
diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt
index 00d0a7168c..9f0398b5da 100644
--- a/ext/gd/tests/imagebmp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt
@@ -15,4 +15,4 @@ try {
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagebmp(): Argument #2 ($to) must not contain null bytes
diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt
index 4518ecad27..4b164392c2 100644
--- a/ext/gd/tests/imagegif_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt
@@ -14,4 +14,4 @@ try {
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagegif(): Argument #2 ($to) must not contain null bytes
diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
index 1a7f6da03c..2f175271d1 100644
--- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
@@ -18,4 +18,4 @@ try {
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagejpeg(): Argument #2 ($to) must not contain null bytes
diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt
index 86d614ab60..bd98a97dab 100644
--- a/ext/gd/tests/imagepng_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt
@@ -18,4 +18,4 @@ try {
}
?>
--EXPECTF--
-Invalid 2nd parameter, filename must not contain null bytes
+imagepng(): Argument #2 ($to) must not contain null bytes
diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
index cce38a63df..8f2bdcec59 100644
--- a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
@@ -18,4 +18,4 @@ try {
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagewbmp(): Argument #2 ($to) must not contain null bytes
diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
index 82e45aca02..c48fd7d821 100644
--- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
@@ -18,4 +18,4 @@ try {
}
?>
--EXPECT--
-Invalid 2nd parameter, filename must not contain null bytes
+imagewebp(): Argument #2 ($to) must not contain null bytes