Skip to content

Fix #71868: Environment variables with no value are filtered out by proc_open() #7927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ext/standard/proc_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ static php_process_env _php_array_to_envp(zval *environment)
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(environment), key, element) {
str = zval_get_string(element);

if (ZSTR_LEN(str) == 0) {
zend_string_release_ex(str, 0);
continue;
}

sizeenv += ZSTR_LEN(str) + 1;

if (key && ZSTR_LEN(key)) {
Expand Down
4 changes: 4 additions & 0 deletions ext/standard/tests/general_functions/bug71868.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
var_dump(isset($_SERVER['FOO']));
var_dump($_SERVER['FOO']);
?>
24 changes: 24 additions & 0 deletions ext/standard/tests/general_functions/bug71868.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Bug #71868: Environment variables with no value are filtered out by proc_open()
--SKIPIF--
<?php
if (!function_exists('proc_open')) die('skip proc_open() not available');
?>
--FILE--
<?php
$callee = __DIR__ . DIRECTORY_SEPARATOR . "bug71868.inc";
$php = getenv('TEST_PHP_EXECUTABLE');
$cmd = "$php -n $callee";

$descriptors = array();
$pipes = array();

$cwd = __DIR__;
$env = array('FOO' => '');

$process = proc_open($cmd, $descriptors, $pipes, $cwd, $env);
proc_close($process);
?>
--EXPECT--
bool(true)
string(0) ""