Module: kamailio
Branch: 4.2
Commit: f06fc524de25e09549f7fbb57a0f08fb2765267e
URL:
https://github.com/kamailio/kamailio/commit/f06fc524de25e09549f7fbb57a0f08f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-07-17T12:36:57+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)
---
Modified: ip_addr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f06fc524de25e09549f7fbb57a0f08f…
Patch:
https://github.com/kamailio/kamailio/commit/f06fc524de25e09549f7fbb57a0f08f…
---
diff --git a/ip_addr.c b/ip_addr.c
index 458eaa0..d88d5fd 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;
}