-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a stack limit check in zend_vm_call_opcode_handler for SAPIs that do not use execute_ex().
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--TEST-- | ||
GH-16041 001: Stack overflow in phpdbg | ||
--SKIPIF-- | ||
<?php | ||
if (ini_get('zend.max_allowed_stack_size') === false) { | ||
die('skip No stack limit support'); | ||
} | ||
?> | ||
--INI-- | ||
zend.max_allowed_stack_size=512K | ||
--PHPDBG-- | ||
set pagination off | ||
run | ||
continue | ||
quit | ||
--FILE-- | ||
<?php | ||
|
||
class Canary { | ||
public function __destruct() { | ||
new Canary(); | ||
} | ||
} | ||
|
||
new Canary(); | ||
|
||
?> | ||
--EXPECTF-- | ||
[Successful compilation of %sgh16041_001.php] | ||
prompt> prompt> [Uncaught Error in %s on line %d: Maximum call stack size of %d bytes%s | ||
>00005: new Canary(); | ||
00006: } | ||
00007: } | ||
prompt> [Uncaught Error in %s on line %d] | ||
Error: Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? in %s:%d | ||
Stack trace: | ||
#0 %s(%d): Canary->__destruct() | ||
%a | ||
prompt> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--TEST-- | ||
GH-16041 002: Stack overflow in phpdbg | ||
--SKIPIF-- | ||
<?php | ||
if (ini_get('zend.max_allowed_stack_size') === false) { | ||
die('skip No stack limit support'); | ||
} | ||
?> | ||
--INI-- | ||
zend.max_allowed_stack_size=512K | ||
--PHPDBG-- | ||
set pagination off | ||
run | ||
quit | ||
--FILE-- | ||
<?php | ||
|
||
function map() { | ||
array_map('map', [1]); | ||
} | ||
|
||
try { | ||
map(); | ||
} catch (\Throwable $e) { | ||
printf("%s: %s\n", $e::class, $e->getMessage()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
[Successful compilation of %sgh16041_002.php] | ||
prompt> prompt> Error: Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? | ||
[Script ended normally] | ||
prompt> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters