repo: ngircd
action: commit
revision: 
path_from: 
revision_from: 5b1efaee67044b56f6ecac1ee70883bfc61f8c5d:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit 5b1efaee67044b56f6ecac1ee70883bfc61f8c5d
Author: Alexander Barton 
Date:   Mon Sep 14 01:23:19 2009 +0200

    Check for sockaddr_in.sin_len and initialize it

    Test for sockaddr_in.sin_len and initialize it to the correct value
    which some systems (notably Mac OS X) require.

    Note: this code path is only relevant when not using getaddrinfo().

diff --git a/configure.in b/configure.in
index 567f216a7f1c21175693829ef4ec36300627fc1f..
index ..bfa800b0a73ee1aa8c6140997dd6da17e2c0f256 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
 #
 # ngIRCd -- The Next Generation IRC Daemon
-# Copyright (c)2001-2008 Alexander Barton 
+# Copyright (c)2001-2009 Alexander Barton 
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@ AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
+AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])

 AH_TEMPLATE([TARGET_OS], [Target operating system name])
 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
@@ -124,6 +125,9 @@ AC_TRY_COMPILE([
 AC_TYPE_SIGNAL
 AC_TYPE_SIZE_T

+AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
+ [#include ])
+
 # -- Libraries --

 AC_CHECK_LIB(UTIL,memmove)
diff --git a/src/ipaddr/ng_ipaddr.c b/src/ipaddr/ng_ipaddr.c
index 0367a1f75848b4d9766425d7e6021b3e8f8bf9a9..
index ..4f1d4ca40492562858e87357c107c320b85c48b2 100644
--- a/src/ipaddr/ng_ipaddr.c
+++ b/src/ipaddr/ng_ipaddr.c
@@ -51,6 +51,10 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
 	return ret == 0;
 #else /* HAVE_GETADDRINFO */
 	assert(ip_str);
+	memset(addr, 0, sizeof *addr);
+#ifdef HAVE_sockaddr_in_len
+	addr->sin4.sin_len = sizeof(addr->sin4);
+#endif
 	addr->sin4.sin_family = AF_INET;
 # ifdef HAVE_INET_ATON
 	if (inet_aton(ip_str, &addr->sin4.sin_addr) == 0)

-----END OF PAGE-----