From 8ae26f96ae710f8562162fd5d4e9a5d7434beb7b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 13 Jan 2019 23:09:48 +0100 Subject: [PATCH] Cygwin: proc fd: return EACCES for HANDLE-less fds Signed-off-by: Corinna Vinschen --- 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 a3691d9c8..a33fd7539 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 ())