Skip to content

Commit b7ae5e0

Browse files
committed
Fixed bug #61273 (call_user_func_array with more than 16333 arguments leaks / crashes)
1 parent 49e9d8f commit b7ae5e0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PHP NEWS
88
. "Connection: close" instead of "Connection: closed" (Gustavo)
99

1010
- Core:
11+
. Fixed bug #61273 (call_user_func_array with more than 16333 arguments
12+
leaks / crashes). (Laruence)
1113
. Fixed bug #61225 (Incorect lexing of 0b00*+<NUM>). (Pierrick)
1214
. Fixed bug #61165 (Segfault - strip_tags()). (Laruence)
1315
. Fixed bug #61106 (Segfault when using header_register_callback). (Nikita

Zend/tests/bug61273.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #61273 (call_user_func_array with more than 16333 arguments leaks / crashes)
3+
--FILE--
4+
<?php
5+
/**
6+
* for 5.3 #define ZEND_VM_STACK_PAGE_SIZE ((64 * 1024) - 64)
7+
* for 5.4 #define ZEND_VM_STACK_PAGE_SIZE ((16 * 1024) - 16)
8+
* we should trick EG(argument_stack) into growing
9+
*/
10+
$args = array_fill(0, 64 * 1024 - 64, "*");
11+
call_user_func_array(function(&$a) {}, $args);
12+
echo strval("okey");
13+
--EXPECTF--
14+
Warning: Parameter 1 to {closure}() expected to be a reference, value given in %sbug61273.php on line %d
15+
okey

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
859859

860860
if (fci->no_separation &&
861861
!ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
862-
if(i) {
862+
if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) {
863863
/* hack to clean up the stack */
864864
zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);
865865
zend_vm_stack_clear_multiple(TSRMLS_C);

0 commit comments

Comments
 (0)