summaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-13 17:34:05 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-13 17:34:05 -0500
commitb1ff8daeb521d1645bc35ffd7191599b7169c2bb (patch)
tree60c365a6cb8f67cb2abbf92cc7e504a282974713 /src/or/geoip.c
parent579808d4cdc62346fffa364900d0d76cfa28b3e1 (diff)
downloadtor-b1ff8daeb521d1645bc35ffd7191599b7169c2bb.tar.gz
tor-b1ff8daeb521d1645bc35ffd7191599b7169c2bb.zip
Nuke uses of memcmp outside of unit tests
We want to be saying fast_mem{cmp,eq,neq} when we're doing a comparison that's allowed to exit early, or tor_mem{cmp,eq,neq} when we need a data-invariant timing. Direct use of memcmp tends to imply that we haven't thought about the issue.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 2fd77d8b97..72a1983cb4 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -224,7 +224,8 @@ static int
geoip_ipv6_compare_entries_(const void **_a, const void **_b)
{
const geoip_ipv6_entry_t *a = *_a, *b = *_b;
- return memcmp(a->ip_low.s6_addr, b->ip_low.s6_addr, sizeof(struct in6_addr));
+ return fast_memcmp(a->ip_low.s6_addr, b->ip_low.s6_addr,
+ sizeof(struct in6_addr));
}
/** bsearch helper: return -1, 1, or 0 based on comparison of an IPv6
@@ -235,10 +236,10 @@ geoip_ipv6_compare_key_to_entry_(const void *_key, const void **_member)
const struct in6_addr *addr = (struct in6_addr *)_key;
const geoip_ipv6_entry_t *entry = *_member;
- if (memcmp(addr->s6_addr, entry->ip_low.s6_addr,
+ if (fast_memcmp(addr->s6_addr, entry->ip_low.s6_addr,
sizeof(struct in6_addr)) < 0)
return -1;
- else if (memcmp(addr->s6_addr, entry->ip_high.s6_addr,
+ else if (fast_memcmp(addr->s6_addr, entry->ip_high.s6_addr,
sizeof(struct in6_addr)) > 0)
return 1;
else