Module: kamailio
Branch: 4.3
Commit: 05ac2a2b88f476b0fd32b1bf314b2357eedfceb0
URL: 
https://github.com/kamailio/kamailio/commit/05ac2a2b88f476b0fd32b1bf314b2357eedfceb0

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2015-07-17T12:25:58+02:00

core: fix matching network addresses with bitmask non divisible to 8

- reported by Kyle Kurz <kk...@digium.com> for permissions module

(cherry picked from commit f429e753dfa750a604bfb0acb5068b47d0fbe142)

---

Modified: ip_addr.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/05ac2a2b88f476b0fd32b1bf314b2357eedfceb0.diff
Patch: 
https://github.com/kamailio/kamailio/commit/05ac2a2b88f476b0fd32b1bf314b2357eedfceb0.patch

---

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;
 }


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to