diff --git a/NEWS b/NEWS index ee63bae14d6..01ce2fcb14e 100644 --- a/NEWS +++ b/NEWS @@ -62,6 +62,10 @@ PHP NEWS . Removed the deprecated inet_ntoa call support. (David Carlier) . Fixed bug #63937 (Upload speed 10 times slower with PHP). (nielsdos) +- GD: + . Fix parameter numbers and missing alpha check for imagecolorset(). + (Giovanni Giacobbi) + - Gettext: . bind_textdomain_codeset, textdomain and d(*)gettext functions now throw an exception on empty domain. (David Carlier) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8b8d6cfd848..b04bd18bb92 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2212,9 +2212,10 @@ PHP_FUNCTION(imagecolorset) im = php_gd_libgdimageptr_from_zval_p(IM); - CHECK_RGBA_RANGE(red, Red, 2); - CHECK_RGBA_RANGE(green, Green, 3); - CHECK_RGBA_RANGE(blue, Blue, 4); + CHECK_RGBA_RANGE(red, Red, 3); + CHECK_RGBA_RANGE(green, Green, 4); + CHECK_RGBA_RANGE(blue, Blue, 5); + CHECK_RGBA_RANGE(alpha, Alpha, 6); col = color; diff --git a/ext/gd/tests/imagecolorset_error1.phpt b/ext/gd/tests/imagecolorset_error1.phpt new file mode 100644 index 00000000000..0a529f8925e --- /dev/null +++ b/ext/gd/tests/imagecolorset_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +imagecolorset() parameters errors +--EXTENSIONS-- +gd +--FILE-- + imagecolorset($im, $c, -3, 4, 5, 6), + fn() => imagecolorset($im, $c, 3, -4, 5, 6), + fn() => imagecolorset($im, $c, 3, 4, -5, 6), + fn() => imagecolorset($im, $c, 3, 4, 5, -6), +); + +?> +--EXPECT-- +!! [ValueError] imagecolorset(): Argument #3 ($red) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorset(): Argument #4 ($green) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorset(): Argument #5 ($blue) must be between 0 and 255 (inclusive) +!! [ValueError] imagecolorset(): Argument #6 ($alpha) must be between 0 and 127 (inclusive)