Cygwin: proc fd: return EACCES for HANDLE-less fds

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2019-01-13 23:09:48 +01:00
parent 7f60199032
commit 8ae26f96ae
1 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,13 @@ fhandler_process_fd::fetch_fh (HANDLE &out_hdl, uint32_t flags)
} }
hdl = pc.deserialize (buf); hdl = pc.deserialize (buf);
} }
if (hdl == NULL)
{
if (proc != GetCurrentProcess ())
CloseHandle (proc);
set_errno (EACCES);
return NULL;
}
BOOL ret = DuplicateHandle (proc, hdl, GetCurrentProcess (), &hdl, BOOL ret = DuplicateHandle (proc, hdl, GetCurrentProcess (), &hdl,
0, FALSE, DUPLICATE_SAME_ACCESS); 0, FALSE, DUPLICATE_SAME_ACCESS);
if (proc != GetCurrentProcess ()) if (proc != GetCurrentProcess ())