Module: kamailio
Branch: master
Commit: f429e753dfa750a604bfb0acb5068b47d0fbe142
URL:
https://github.com/kamailio/kamailio/commit/f429e753dfa750a604bfb0acb5068b4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-07-07T11:16:17+02:00
core: fix matching network addresses with bitmask non divisible to 8
- reported by Kyle Kurz <kkurz(a)digium.com> for permissions module
---
Modified: ip_addr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f429e753dfa750a604bfb0acb5068b4…
Patch:
https://github.com/kamailio/kamailio/commit/f429e753dfa750a604bfb0acb5068b4…
---
diff --git a/ip_addr.c b/ip_addr.c
index 8504740..3412af9 100644
--- a/ip_addr.c
+++ b/ip_addr.c
@@ -377,7 +377,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;
@@ -420,8 +421,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;
}