mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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
This commit is contained in:
parent
6ded024914
commit
48f2ce298b
@ -68,6 +68,8 @@ tor_addr_to_sockaddr(const tor_addr_t *a,
|
|||||||
if (len < (int)sizeof(struct sockaddr_in))
|
if (len < (int)sizeof(struct sockaddr_in))
|
||||||
return -1;
|
return -1;
|
||||||
sin = (struct sockaddr_in *)sa_out;
|
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_family = AF_INET;
|
||||||
sin->sin_port = htons(port);
|
sin->sin_port = htons(port);
|
||||||
sin->sin_addr.s_addr = tor_addr_to_ipv4n(a);
|
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;
|
return -1;
|
||||||
sin6 = (struct sockaddr_in6 *)sa_out;
|
sin6 = (struct sockaddr_in6 *)sa_out;
|
||||||
memset(sin6, 0, sizeof(struct sockaddr_in6));
|
memset(sin6, 0, sizeof(struct sockaddr_in6));
|
||||||
|
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||||
sin6->sin6_family = AF_INET6;
|
sin6->sin6_family = AF_INET6;
|
||||||
sin6->sin6_port = htons(port);
|
sin6->sin6_port = htons(port);
|
||||||
memcpy(&sin6->sin6_addr, tor_addr_to_in6(a), sizeof(struct in6_addr));
|
memcpy(&sin6->sin6_addr, tor_addr_to_in6(a), sizeof(struct in6_addr));
|
||||||
|
@ -2300,6 +2300,9 @@ out1:
|
|||||||
int
|
int
|
||||||
evdns_nameserver_add(unsigned long int address) {
|
evdns_nameserver_add(unsigned long int address) {
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
|
memset(&sin, 0, sizeof(sin));
|
||||||
|
sin.sin_family = AF_INET;
|
||||||
|
sin.sin_len = sizeof(sin);
|
||||||
sin.sin_addr.s_addr = htonl(address);
|
sin.sin_addr.s_addr = htonl(address);
|
||||||
sin.sin_port = 53;
|
sin.sin_port = 53;
|
||||||
return _evdns_nameserver_add_impl((struct sockaddr*) &sin, sizeof(sin));
|
return _evdns_nameserver_add_impl((struct sockaddr*) &sin, sizeof(sin));
|
||||||
@ -2377,6 +2380,8 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
assert(addr_part);
|
assert(addr_part);
|
||||||
if (is_ipv6) {
|
if (is_ipv6) {
|
||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
|
memset(&sin6, 0, sizeof(sin6));
|
||||||
|
sin6.sin6_len = sizeof(sin6);
|
||||||
sin6.sin6_family = AF_INET6;
|
sin6.sin6_family = AF_INET6;
|
||||||
sin6.sin6_port = htons(port);
|
sin6.sin6_port = htons(port);
|
||||||
if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) {
|
if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) {
|
||||||
@ -2387,10 +2392,12 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
sizeof(sin6));
|
sizeof(sin6));
|
||||||
} else {
|
} else {
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
|
memset(&sin, 0, sizeof(sin));
|
||||||
|
sin.sin_len = sizeof(sin);
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_port = htons(port);
|
sin.sin_port = htons(port);
|
||||||
if (!inet_aton(addr_part, &sin.sin_addr)) {
|
if (!inet_aton(addr_part, &sin.sin_addr)) {
|
||||||
log(EVDNS_LOG_DEBUG, "anet_pton(%s) failed", addr_part);
|
log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
return _evdns_nameserver_add_impl((struct sockaddr*)&sin,
|
return _evdns_nameserver_add_impl((struct sockaddr*)&sin,
|
||||||
|
Loading…
Reference in New Issue
Block a user