[php-src] PHP-8.5: Fix proc_open() null descriptor not inheritable on Windows
| From: | Jorg Sowa | Date: | Fri, 16 Oct 2026 18:27:16 +0000 |
| Subject: | [php-src] PHP-8.5: Fix proc_open() null descriptor not inheritable on Windows | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142363@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-10-16T20:22:16+02:00
Commit: https://github.com/php/php-src/commit/6ec698758e50d0356a7befeca6b2bfaffffa15aa
Raw diff: https://github.com/php/php-src/commit/6ec698758e50d0356a7befeca6b2bfaffffa15aa.diff
Fix proc_open() null descriptor not inheritable on Windows
The nul handle was opened without security attributes, making it
non-inheritable. It was then passed to CreateProcess() via
STARTF_USESTDHANDLES, where the child cannot use a non-inheritable
handle. Use php_proc_open_security so the handle is inheritable, like
the pipe handles.
Closes GH-24335.
Changed paths:
M NEWS
M ext/standard/proc_open.c
Diff:
diff --git a/NEWS b/NEWS
index 1d855a4b1ec4..aa752e0af386 100644
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,8 @@ PHP NEWS
when getpwnam_r() needs a larger buffer. (Ilia Alshanetsky)
. Fixed password_get_info() and password_needs_rehash() accepting malformed
bcrypt costs. (Ilia Alshanetsky)
+ . Fixed proc_open() null descriptor not being inheritable on Windows.
+ (Jorg Sowa)
- Tidy:
. Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 54a523a42919..ed01405e840e 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -845,7 +845,7 @@ static zend_result set_proc_descriptor_to_blackhole(descriptorspec_item *desc)
{
#ifdef PHP_WIN32
desc->childend = CreateFileA("nul", GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &php_proc_open_security, OPEN_EXISTING, 0, NULL);
if (desc->childend == INVALID_HANDLE_VALUE) {
php_error_docref(NULL, E_WARNING, "Failed to open nul");
return FAILURE;