From a45c91ec6aff3ff40462258f4527fe4a57991955 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Nov 2007 14:22:19 -0700 Subject: Ensure we use the correct socklen_t values for bind() for Solaris. Jeremy. (This used to be commit 638579d75a2aa00836dc4c0c772381b775944b16) --- source3/lib/util_sock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/lib/util_sock.c') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index b4fda54ebd..4a73f92bd8 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1325,12 +1325,14 @@ int open_socket_in(int type, { struct sockaddr_storage sock; int res; + socklen_t slen = sizeof(struct sockaddr_in); sock = *psock; #if defined(HAVE_IPV6) if (sock.ss_family == AF_INET6) { ((struct sockaddr_in6 *)&sock)->sin6_port = htons(port); + slen = sizeof(struct sockaddr_in6); } #endif if (sock.ss_family == AF_INET) { @@ -1374,7 +1376,7 @@ int open_socket_in(int type, } /* now we've got a socket - we need to bind it */ - if( bind( res, (struct sockaddr *)&sock, sizeof(sock) ) == -1 ) { + if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) { if( DEBUGLVL(dlevel) && (port == SMB_PORT1 || port == SMB_PORT2 || port == NMB_PORT) ) { char addr[INET6_ADDRSTRLEN]; -- cgit