Check stack limit in fuzzer executor

The stack limit is checked when entering execute_ex(), but the fuzzer has
its own execute function and does not call execute_ex().

Add a stack limit check in the fuzzer's execute function.

Closes GH-19391
This commit is contained in:
Arnaud Le Blanc 2025-08-06 17:40:53 +02:00
parent c42e6d62d8
commit d1fceeec30
No known key found for this signature in database

View file

@ -53,7 +53,18 @@ static zend_always_inline void fuzzer_step(void) {
static void (*orig_execute_ex)(zend_execute_data *execute_data); static void (*orig_execute_ex)(zend_execute_data *execute_data);
static void fuzzer_execute_ex(zend_execute_data *execute_data) { static void fuzzer_execute_ex(zend_execute_data *execute_data) {
#ifdef ZEND_CHECK_STACK_LIMIT
if (UNEXPECTED(zend_call_stack_overflowed(EG(stack_limit)))) {
zend_call_stack_size_error();
/* No opline was executed before exception */
EG(opline_before_exception) = NULL;
/* Fall through to handle exception below. */
}
#endif /* ZEND_CHECK_STACK_LIMIT */
const zend_op *opline = EX(opline); const zend_op *opline = EX(opline);
while (1) { while (1) {
fuzzer_step(); fuzzer_step();
opline = ((opcode_handler_t) opline->handler)(execute_data, opline); opline = ((opcode_handler_t) opline->handler)(execute_data, opline);