Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93865a4

Browse files
committed
Fix GH-19578: imagefilledellipse underflow on width argument.
close GH-19579
1 parent 2f16221 commit 93865a4

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

‎NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ PHP NEWS
2929
- FPM:
3030
. Fixed failed debug assertion when php_admin_value setting fails. (ilutov)
3131

32+
- GD:
33+
. Fixed bug GH-19579 (imagefilledellipse underflow on width argument).
34+
(David Carlier)
35+
3236
- OpenSSL:
3337
. Fixed bug GH-19245 (Success error message on TLS stream accept failure).
3438
(Jakub Zelenka)

‎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 || ZEND_LONG_INT_OVFL(w)) {
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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
GH-19578: imagefilledellipse underflow on width argument
3+
--EXTENSIONS--
4+
gd
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE != 8) die('skip this test is for 64bit platforms only');
8+
?>
9+
--FILE--
10+
<?php
11+
$src = imagecreatetruecolor(255, 255);
12+
13+
try {
14+
imagefilledellipse($src, 0, 0, PHP_INT_MAX, 254, 0);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage(), PHP_EOL;
17+
}
18+
19+
try {
20+
imagefilledellipse($src, 0, 0, -16, 254, 0);
21+
} catch (\ValueError $e) {
22+
echo $e->getMessage();
23+
}
24+
?>
25+
--EXPECTF--
26+
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
27+
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d

‎ext/gd/tests/gh19578_32bits.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-19578: imagefilledellipse underflow on width argument
3+
--EXTENSIONS--
4+
gd
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE != 4) die('skip this test is for 32bit platforms only');
8+
?>
9+
--FILE--
10+
<?php
11+
$src = imagecreatetruecolor(255, 255);
12+
13+
try {
14+
imagefilledellipse($src, 0, 0, -16, 254, 0);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage();
17+
}
18+
?>
19+
--EXPECTF--
20+
imagefilledellipse(): Argument #4 ($width) must be between 0 and %d

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /