Skip to content

Commit 1feb210

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 39ae00f + 3caa5f8 commit 1feb210

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ext/gd/gd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,11 @@ PHP_FUNCTION(imagerotate)
12371237
Z_PARAM_LONG(color)
12381238
ZEND_PARSE_PARAMETERS_END();
12391239

1240+
if (degrees < (double)(INT_MIN / 100) || degrees > (double)(INT_MAX / 100)) {
1241+
zend_argument_value_error(2, "must be between %d and %d", (INT_MIN / 100), (INT_MAX / 100));
1242+
RETURN_THROWS();
1243+
}
1244+
12401245
im_src = php_gd_libgdimageptr_from_zval_p(SIM);
12411246
im_dst = gdImageRotateInterpolated(im_src, (const float)degrees, color);
12421247

ext/gd/tests/gh16260.phpt

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

0 commit comments

Comments
 (0)