[newlib-cygwin] Cygwin: proc fd: return EACCES for HANDLE-less fds
Corinna Vinschen
corinna@sourceware.org
Sun Jan 13 22:16:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8ae26f96ae710f8562162fd5d4e9a5d7434beb7b
commit 8ae26f96ae710f8562162fd5d4e9a5d7434beb7b
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sun Jan 13 23:09:48 2019 +0100
Cygwin: proc fd: return EACCES for HANDLE-less fds
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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 ())
More information about the Cygwin-cvs
mailing list