Skip to content

Commit 2dfd2b9

Browse files
committed
Fix GH-16266: Passing unknown named parameter may segfault
We must not assume that an internal function has arg_info; that is at least not given for internal classes implementing the magic `__call()` method. In such cases we cannot look up the parameter offset by name, and raise a fatal error.
1 parent a5e8ac6 commit 2dfd2b9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Zend/tests/gh16266.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-16266 (Passing unknown named parameter may segfault)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
$o = new _ZendTestClass();
8+
var_dump($o->test('a', 'b', c: 'c'));
9+
?>
10+
--EXPECTF--
11+
Fatal error: Uncaught Error: Unknown named parameter $c in %s:%d
12+
%A

Zend/zend_execute.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,9 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name(
49454945
}
49464946
}
49474947
} else {
4948+
if (fbc->internal_function.arg_info == NULL) {
4949+
return (uint32_t) -1;
4950+
}
49484951
for (uint32_t i = 0; i < num_args; i++) {
49494952
zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i];
49504953
size_t len = strlen(arg_info->name);

0 commit comments

Comments
 (0)