From: Giang Nguyen <nen24t@gmail.com> Windows reports AF_UNIX with an empty path for a socket that was never bound, and for the peer of an accepted connection whose client never bound. Both structures were left zeroed, so getsockname() and getpeername() returned family 0. init_socket() now presets sun_family and the full length for WS_AF_UNIX, which covers both cases: the unbound client socket, and the accept path that copies the listener's never populated peer address. Only the WS_AF_UNIX branch is touched; every other family keeps the zeroed structure it had. ws2_32:sock test_afunix: 24 failing assertions down to 16, clearing sock.c:14658 and sock.c:14693. Signed-off-by: Giang Nguyen <nen24t@gmail.com> --- server/sock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/sock.c b/server/sock.c index c53f55533bc..e42612a0ecc 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2035,6 +2035,18 @@ static int init_socket( struct sock *sock, int family, int type, int protocol ) sock->type = type; sock->family = family; + /* Windows reports AF_UNIX with an empty path for an unbound socket, so the + * family has to be present before bind() ever runs. */ + if (family == WS_AF_UNIX) + { + memset( &sock->addr.un, 0, sizeof(sock->addr.un) ); + sock->addr.un.sun_family = WS_AF_UNIX; + sock->addr_len = sizeof(sock->addr.un); + memset( &sock->peer_addr.un, 0, sizeof(sock->peer_addr.un) ); + sock->peer_addr.un.sun_family = WS_AF_UNIX; + sock->peer_addr_len = sizeof(sock->peer_addr.un); + } + if (is_tcp_socket( sock )) { value = 1; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7650