Module: kamailio
Branch: 4.1
Commit: bd85c1d19fc0e1c2d706282b954a2baa1665d34f
URL:
https://github.com/kamailio/kamailio/commit/bd85c1d19fc0e1c2d706282b954a2ba…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-07-17T12:37:50+02:00
core: fix matching network addresses with bitmask non divisible to 8
- reported by Kyle Kurz <kkurz(a)digium.com> for permissions module
(cherry picked from commit f429e753dfa750a604bfb0acb5068b47d0fbe142)
(cherry picked from commit 05ac2a2b88f476b0fd32b1bf314b2357eedfceb0)
(cherry picked from commit f06fc524de25e09549f7fbb57a0f08fb2765267e)
---
Modified: ip_addr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/bd85c1d19fc0e1c2d706282b954a2ba…
Patch:
https://github.com/kamailio/kamailio/commit/bd85c1d19fc0e1c2d706282b954a2ba…
---
diff --git a/ip_addr.c b/ip_addr.c
index 7175bd0..bde491d 100644
--- a/ip_addr.c
+++ b/ip_addr.c
@@ -356,7 +356,8 @@ char* get_proto_name(unsigned int proto)
int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr,
int mask)
{
- unsigned char c;
+ unsigned char ci;
+ unsigned char cn;
int i;
int mbytes;
int mbits;
@@ -399,8 +400,9 @@ int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr,
mbits = mask % 8;
if(mbits==0)
return 0;
- c = naddr->u.addr[i] & (~((1 << (8 - mbits)) - 1));
- if((iaddr->u.addr[i] & c) == c)
+ ci = iaddr->u.addr[i] & (~((1 << (8 - mbits)) - 1));
+ cn = naddr->u.addr[i] & (~((1 << (8 - mbits)) - 1));
+ if(ci == cn)
return 0;
return -1;
}