Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-260

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0
    • 2.2
    • None
    • None

    Description

      SubnetUtils class handles IP addresses as int (which in Java is signed).
      isInRange() method does not take this into account:

      private boolean isInRange(int address) {
          return ((address-low()) <= (high()-low()));
      }
      

      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)

      String cidrNotation = "192.168.12.0/23";
      SubnetUtils.SubnetInfo info = new SubnetUtils(cidrNotation).getInfo();
      assertFalse(info.isInRange("120.0.0.0")); // fails
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              drone Andris Rauda
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: