SubnetUtils.SubnetInfo.isInRange(...) returns incorrect values
--------------------------------------------------------------

                 Key: NET-260
                 URL: https://issues.apache.org/jira/browse/NET-260
             Project: Commons Net
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Andris Rauda


SubnetUtils class handles IP addresses as int (which in Java is signed).
isInRange() method does not take this into account:
{code}
private boolean isInRange(int address) {
    return ((address-low()) <= (high()-low()));
}
{code}

In following code snippet isInRange() returns true, when clearly 120.0.0.0 is 
outside the range: 192.168.12.0 - 192.168.13.255
(see 
http://compnetworking.about.com/od/workingwithipaddresses/a/cidr_notation.htm)
{code}
        String cidrNotation = "192.168.12.0/23";
        SubnetUtils.SubnetInfo info = new SubnetUtils(cidrNotation).getInfo();
        assertFalse(info.isInRange("120.0.0.0")); // fails
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to