Skip to content

Commit

Permalink
core: fix matching network addresses with bitmask non divisible to 8
Browse files Browse the repository at this point in the history
- reported by Kyle Kurz <kkurz@digium.com> for permissions module

(cherry picked from commit f429e75)
(cherry picked from commit 05ac2a2)
  • Loading branch information
miconda committed Jul 17, 2015
1 parent 547f148 commit f06fc52
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ip_addr.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f06fc52

Please sign in to comment.