1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fixed GH-12564: The negative fiber.stack_size setting leads to crash
This commit is contained in:
Dmitry Stogov
2023-11-01 16:26:32 +03:00
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
--TEST--
fiber.stack_size must be a positive number
--FILE--
<?php
ini_set("fiber.stack_size","-1");
$fiber = new Fiber(function() {});
try {
$fiber->start();
} catch (Throwable $e) {
echo "Exception: " . $e->getMessage()."\n";
}
?>
DONE
--EXPECTF--
Warning: fiber.stack_size must be a positive number in %snegative_stack_size.php on line 2
DONE

View File

@@ -177,7 +177,12 @@ static ZEND_INI_MH(OnSetExceptionStringParamMaxLen) /* {{{ */
static ZEND_INI_MH(OnUpdateFiberStackSize) /* {{{ */
{
if (new_value) {
EG(fiber_stack_size) = zend_ini_parse_quantity_warn(new_value, entry->name);
zend_long tmp = zend_ini_parse_quantity_warn(new_value, entry->name);
if (tmp < 0) {
zend_error(E_WARNING, "fiber.stack_size must be a positive number");
return FAILURE;
}
EG(fiber_stack_size) = tmp;
} else {
EG(fiber_stack_size) = ZEND_FIBER_DEFAULT_C_STACK_SIZE;
}