From d52a6fd23cef2412d6def44ff9c59abb96982efb Mon Sep 17 00:00:00 2001 From: david Date: Tue, 27 Nov 2012 21:47:25 +0000 Subject: [PATCH] Straighten out port computation in nsock_connect_internal. There was a bug here where AF_INET6 was used instead of AF_UNIX in the HAVE_SYS_UN_H section. This masked another bug, which was that the HAVE_SYS_UN_H section inadvertently extended into what was supposed to be the HAVE_IPV6 section. --- nsock/src/nsock_connect.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nsock/src/nsock_connect.c b/nsock/src/nsock_connect.c index dfe079908..a2f4fccd1 100644 --- a/nsock/src/nsock_connect.c +++ b/nsock/src/nsock_connect.c @@ -153,17 +153,18 @@ void nsock_connect_internal(mspool *ms, msevent *nse, int type, int proto, struc } else { if (ss->ss_family == AF_INET) { sin->sin_port = htons(port); -#if HAVE_SYS_UN_H - } else if (ss->ss_family == AF_INET6) { -#else - } else { -#endif - assert(ss->ss_family == AF_INET6); + } #if HAVE_IPV6 + else if (ss->ss_family == AF_INET6) { sin6->sin6_port = htons(port); -#else - fatal("IPv6 address passed to nsock_connect_* call, but nsock was not compiled w/IPv6 support"); + } #endif +#if HAVE_SYS_UN_H + else if (ss->ss_family == AF_UNIX) { + } +#endif + else { + fatal("Unknown address family %d\n", ss->ss_family); } assert(sslen <= sizeof(iod->peer));