From 0f800bf44a126cb5d9bf66dce68d8a6effe2cfd7 Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Wed, 7 Oct 2020 07:07:18 -0400 Subject: [PATCH] Cygwin: AF_UNIX: accept4: copy trailing NUL byte If the caller has requested the peer's address, include the trailing NUL byte of the address if possible. --- winsup/cygwin/fhandler_socket_unix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index b44f36a0a..a1d7cb49a 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -1665,7 +1665,7 @@ fhandler_socket_unix::accept4 (struct sockaddr *peer, int *len, int flags) if (sun) { memcpy (peer, &sun->un, - MIN (*len, sun->un_len)); + MIN (*len, sun->un_len + 1)); *len = sun->un_len; } else if (len)