Skip to content

Commit 772bb05

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix three Win32-only defects in proc_open descriptor handling
2 parents 1e8f7ee + 6baec62 commit 772bb05

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ PHP NEWS
7474
- Standard:
7575
. Fixed bug #60110 (fclose(), file_put_contents(), copy() do not return false
7676
properly). (Jakub Zelenka, Ilija Tovilo)
77+
. Fixed three Windows-only proc_open() defects: an uninitialized
78+
PROCESS_INFORMATION, an indeterminate comspec pointer after a failed
79+
lookup, and an unchecked CreateFileA() failure. (Ilia Alshanetsky)
7780

7881

7982
10 Sep 2026, PHP 8.6.0beta3

‎ext/standard/proc_open.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static void init_startup_info(STARTUPINFOW *si, descriptorspec_item *descriptors
706706

707707
static void init_process_info(PROCESS_INFORMATION *pi)
708708
{
709-
memset(&pi, 0, sizeof(pi));
709+
memset(pi, 0, sizeof(*pi));
710710
}
711711

712712
/* on success, returns length of *comspec, which then needs to be efree'd by caller */
@@ -757,7 +757,7 @@ static size_t find_comspec_nt(wchar_t **comspec)
757757

758758
static zend_result convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
759759
{
760-
wchar_t *comspec;
760+
wchar_t *comspec = NULL;
761761
size_t len = find_comspec_nt(&comspec);
762762
if (len == 0) {
763763
php_error_docref(NULL, E_WARNING, "Command conversion failed");
@@ -842,7 +842,7 @@ static zend_result set_proc_descriptor_to_blackhole(descriptorspec_item *desc)
842842
#ifdef PHP_WIN32
843843
desc->childend = CreateFileA("nul", GENERIC_READ | GENERIC_WRITE,
844844
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
845-
if (desc->childend == NULL) {
845+
if (desc->childend == INVALID_HANDLE_VALUE) {
846846
php_error_docref(NULL, E_WARNING, "Failed to open nul");
847847
return FAILURE;
848848
}

0 commit comments

Comments
 (0)