From 4c1a288f6347522600c9f3561be62c002c631b30 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 7 Feb 2022 19:14:45 +0300 Subject: [PATCH] server: Always update cached socket name after connect. Fixes a regression introduced by 5c009c17b3a212c3f5b0034c465077c0c593daae. For IPV6 socket already bound with bind() with IPV6_V6ONLY set to 0 the address returned by getsockname() may change after it is connected to a IPV4 peer (e. g., from :: to ::ffff:192.0.2.128). The effect of blamed commit is that before that Unix getsockname() was called for each ws2_32 getsockname() and after the commit the socket name is cached at bind and connect. Signed-off-by: Paul Gofman Signed-off-by: Alexandre Julliard --- server/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/sock.c b/server/sock.c index 40fb0cac535..512b7c0f78e 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2340,7 +2340,7 @@ static void sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) allow_fd_caching( sock->fd ); unix_len = sizeof(unix_addr); - if (!sock->bound && !getsockname( unix_fd, &unix_addr.addr, &unix_len )) + if (!getsockname( unix_fd, &unix_addr.addr, &unix_len )) sock->addr_len = sockaddr_from_unix( &unix_addr, &sock->addr.addr, sizeof(sock->addr) ); sock->bound = 1;