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

Fix GH-19578: imagefilledellipse underflow on width argument.

close GH-19579
This commit is contained in:
David Carlier
2025-08-25 06:41:45 +01:00
parent 2f162214e8
commit 93865a4086
4 changed files with 56 additions and 0 deletions

4
NEWS
View File

@@ -29,6 +29,10 @@ PHP NEWS
- FPM:
. Fixed failed debug assertion when php_admin_value setting fails. (ilutov)
- GD:
. Fixed bug GH-19579 (imagefilledellipse underflow on width argument).
(David Carlier)
- OpenSSL:
. Fixed bug GH-19245 (Success error message on TLS stream accept failure).
(Jakub Zelenka)

View File

@@ -832,6 +832,11 @@ PHP_FUNCTION(imagefilledellipse)
RETURN_THROWS();
}
if (w < 0 || ZEND_LONG_INT_OVFL(w)) {
zend_argument_value_error(4, "must be between 0 and %d", INT_MAX);
RETURN_THROWS();
}
im = php_gd_libgdimageptr_from_zval_p(IM);
gdImageFilledEllipse(im, cx, cy, w, h, color);

27
ext/gd/tests/gh19578.phpt Normal file
View File

@@ -0,0 +1,27 @@
--TEST--
GH-19578: imagefilledellipse underflow on width argument
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die('skip this test is for 64bit platforms only');
?>
--FILE--
<?php
$src = imagecreatetruecolor(255, 255);
try {
imagefilledellipse($src, 0, 0, PHP_INT_MAX, 254, 0);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
imagefilledellipse($src, 0, 0, -16, 254, 0);
} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d

View File

@@ -0,0 +1,20 @@
--TEST--
GH-19578: imagefilledellipse underflow on width argument
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die('skip this test is for 32bit platforms only');
?>
--FILE--
<?php
$src = imagecreatetruecolor(255, 255);
try {
imagefilledellipse($src, 0, 0, -16, 254, 0);
} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d