From 1c367b06fcaee62f8d1fafeb7d6f15993aa277e8 Mon Sep 17 00:00:00 2001 From: Bjoern Jacke Date: Tue, 17 Aug 2021 11:39:24 +0000 Subject: [PATCH] util_sock: fix assignment of sa_socklen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Metzmacher Reviewed-by: Bjoern Jacke Reviewed-by: Volker Lendecke BUG: https://bugzilla.samba.org/show_bug.cgi?id=14800 Autobuild-User(master): Björn Jacke Autobuild-Date(master): Tue Aug 31 09:54:35 UTC 2021 on sn-devel-184 (cherry picked from commit 1209c89dcf6371bbfa4f3929a47a573ef2916c1a) --- source3/lib/util_sock.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 2dbb572a974..85dc3efbe15 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -254,6 +254,15 @@ int open_socket_in( int val = rebind ? 1 : 0; bool ok; + switch (addr.u.sa.sa_family) { + case AF_INET6: + addr.sa_socklen = sizeof(struct sockaddr_in6); + break; + case AF_INET: + addr.sa_socklen = sizeof(struct sockaddr_in); + break; + } + ok = samba_sockaddr_set_port(&addr, port); if (!ok) { ret = -EINVAL; -- 2.20.2