aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-10-29 13:29:54 +0000
committerNick Mathewson <nickm@torproject.org>2008-10-29 13:29:54 +0000
commit361086005ca70d8acce55f140a701b0b3a90e48c (patch)
tree7480722572a297678604137294ddd10cab78233b /src/common
parentaccb4a680f318a225f51b047014e2c5a3671aa6f (diff)
downloadtor-361086005ca70d8acce55f140a701b0b3a90e48c.tar
tor-361086005ca70d8acce55f140a701b0b3a90e48c.tar.gz
Fix a possible negative shift in address comparison. May fix bug 845 and bug 811
svn:r17169
Diffstat (limited to 'src/common')
-rw-r--r--src/common/address.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c
index 2a2924a75..d6b64828c 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -686,6 +686,8 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
case AF_INET: {
uint32_t a1 = ntohl(addr1->addr.in_addr.s_addr);
uint32_t a2 = ntohl(addr2->addr.in_addr.s_addr);
+ if (mbits > 32)
+ mbits = 32;
a1 >>= (32-mbits);
a2 >>= (32-mbits);
return (a1 < a2) ? -1 : (a1 == a2) ? 0 : 1;