https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8ae26f96ae710f8562162fd5d4e9a5d7434beb7b
commit 8ae26f96ae710f8562162fd5d4e9a5d7434beb7b Author: Corinna Vinschen <[email protected]> Date: Sun Jan 13 23:09:48 2019 +0100 Cygwin: proc fd: return EACCES for HANDLE-less fds Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/fhandler_process_fd.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/winsup/cygwin/fhandler_process_fd.cc b/winsup/cygwin/fhandler_process_fd.cc index a3691d9..a33fd75 100644 --- a/winsup/cygwin/fhandler_process_fd.cc +++ b/winsup/cygwin/fhandler_process_fd.cc @@ -69,6 +69,13 @@ fhandler_process_fd::fetch_fh (HANDLE &out_hdl, uint32_t flags) } hdl = pc.deserialize (buf); } + if (hdl == NULL) + { + if (proc != GetCurrentProcess ()) + CloseHandle (proc); + set_errno (EACCES); + return NULL; + } BOOL ret = DuplicateHandle (proc, hdl, GetCurrentProcess (), &hdl, 0, FALSE, DUPLICATE_SAME_ACCESS); if (proc != GetCurrentProcess ())
