[PATCH] fhandler_pipe: add sanity limit to handle loops
Jeremy Drake
cygwin@jdrake.com
Thu Dec 23 23:10:49 GMT 2021
Attempt to avoid an exception I caught once in gdb, trying to debug
msys2/MSYS2-packages#2752. Unfortunately I haven't been able to catch it
in the act again since, but with this change running on Windows on ARM64
has been more reliable than it had been.
---
winsup/cygwin/fhandler_pipe.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/fhandler_pipe.cc
b/winsup/cygwin/fhandler_pipe.cc
index ba6b70f55..48713a38d 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -1239,7 +1239,7 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name,
if (!NT_SUCCESS (status))
goto close_proc;
- for (ULONG j = 0; j < phi->NumberOfHandles; j++)
+ for (ULONG j = 0; j < min(phi->NumberOfHandles, n_handle); j++)
{
/* Check for the peculiarity of cygwin read pipe */
const ULONG access = FILE_READ_DATA | FILE_READ_EA
@@ -1309,7 +1309,7 @@ fhandler_pipe::get_query_hdl_per_system (WCHAR *name,
if (!NT_SUCCESS (status))
return NULL;
- for (LONG i = (LONG) shi->NumberOfHandles - 1; i >= 0; i--)
+ for (LONG i = (LONG) min(shi->NumberOfHandles, n_handle) - 1; i >= 0; i--)
{
/* Check for the peculiarity of cygwin read pipe */
const ULONG access = FILE_READ_DATA | FILE_READ_EA
--
2.34.1.windows.1
-------------- next part --------------
From aba830150ebb1707c66acdad8254728c5f962705 Mon Sep 17 00:00:00 2001
From: Jeremy Drake <cygwin@jdrake.com>
Date: Thu, 23 Dec 2021 12:22:46 -0800
Subject: [PATCH] fhandler_pipe: add sanity limit to handle loops
Attempt to avoid an exception I caught once in gdb, trying to debug msys2/MSYS2-packages#2752
---
winsup/cygwin/fhandler_pipe.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
index ba6b70f55..48713a38d 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -1239,7 +1239,7 @@ fhandler_pipe::get_query_hdl_per_process (WCHAR *name,
if (!NT_SUCCESS (status))
goto close_proc;
- for (ULONG j = 0; j < phi->NumberOfHandles; j++)
+ for (ULONG j = 0; j < min(phi->NumberOfHandles, n_handle); j++)
{
/* Check for the peculiarity of cygwin read pipe */
const ULONG access = FILE_READ_DATA | FILE_READ_EA
@@ -1309,7 +1309,7 @@ fhandler_pipe::get_query_hdl_per_system (WCHAR *name,
if (!NT_SUCCESS (status))
return NULL;
- for (LONG i = (LONG) shi->NumberOfHandles - 1; i >= 0; i--)
+ for (LONG i = (LONG) min(shi->NumberOfHandles, n_handle) - 1; i >= 0; i--)
{
/* Check for the peculiarity of cygwin read pipe */
const ULONG access = FILE_READ_DATA | FILE_READ_EA
--
2.34.1.windows.1
More information about the Cygwin-patches
mailing list