diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-11-14 20:51:41 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-11-14 23:16:57 -0500 |
commit | bb2145b45ba5992eae6d647b946b430dd2367375 (patch) | |
tree | 8f066e05ceeffd528be75899deab8197996693c4 /src/or/policies.c | |
parent | 85e8d35fca49c0a660e104a85bb727f808b8ffb0 (diff) | |
download | tor-bb2145b45ba5992eae6d647b946b430dd2367375.tar.gz tor-bb2145b45ba5992eae6d647b946b430dd2367375.zip |
Fix a bug in policy_is_reject_star() that was making IPv4 exits break
IPv4-only exits have an implicit "reject [::]/0", which was making
policy_is_reject_star() return 1 for them, making us refuse to do
hostname lookups.
This fix chanes policy_is_reject_star() to ask about which family we meant.
Diffstat (limited to 'src/or/policies.c')
-rw-r--r-- | src/or/policies.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/or/policies.c b/src/or/policies.c index f9646f8f61..dd7de7013f 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -1049,18 +1049,23 @@ exit_policy_is_general_exit(smartlist_t *policy) /** Return false if <b>policy</b> might permit access to some addr:port; * otherwise if we are certain it rejects everything, return true. */ int -policy_is_reject_star(const smartlist_t *policy) +policy_is_reject_star(const smartlist_t *policy, sa_family_t family) { if (!policy) /*XXXX disallow NULL policies? */ return 1; - SMARTLIST_FOREACH(policy, addr_policy_t *, p, { - if (p->policy_type == ADDR_POLICY_ACCEPT) + SMARTLIST_FOREACH_BEGIN(policy, addr_policy_t *, p) { + if (p->policy_type == ADDR_POLICY_ACCEPT && + (tor_addr_family(&p->addr) == family || + tor_addr_family(&p->addr) == AF_UNSPEC)) { return 0; - else if (p->policy_type == ADDR_POLICY_REJECT && - p->prt_min <= 1 && p->prt_max == 65535 && - p->maskbits == 0) + } else if (p->policy_type == ADDR_POLICY_REJECT && + p->prt_min <= 1 && p->prt_max == 65535 && + p->maskbits == 0 && + (tor_addr_family(&p->addr) == family || + tor_addr_family(&p->addr) == AF_UNSPEC)) { return 1; - }); + } + } SMARTLIST_FOREACH_END(p); return 1; } |