diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-01-02 20:57:10 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-01-02 20:57:10 +0000 |
commit | 9c20441bcbf835ed45f5afcc1a8e52cc7dce2563 (patch) | |
tree | 2a58466e5d4391eff8e34c17dc158723c956bacf /src | |
parent | 89d268848f769f761f9cd128aa401c38ab470c74 (diff) | |
download | tor-9c20441bcbf835ed45f5afcc1a8e52cc7dce2563.tar.gz tor-9c20441bcbf835ed45f5afcc1a8e52cc7dce2563.zip |
Only set sin_len/sin6_len when they exist.
svn:r17851
Diffstat (limited to 'src')
-rw-r--r-- | src/common/address.c | 4 | ||||
-rw-r--r-- | src/or/eventdns.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c index 1abd1a7dfb..2dd763da99 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -69,7 +69,9 @@ tor_addr_to_sockaddr(const tor_addr_t *a, return -1; sin = (struct sockaddr_in *)sa_out; memset(sin, 0, sizeof(struct sockaddr_in)); +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sin->sin_len = sizeof(struct sockaddr_in); +#endif sin->sin_family = AF_INET; sin->sin_port = htons(port); sin->sin_addr.s_addr = tor_addr_to_ipv4n(a); @@ -80,7 +82,9 @@ tor_addr_to_sockaddr(const tor_addr_t *a, return -1; sin6 = (struct sockaddr_in6 *)sa_out; memset(sin6, 0, sizeof(struct sockaddr_in6)); +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif sin6->sin6_family = AF_INET6; sin6->sin6_port = htons(port); memcpy(&sin6->sin6_addr, tor_addr_to_in6(a), sizeof(struct in6_addr)); diff --git a/src/or/eventdns.c b/src/or/eventdns.c index 248422d22a..6b61758210 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -2302,7 +2302,9 @@ evdns_nameserver_add(unsigned long int address) { struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sin.sin_len = sizeof(sin); +#endif sin.sin_addr.s_addr = htonl(address); sin.sin_port = 53; return _evdns_nameserver_add_impl((struct sockaddr*) &sin, sizeof(sin)); @@ -2381,7 +2383,9 @@ evdns_nameserver_ip_add(const char *ip_as_string) { if (is_ipv6) { struct sockaddr_in6 sin6; memset(&sin6, 0, sizeof(sin6)); +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sin6.sin6_len = sizeof(sin6); +#endif sin6.sin6_family = AF_INET6; sin6.sin6_port = htons(port); if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) { @@ -2393,7 +2397,9 @@ evdns_nameserver_ip_add(const char *ip_as_string) { } else { struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sin.sin_len = sizeof(sin); +#endif sin.sin_family = AF_INET; sin.sin_port = htons(port); if (!inet_aton(addr_part, &sin.sin_addr)) { |