diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2020-02-28 12:39:41 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-02-28 12:41:05 +0100 |
commit | 92b8b300c26c20ea441f69b36da9a838aa85c2d8 (patch) | |
tree | 97a1c649a4f7026dc81e6cebdb3f43f2d2e3087e | |
parent | ba2f251d439294c7087f3a38a8d407c95cdc5c1e (diff) | |
download | newlib-92b8b300c26c20ea441f69b36da9a838aa85c2d8.zip newlib-92b8b300c26c20ea441f69b36da9a838aa85c2d8.tar.gz newlib-92b8b300c26c20ea441f69b36da9a838aa85c2d8.tar.bz2 |
Cygwin: AF_UNIX: fix creating shared mem region in dup
reopen_shmem is accidentally called on the parent fhandler
rather than the child fhandler, and it's called too early.
Make sure to call it on the child and only after its shmem_handle
is valid.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler_socket_unix.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index eea7e76..824bcba 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -1201,12 +1201,6 @@ fhandler_socket_unix::dup (fhandler_base *child, int flags) return -1; } fhandler_socket_unix *fhs = (fhandler_socket_unix *) child; - if (reopen_shmem () < 0) - { - __seterrno (); - fhs->close (); - return -1; - } if (backing_file_handle && backing_file_handle != INVALID_HANDLE_VALUE && !DuplicateHandle (GetCurrentProcess (), backing_file_handle, GetCurrentProcess (), &fhs->backing_file_handle, @@ -1224,6 +1218,12 @@ fhandler_socket_unix::dup (fhandler_base *child, int flags) fhs->close (); return -1; } + if (fhs->reopen_shmem () < 0) + { + __seterrno (); + fhs->close (); + return -1; + } fhs->sun_path (sun_path ()); fhs->peer_sun_path (peer_sun_path ()); fhs->connect_wait_thr = NULL; |