[tor-commits] [tor/master] Switch from "AF_UNIX is always equal" to "always unequal" to avoid wacky bugs. See discussion on 20261

nickm at torproject.org nickm at torproject.org
Tue Oct 11 15:11:45 UTC 2016


commit 2e7e635c593f13012303ced2bb85d50ed3195d24
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Oct 11 11:11:21 2016 -0400

    Switch from "AF_UNIX is always equal" to "always unequal" to avoid wacky bugs. See discussion on 20261
---
 src/common/address.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/common/address.c b/src/common/address.c
index dae1800..773e688 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1042,9 +1042,9 @@ tor_addr_copy_tight(tor_addr_t *dest, const tor_addr_t *src)
  * <b>how</b> is CMP_EXACT; otherwise, IPv6-mapped IPv4 addresses are
  * considered equivalent to their IPv4 equivalents.
  *
- * As a special case, all AF_UNIX addresses are always considered equal
- * since tor_addr_t currently does not contain the information required to
- * make the comparison.
+ * As a special case, all pointer-wise distinct AF_UNIX addresses are always
+ * considered unequal since tor_addr_t currently does not contain the
+ * information required to make the comparison.
  */
 int
 tor_addr_compare(const tor_addr_t *addr1, const tor_addr_t *addr2,
@@ -1125,11 +1125,17 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
          *
          * Since the only time we currently actually should be comparing
          * 2 AF_UNIX addresses is when dealing with ISO_CLIENTADDR (which
-         * is diesabled for AF_UNIX SocksPorts anyway), this just returns 0.
+         * is disabled for AF_UNIX SocksPorts anyway), this just does
+         * a pointer comparison.
          *
          * See: #20261.
          */
-        return 0;
+        if (addr1 < addr2)
+          return -1;
+        else if (addr1 == addr2)
+          return 0;
+        else
+          return 1;
       default:
         /* LCOV_EXCL_START */
         tor_fragile_assert();



More information about the tor-commits mailing list