Skip to content

Commit ac84641

Browse files
committed
initial fix
1 parent 0471420 commit ac84641

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ PHP NEWS
174174
(Weilin Du)
175175
. getenv() and putenv() now raises a ValueError when the first argument
176176
contains null bytes. (Weilin Du)
177+
. proc_open() now raises a ValueError when the $cwd argument contains
178+
null bytes. (Weilin Du)
177179

178180
- Streams:
179181
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ PHP 8.6 UPGRADE NOTES
9595
argument value is passed.
9696
. scandir() now raises a ValueError when an invalid $sorting_order
9797
argument value is passed.
98+
. proc_open() now raises a ValueError when the $cwd argument contains
99+
null bytes.
98100

99101
- Zip:
100102
. ZipArchive::extractTo now raises a TypeError for the

ext/standard/proc_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ PHP_FUNCTION(proc_open)
12401240
Z_PARAM_ARRAY_HT(descriptorspec)
12411241
Z_PARAM_ZVAL(pipes)
12421242
Z_PARAM_OPTIONAL
1243-
Z_PARAM_STRING_OR_NULL(cwd, cwd_len)
1243+
Z_PARAM_PATH_OR_NULL(cwd, cwd_len)
12441244
Z_PARAM_ARRAY_HT_OR_NULL(environment)
12451245
Z_PARAM_ARRAY_OR_NULL(other_options)
12461246
ZEND_PARSE_PARAMETERS_END();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
proc_open() rejects null bytes in cwd
3+
--SKIPIF--
4+
<?php
5+
if (!function_exists("proc_open")) echo "skip proc_open() is not available";
6+
?>
7+
--FILE--
8+
<?php
9+
10+
try {
11+
proc_open("does_not_matter", [], $pipes, "foo\0bar");
12+
} catch (ValueError $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
proc_open(): Argument #4 ($cwd) must not contain any null bytes

0 commit comments

Comments
 (0)