aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-09-19 15:27:39 +1000
committerteor <teor@torproject.org>2019-09-19 16:19:12 +1000
commit03c2b1be8d1e749b4f468cfe522da9e8375a83ad (patch)
tree80aadbb469160c196f138be60d164a5c5b6a5db1 /src
parent46fea1dfeeae1b575d427a9c3c6b4a8d1ab7f2b9 (diff)
downloadtor-03c2b1be8d1e749b4f468cfe522da9e8375a83ad.tar.gz
tor-03c2b1be8d1e749b4f468cfe522da9e8375a83ad.zip
dirauth: reorder the checks in dirserv_router_has_valid_address()
To avoid a bug warning. Fixes 31793. Bug not in any release, no changes file required.
Diffstat (limited to 'src')
-rw-r--r--src/feature/dirauth/process_descs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/feature/dirauth/process_descs.c b/src/feature/dirauth/process_descs.c
index e1a02179b0..1c026372b0 100644
--- a/src/feature/dirauth/process_descs.c
+++ b/src/feature/dirauth/process_descs.c
@@ -432,20 +432,22 @@ STATIC int
dirserv_router_has_valid_address(routerinfo_t *ri)
{
tor_addr_t addr;
+
if (get_options()->DirAllowPrivateAddresses)
return 0; /* whatever it is, we're fine with it */
- tor_addr_from_ipv4h(&addr, ri->addr);
- if (tor_addr_is_internal(&addr, 0) || tor_addr_is_null(&addr)) {
+ tor_addr_from_ipv4h(&addr, ri->addr);
+ if (tor_addr_is_null(&addr) || tor_addr_is_internal(&addr, 0)) {
log_info(LD_DIRSERV,
"Router %s published internal IPv4 address. Refusing.",
router_describe(ri));
return -1; /* it's a private IP, we should reject it */
}
+
/* We only check internal v6 on non-null addresses because we do not require
* IPv6 and null IPv6 is normal. */
- if (tor_addr_is_internal(&ri->ipv6_addr, 0) &&
- !tor_addr_is_null(&ri->ipv6_addr)) {
+ if (!tor_addr_is_null(&ri->ipv6_addr) &&
+ tor_addr_is_internal(&ri->ipv6_addr, 0)) {
log_info(LD_DIRSERV,
"Router %s published internal IPv6 address. Refusing.",
router_describe(ri));