diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-01-02 20:39:38 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-01-02 20:39:38 +0000 |
commit | 48f2ce298b617f00775fb07af7936a09b5d675c6 (patch) | |
tree | 12bac3c13694a4b96be25bb64655ebc408bc138a /src/common | |
parent | 6ded0249148745bbce46937faba1eedf9bfb2450 (diff) | |
download | tor-48f2ce298b617f00775fb07af7936a09b5d675c6.tar.gz tor-48f2ce298b617f00775fb07af7936a09b5d675c6.zip |
Try harder to make sure we zero-out the extraneous sockaddr fields and that we set sockaddr_len. Conceivably a backport candidate, though nothing has yet been sen to break.
svn:r17849
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/address.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c index a47b1228f9..1abd1a7dfb 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -68,6 +68,8 @@ tor_addr_to_sockaddr(const tor_addr_t *a, if (len < (int)sizeof(struct sockaddr_in)) return -1; sin = (struct sockaddr_in *)sa_out; + memset(sin, 0, sizeof(struct sockaddr_in)); + sin->sin_len = sizeof(struct sockaddr_in); sin->sin_family = AF_INET; sin->sin_port = htons(port); sin->sin_addr.s_addr = tor_addr_to_ipv4n(a); @@ -78,6 +80,7 @@ tor_addr_to_sockaddr(const tor_addr_t *a, return -1; sin6 = (struct sockaddr_in6 *)sa_out; memset(sin6, 0, sizeof(struct sockaddr_in6)); + sin6->sin6_len = sizeof(struct sockaddr_in6); sin6->sin6_family = AF_INET6; sin6->sin6_port = htons(port); memcpy(&sin6->sin6_addr, tor_addr_to_in6(a), sizeof(struct in6_addr)); |