diff --git a/NEWS b/NEWS index fe70343e8398..4ace7d3dc462 100644 --- a/NEWS +++ b/NEWS @@ -99,6 +99,10 @@ PHP NEWS . Added TLS session resumption support for streams with new context options and Openssl\Session class. (Jakub Zelenka) +- PCNTL: + . pcntl_exec() now throws a ValueError if the $args array is not a list + array. (Weilin Du) + - PDO_DBLIB; . Added dblib_handle_check_liveness handler. (freddy77) diff --git a/UPGRADING b/UPGRADING index fe44036383d0..d271eb47f7d1 100644 --- a/UPGRADING +++ b/UPGRADING @@ -37,6 +37,8 @@ PHP 8.6 UPGRADE NOTES - PCNTL: . pcntl_alarm() now raises a ValueError if the seconds argument is lower than zero or greater than platform's UINT_MAX. + . pcntl_exec() now raises a ValueError if the $args argument is not a list + array. - PCRE: . preg_grep() now returns false instead of a partial array when a PCRE diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index e9453b21329e..2ba732c4540e 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -675,7 +675,11 @@ PHP_FUNCTION(pcntl_exec) ZEND_PARSE_PARAMETERS_END(); if (args != NULL) { - // TODO Check array is a list? + if (!zend_array_is_list(Z_ARRVAL_P(args))) { + zend_argument_value_error(2, "must be a list array"); + RETURN_THROWS(); + } + /* Build argument list */ SEPARATE_ARRAY(args); const HashTable *args_ht = Z_ARRVAL_P(args); diff --git a/ext/pcntl/tests/pcntl_exec_list_args.phpt b/ext/pcntl/tests/pcntl_exec_list_args.phpt new file mode 100644 index 000000000000..5cd8c0fbe228 --- /dev/null +++ b/ext/pcntl/tests/pcntl_exec_list_args.phpt @@ -0,0 +1,14 @@ +--TEST-- +pcntl_exec(): Argument array must be a list +--EXTENSIONS-- +pcntl +--FILE-- + '-n']); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} +?> +--EXPECT-- +ValueError: pcntl_exec(): Argument #2 ($args) must be a list array