diff options
author | Linus Nordberg <linus@torproject.org> | 2012-10-31 15:52:56 +0100 |
---|---|---|
committer | Linus Nordberg <linus@torproject.org> | 2012-10-31 15:52:56 +0100 |
commit | e7e68b80a74faa52fbf6e551bf373a405c6cdf97 (patch) | |
tree | 8229a87b9a27d4d7f7fac233d3a703b6d3f8ae5f | |
parent | 6a241ff3ffe7dc1f18c8a5d335a012aa20d763f7 (diff) | |
download | tor-e7e68b80a74faa52fbf6e551bf373a405c6cdf97.tar tor-e7e68b80a74faa52fbf6e551bf373a405c6cdf97.tar.gz |
Don't memcmp struct in6_addr but rather its s6_addr member.
-rw-r--r-- | src/or/geoip.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c index 8ba7b70da..606bece8b 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -224,24 +224,22 @@ 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, &b->ip_low, sizeof(struct in6_addr)); + return 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 - * (a pointer to a in6_addr in host order) to a geoip_ipv6_entry_t */ + * (a pointer to a in6_addr) to a geoip_ipv6_entry_t */ static int geoip_ipv6_compare_key_to_entry_(const void *_key, const void **_member) { - /* XXX5053 The following comment isn't correct anymore and I'm not 100% - * certain how to fix it, because I don't know what alignment issues - * there could be. -KL */ - /* No alignment issue here, since _key really is a pointer to uint32_t */ const struct in6_addr *addr = (struct in6_addr *)_key; const geoip_ipv6_entry_t *entry = *_member; - if (memcmp(addr, &entry->ip_low, sizeof(struct in6_addr)) < 0) + if (memcmp(addr->s6_addr, entry->ip_low.s6_addr, + sizeof(struct in6_addr)) < 0) return -1; - else if (memcmp(addr, &entry->ip_high, sizeof(struct in6_addr)) > 0) + else if (memcmp(addr->s6_addr, entry->ip_high.s6_addr, + sizeof(struct in6_addr)) > 0) return 1; else return 0; |