Skip to content

Commit e7aea3d

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-20070: Return type violation in imagefilter when an invalid filter is provided
2 parents b3dd837 + 26f9893 commit e7aea3d

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
. Fixed bug GH-19974 (fpm_status_export_to_zval segfault for parallel
1414
execution). (Jakub Zelenka, txuna)
1515

16+
- GD:
17+
. Fixed bug GH-20070 (Return type violation in imagefilter when an invalid
18+
filter is provided). (Girgias)
19+
1620
- Opcache:
1721
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
1822
(Arnaud)

ext/gd/gd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,9 +3732,11 @@ PHP_FUNCTION(imagefilter)
37323732
RETURN_THROWS();
37333733
}
37343734

3735-
if (filtertype >= 0 && filtertype <= IMAGE_FILTER_MAX) {
3736-
filters[filtertype](INTERNAL_FUNCTION_PARAM_PASSTHRU);
3735+
if (UNEXPECTED(filtertype < 0 || filtertype > IMAGE_FILTER_MAX)) {
3736+
zend_argument_value_error(2, "must be one of the IMG_FILTER_* filter constants");
3737+
RETURN_THROWS();
37373738
}
3739+
filters[filtertype](INTERNAL_FUNCTION_PARAM_PASSTHRU);
37383740
}
37393741
/* }}} */
37403742

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-20070: Testing wrong parameter passing in imagefilter() of GD library
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
$image = imagecreatetruecolor(1, 1);
8+
9+
try {
10+
var_dump(imagefilter($image, -1));
11+
} catch (Throwable $e) {
12+
echo $e::class, ': ', $e->getMessage(), "\n";
13+
}
14+
?>
15+
--EXPECT--
16+
ValueError: imagefilter(): Argument #2 ($filter) must be one of the IMG_FILTER_* filter constants

0 commit comments

Comments
 (0)