Clear the address when node_get_prim_orport() returns early

Fixes bug 23874; bugfix on 0.2.8.2-alpha.
This commit is contained in:
teor 2017-10-15 16:45:15 -04:00
parent 43ebe54a24
commit 5bca66be49
No known key found for this signature in database
GPG Key ID: 740D9E39025272A2
2 changed files with 11 additions and 0 deletions

3
changes/bug23874 Normal file
View File

@ -0,0 +1,3 @@
o Minor bugfixes (memory safety):
- Clear the address when node_get_prim_orport() returns early.
Fixes bug 23874; bugfix on 0.2.8.2-alpha.

View File

@ -1031,6 +1031,14 @@ node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
node_assert_ok(node);
tor_assert(ap_out);
/* Clear the address, as a safety precaution if calling functions ignore the
* return value */
tor_addr_make_null(&ap_out->addr, AF_INET);
ap_out->port = 0;
/* Check ri first, because rewrite_node_address_for_bridge() updates
* node->ri with the configured bridge address. */
RETURN_IPV4_AP(node->ri, or_port, ap_out);
RETURN_IPV4_AP(node->rs, or_port, ap_out);
/* Microdescriptors only have an IPv6 address */