Skip to content

Commit efc4203

Browse files
authored
ext/pcntl: Ensure $array is a list array in pcntl_exec (#21951)
1 parent de90598 commit efc4203

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ PHP NEWS
8585
list of candidate encodings (with 200,000+ entries). (Jordi Kroon)
8686
. mbregex has been deprecated. (youkidearitai)
8787

88+
- PCNTL:
89+
. pcntl_exec() now throws a ValueError if the $args array is not a list
90+
array. (Weilin Du)
91+
8892
- Mysqli:
8993
. Added mysqli_quote_string() and mysqli::quote_string(). (Kamil Tekiela)
9094

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ PHP 8.6 UPGRADE NOTES
3737
- PCNTL:
3838
. pcntl_alarm() now raises a ValueError if the seconds argument is
3939
lower than zero or greater than platform's UINT_MAX.
40+
. pcntl_exec() now raises a ValueError if the $args argument is not a list
41+
array.
4042

4143
- PCRE:
4244
. preg_grep() now returns false instead of a partial array when a PCRE

ext/pcntl/pcntl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,11 @@ PHP_FUNCTION(pcntl_exec)
675675
ZEND_PARSE_PARAMETERS_END();
676676

677677
if (args != NULL) {
678-
// TODO Check array is a list?
678+
if (!zend_array_is_list(Z_ARRVAL_P(args))) {
679+
zend_argument_value_error(2, "must be a list array");
680+
RETURN_THROWS();
681+
}
682+
679683
/* Build argument list */
680684
SEPARATE_ARRAY(args);
681685
const HashTable *args_ht = Z_ARRVAL_P(args);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
pcntl_exec(): Argument array must be a list
3+
--EXTENSIONS--
4+
pcntl
5+
--FILE--
6+
<?php
7+
try {
8+
pcntl_exec('cmd', ['opt' => '-n']);
9+
} catch (Throwable $e) {
10+
echo $e::class, ': ', $e->getMessage(), "\n";
11+
}
12+
?>
13+
--EXPECT--
14+
ValueError: pcntl_exec(): Argument #2 ($args) must be a list array

0 commit comments

Comments
 (0)