Skip to content

Commit b6c05b7

Browse files
committed
Fix GH-19578: imagefilledellipse underflow on width argument.
1 parent e46f77c commit b6c05b7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/gd/gd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ PHP_FUNCTION(imagefilledellipse)
832832
RETURN_THROWS();
833833
}
834834

835+
if (w < 0 || w > INT_MAX) {
836+
zend_argument_value_error(4, "must be between 0 and %d", INT_MAX);
837+
RETURN_THROWS();
838+
}
839+
835840
im = php_gd_libgdimageptr_from_zval_p(IM);
836841

837842
gdImageFilledEllipse(im, cx, cy, w, h, color);

ext/gd/tests/gh19578.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-19578: imagefilledellipse underflow on width argument
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
$src = imagecreatetruecolor(255, 255);
8+
9+
try {
10+
imagefilledellipse($src, 0, 0, PHP_INT_MAX, 254, 0);
11+
} catch (\ValueError $e) {
12+
echo $e->getMessage(), PHP_EOL;
13+
}
14+
15+
try {
16+
imagefilledellipse($src, 0, 0, -16, 254, 0);
17+
} catch (\ValueError $e) {
18+
echo $e->getMessage();
19+
}
20+
?>
21+
--EXPECTF--
22+
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
23+
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d

0 commit comments

Comments
 (0)