Skip to content

Commit 6ec6987

Browse files
committed
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.
1 parent 171f81f commit 6ec6987

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ PHP NEWS
9595
when getpwnam_r() needs a larger buffer. (Ilia Alshanetsky)
9696
. Fixed password_get_info() and password_needs_rehash() accepting malformed
9797
bcrypt costs. (Ilia Alshanetsky)
98+
. Fixed proc_open() null descriptor not being inheritable on Windows.
99+
(Jorg Sowa)
98100

99101
- Tidy:
100102
. Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and

‎ext/standard/proc_open.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static zend_result set_proc_descriptor_to_blackhole(descriptorspec_item *desc)
845845
{
846846
#ifdef PHP_WIN32
847847
desc->childend = CreateFileA("nul", GENERIC_READ | GENERIC_WRITE,
848-
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
848+
FILE_SHARE_READ | FILE_SHARE_WRITE, &php_proc_open_security, OPEN_EXISTING, 0, NULL);
849849
if (desc->childend == INVALID_HANDLE_VALUE) {
850850
php_error_docref(NULL, E_WARNING, "Failed to open nul");
851851
return FAILURE;

0 commit comments

Comments
 (0)