diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-12-08 08:42:52 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-08 08:44:58 -0500 |
commit | e9bf584694a592852293b945575d17ea4c3b742b (patch) | |
tree | d89a896ab04aab60aac090f6b06af5fa89ebe699 /src/or/policies.c | |
parent | 9c66afe7720aa32a2640564bbf8b0af64e394ba5 (diff) | |
download | tor-e9bf584694a592852293b945575d17ea4c3b742b.tar.gz tor-e9bf584694a592852293b945575d17ea4c3b742b.zip |
Format IPv6 policies correctly.
Previously we'd suppressed the mask-bits field in the output when
formatting a policy if it was >=32. But that should be a >=128 if
we're talking about IPv6.
Since we didn't put these in descriptors, this bug affects only log
messages and controller outputs.
Fix for bug 16056. The code in question was new in 0.2.0, but the
bug was introduced in 0.2.4 when we started supporting IPv6 exits.
Diffstat (limited to 'src/or/policies.c')
-rw-r--r-- | src/or/policies.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/or/policies.c b/src/or/policies.c index 9c858ec1b0..b247e6a64d 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -1391,9 +1391,9 @@ policy_write_item(char *buf, size_t buflen, addr_policy_t *policy, if (result < 0) return -1; written += strlen(buf); - /* If the maskbits is 32 we don't need to give it. If the mask is 0, - * we already wrote "*". */ - if (policy->maskbits < 32 && policy->maskbits > 0) { + /* If the maskbits is 32 (IPv4) or 128 (IPv6) we don't need to give it. If + the mask is 0, we already wrote "*". */ + if (policy->maskbits < (is_ip6?128:32) && policy->maskbits > 0) { if (tor_snprintf(buf+written, buflen-written, "/%d", policy->maskbits)<0) return -1; written += strlen(buf+written); |