]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Format IPv6 policies correctly.
authorNick Mathewson <nickm@torproject.org>
Tue, 8 Dec 2015 13:42:52 +0000 (08:42 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 8 Dec 2015 13:44:58 +0000 (08:44 -0500)
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.

changes/bug16056 [new file with mode: 0644]
src/or/policies.c

diff --git a/changes/bug16056 b/changes/bug16056
new file mode 100644 (file)
index 0000000..e3311c0
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (relay, IPv6):
+    - When displaying an IPv6 exit policy, include the mask bits correctly
+      even when the number is greater than 31. Fixes bug 16056; bugfix on
+      0.2.4.7-alpha. Patch from "gturner".
\ No newline at end of file
index 9c858ec1b011ec49147e308aad46020569c00c42..b247e6a64dd01e75d2aa79c9c871c69fd1869785 100644 (file)
@@ -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);