diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2018-03-07 18:08:15 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-03-07 18:08:15 +0300 |
commit | 4de52a0fe1009d2a5318a731400dbf4280b184cc (patch) | |
tree | bf8e9181b5af45a2f3edf0cdb9fa977d02ec1be7 /winsup/cygwin/fhandler_socket_unix.cc | |
parent | 2f2a75b7bbf521057f3e8e502f1a6641a2baf376 (diff) |
Cygwin: AF_UNIX: fix SEGV when sending an empty socket name from connect
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler_socket_unix.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket_unix.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index f32045361..27ac95876 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -540,15 +540,18 @@ fhandler_socket_unix::set_pipe_non_blocking (bool nonblocking) int fhandler_socket_unix::send_my_name () { + sun_name_t *sun; size_t name_len = 0; af_unix_pkt_hdr_t *packet; NTSTATUS status; IO_STATUS_BLOCK io; AcquireSRWLockShared (&bind_lock); - name_len = get_sun_path ()->un_len; + sun = get_sun_path (); + name_len = sun ? sun->un_len : 0; packet = (af_unix_pkt_hdr_t *) alloca (sizeof *packet + name_len); - memcpy (AF_UNIX_PKT_NAME (packet), &get_sun_path ()->un, name_len); + if (sun) + memcpy (AF_UNIX_PKT_NAME (packet), &sun->un, name_len); ReleaseSRWLockShared (&bind_lock); packet->init (0, name_len, 0, 0); |