commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andris Rauda (JIRA)" <j...@apache.org>
Subject [jira] Updated: (NET-260) SubnetUtils.SubnetInfo.isInRange(...) returns incorrect values
Date Tue, 10 Mar 2009 13:44:50 GMT

     [ https://issues.apache.org/jira/browse/NET-260?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andris Rauda updated NET-260:
-----------------------------

    Fix Version/s: 1.1.1
      Description: 
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}

  was:
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}


> 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
>             Fix For: 1.1.1
>
>
> 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.


Mime
View raw message