From: Felix Morgner Date: Mon, 1 Dec 2014 09:29:32 +0000 (+0100) Subject: fixed banning (hopefully) X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=commitdiff_plain;h=38763ab7cb701f7721b4b558952e85d09a935796 fixed banning (hopefully) The original code used ^ which in C is the XOR operator. I believe the author meant to raise 2 to the power of ban->mask, the new code should calculate the mask correctly. --- diff --git a/src/ban.c b/src/ban.c index 4ff47c8..c8b8688 100644 --- a/src/ban.c +++ b/src/ban.c @@ -144,7 +144,8 @@ bool_t Ban_isBannedAddr(struct sockaddr_storage *address) ban = list_get_entry(itr, ban_t, node); if (ban->address.ss_family == address->ss_family) { if (address->ss_family == AF_INET) { - uint32_t a1, a2, mask = 2 ^ ban->mask; + uint32_t a1, a2, mask; + mask = (ban->mask == 32) ? UINT32_MAX : (1u << ban->mask) - 1; a1 = (uint32_t)((struct sockaddr_in *)&ban->address)->sin_addr.s_addr & mask; a2 = (uint32_t)((struct sockaddr_in *)address)->sin_addr.s_addr & mask; if (a1 == a2)