Skip to content

Commit 414d562

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
2 parents a584d12 + 61b276c commit 414d562

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/filter/logical_filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
444444

445445
switch (is_numeric_string(num, p - num, &lval, &dval, 0)) {
446446
case IS_LONG:
447-
zval_ptr_dtor(value);
448447
if ((min_range_set && (lval < min_range)) || (max_range_set && (lval > max_range))) {
449448
goto error;
450449
}
450+
zval_ptr_dtor(value);
451451
ZVAL_DOUBLE(value, (double)lval);
452452
break;
453453
case IS_DOUBLE:

ext/filter/tests/bug81708.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #81708 (UAF due to php_filter_float() failing for ints)
3+
--EXTENSIONS--
4+
filter
5+
--INI--
6+
opcache.enable_cli=0
7+
--FILE--
8+
<?php
9+
$input = "+" . str_repeat("1", 2); // avoid string interning
10+
filter_var(
11+
$input,
12+
FILTER_VALIDATE_FLOAT,
13+
["options" => ['min_range' => -1, 'max_range' => 1]]
14+
);
15+
var_dump($input);
16+
?>
17+
--EXPECT--
18+
string(3) "+11"

0 commit comments

Comments
 (0)