commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pin_ptr (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (NET-641) SubnetUtils.SubnetInfo.isInRange("0.0.0.0") returns true for CIDR/31, 32
Date Thu, 03 Aug 2017 17:41:00 GMT

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

pin_ptr reopened NET-641:
-------------------------

My idea:

public boolean isInRange(int address) { 
    long addLong = address & UNSIGNED_INT_MASK;
    if (inclusiveHostCount) {
        return networkLong() <= addLong && addLong <= broadcastLong();
    } else {
        return networkLong() < addLong && addLong < broadcastLong();
    }
}


> SubnetUtils.SubnetInfo.isInRange("0.0.0.0") returns true for CIDR/31, 32
> ------------------------------------------------------------------------
>
>                 Key: NET-641
>                 URL: https://issues.apache.org/jira/browse/NET-641
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 3.6
>         Environment: Windows; JDK8; common-net 3.6
>            Reporter: pin_ptr
>            Priority: Minor
>             Fix For: 3.7
>
>
> Code:
> import org.apache.commons.net.util.SubnetUtils;
> public class A {
>   public static void main(String[] args) {
>     System.out.println(new SubnetUtils("192.168.1.0/30").getInfo().isInRange("0.0.0.0"));
>     System.out.println(new SubnetUtils("192.168.1.0/31").getInfo().isInRange("0.0.0.0"));
>     System.out.println(new SubnetUtils("192.168.1.0/32").getInfo().isInRange("0.0.0.0"));
>   }
> }
> Result:
> false
> true
> true
> Expected:
> false
> false
> false



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message