fixed bug in checking IP address includion into address range
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 26 Jul 2017 10:44:02 +0000 (13:44 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 26 Jul 2017 10:44:02 +0000 (13:44 +0300)
src/server/core/addrlist.cpp

index d095238..315467e 100644 (file)
@@ -115,7 +115,11 @@ bool InetAddressListElement::contains(const InetAddress& addr) const
    if (m_type == InetAddressListElement_SUBNET)
       return m_baseAddress.contain(addr);
    if ((m_baseAddress.getFamily() == addr.getFamily()) && (m_endAddress.getFamily() == addr.getFamily()))
-      return (m_baseAddress.compareTo(addr) <= 0) && (m_endAddress.compareTo(addr) >= 0);
+   {
+      InetAddress a = addr;
+      a.setMaskBits(m_baseAddress.getMaskBits());   // compare only address parts
+      return (m_baseAddress.compareTo(a) <= 0) && (m_endAddress.compareTo(a) >= 0);
+   }
    return false;
 }