Skip to content

Commit 17d2917

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-12655: proc_open() does not take into account references in the descriptor array
2 parents cc2bf11 + 5c25742 commit 17d2917

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/standard/proc_open.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ PHP_FUNCTION(proc_open)
11731173

11741174
descriptors[ndesc].index = (int)nindex;
11751175

1176+
ZVAL_DEREF(descitem);
11761177
if (Z_TYPE_P(descitem) == IS_RESOURCE) {
11771178
if (set_proc_descriptor_from_resource(descitem, &descriptors[ndesc], ndesc) == FAILURE) {
11781179
goto exit_fail;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-12655 (proc_open(): Argument #2 ($descriptor_spec) must only contain arrays and streams [Descriptor item must be either an array or a File-Handle])
3+
--FILE--
4+
<?php
5+
6+
$descriptor_spec = [
7+
0 => [ "pipe", "r" ], // stdin is a pipe that the child will read from
8+
1 => [ "pipe", "w" ], // stdout is a pipe that the child will write to
9+
2 => [ "pipe", "w" ], // stderr is a file to write to
10+
];
11+
12+
foreach ( $descriptor_spec as $fd => &$d )
13+
{
14+
// don't do anything, just the fact that we used "&$d" will sink the ship!
15+
}
16+
17+
$proc = proc_open(PHP_BINARY, $descriptor_spec, $pipes);
18+
echo $proc === false ? "FAILED\n" : "SUCCEEDED\n";
19+
20+
?>
21+
--EXPECT--
22+
SUCCEEDED

0 commit comments

Comments
 (0)