From 7ba2bde90dd3cb0b71b5ce13f8cca24896ecc514 Mon Sep 17 00:00:00 2001 From: Nikita Radchenko Date: Tue, 11 Jan 2022 11:26:22 +0300 Subject: [PATCH] Fix #71868: Environment variables with no value are filtered out by proc_open() Remove empty value check from _php_array_to_envp (introduced in 7e92f63) --- ext/standard/proc_open.c | 5 ---- .../tests/general_functions/bug71868.inc | 4 ++++ .../tests/general_functions/bug71868.phpt | 24 +++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 ext/standard/tests/general_functions/bug71868.inc create mode 100644 ext/standard/tests/general_functions/bug71868.phpt diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 03b55c3eac06a..fd1baa7b7227a 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -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)) { diff --git a/ext/standard/tests/general_functions/bug71868.inc b/ext/standard/tests/general_functions/bug71868.inc new file mode 100644 index 0000000000000..76b0cb0d70eff --- /dev/null +++ b/ext/standard/tests/general_functions/bug71868.inc @@ -0,0 +1,4 @@ + diff --git a/ext/standard/tests/general_functions/bug71868.phpt b/ext/standard/tests/general_functions/bug71868.phpt new file mode 100644 index 0000000000000..04068ea10e081 --- /dev/null +++ b/ext/standard/tests/general_functions/bug71868.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #71868: Environment variables with no value are filtered out by proc_open() +--SKIPIF-- + +--FILE-- + ''); + +$process = proc_open($cmd, $descriptors, $pipes, $cwd, $env); +proc_close($process); +?> +--EXPECT-- +bool(true) +string(0) ""