summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-10-11 11:11:21 -0400
committerNick Mathewson <nickm@torproject.org>2016-10-11 11:11:21 -0400
commit2e7e635c593f13012303ced2bb85d50ed3195d24 (patch)
treef34e7336318fde57e72ad1f7d473985a80f2bd4b
parentd25fed51746e848fc04cabefe58133e3957209de (diff)
downloadtor-2e7e635c593f13012303ced2bb85d50ed3195d24.tar.gz
tor-2e7e635c593f13012303ced2bb85d50ed3195d24.zip
Switch from "AF_UNIX is always equal" to "always unequal" to avoid wacky bugs. See discussion on 20261
-rw-r--r--src/common/address.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/common/address.c b/src/common/address.c
index dae1800919..773e688554 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();