From 5b1efaee67044b56f6ecac1ee70883bfc61f8c5d Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Mon, 14 Sep 2009 01:23:19 +0200 Subject: 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(). --- src/ipaddr/ng_ipaddr.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ipaddr/ng_ipaddr.c b/src/ipaddr/ng_ipaddr.c index 0367a1f7..4f1d4ca4 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) -- cgit 1.4.1