1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix parameter numbers and missing alpha check for imagecolorset()

The check for the alpha parameter existed in PHP 7.4 but was lost in PHP 8.0.

Fixes: 50765075db

Closes GH-14477.
This commit is contained in:
Giovanni Giacobbi
2024-06-05 08:57:18 +02:00
committed by Niels Dossche
parent a3b148e38d
commit 44cbdb107e
3 changed files with 34 additions and 3 deletions

4
NEWS
View File

@@ -62,6 +62,10 @@ PHP NEWS
. Removed the deprecated inet_ntoa call support. (David Carlier) . Removed the deprecated inet_ntoa call support. (David Carlier)
. Fixed bug #63937 (Upload speed 10 times slower with PHP). (nielsdos) . Fixed bug #63937 (Upload speed 10 times slower with PHP). (nielsdos)
- GD:
. Fix parameter numbers and missing alpha check for imagecolorset().
(Giovanni Giacobbi)
- Gettext: - Gettext:
. bind_textdomain_codeset, textdomain and d(*)gettext functions . bind_textdomain_codeset, textdomain and d(*)gettext functions
now throw an exception on empty domain. (David Carlier) now throw an exception on empty domain. (David Carlier)

View File

@@ -2212,9 +2212,10 @@ PHP_FUNCTION(imagecolorset)
im = php_gd_libgdimageptr_from_zval_p(IM); im = php_gd_libgdimageptr_from_zval_p(IM);
CHECK_RGBA_RANGE(red, Red, 2); CHECK_RGBA_RANGE(red, Red, 3);
CHECK_RGBA_RANGE(green, Green, 3); CHECK_RGBA_RANGE(green, Green, 4);
CHECK_RGBA_RANGE(blue, Blue, 4); CHECK_RGBA_RANGE(blue, Blue, 5);
CHECK_RGBA_RANGE(alpha, Alpha, 6);
col = color; col = color;

View File

@@ -0,0 +1,26 @@
--TEST--
imagecolorset() parameters errors
--EXTENSIONS--
gd
--FILE--
<?php
require __DIR__ . '/func.inc';
$im = imagecreate(5, 5);
$c = imagecolorallocatealpha($im, 3, 4, 5, 6);
trycatch_dump(
fn() => 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)