From f035eceb7249e358aec559fe2d94744d3c17deee Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 13 May 2012 14:06:53 +0000 Subject: [PATCH] Pass the right socket address length to bind() in client connections with IPv6 enabled. This fixes an issue reported by packet, where IPv4 conections don't work on FreeBSD when the client is built with IPv6 support and you have a local hostname set (with /hostname, -H or IRCHOST). Also ensure we clear the full size of the 'server' address structure - doesn't fix a known problem but is a defensive measure. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@181 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 +- source/network.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index dda1b51..506819f 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,7 @@ [Changes 1.2c01] * Fix known problem with IPv6 on FreeBSD and enable IPv6 on all supporting - platforms. Thanks to brabes and snadge. (caf) + platforms. Thanks to brabes, snadge and packet. (caf) * Improve connect() error handling. (caf) diff --git a/source/network.c b/source/network.c index a048e53..2bb20cd 100644 --- a/source/network.c +++ b/source/network.c @@ -520,7 +520,7 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int } #endif - memset(&server, 0, sizeof(struct sockaddr_in)); + memset(&server, 0, sizeof server); #ifndef WINNT #ifdef IPV6 @@ -554,7 +554,7 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int if (LocalHostName && !getaddrinfo(LocalHostName, NULL, &hints, &res) && res) { - if (bind(fd, (struct sockaddr *) res->ai_addr, sizeof(struct sockaddr_foobar))) + if (bind(fd, (struct sockaddr *) res->ai_addr, res->ai_addrlen)) return close(fd), -2; freeaddrinfo(res); }