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

SubnetUtils.SubnetInfo.getAddressCount() can overflow as it returns an int

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Component/s: None
    • Labels:
      None

      Description

      The method SubnetUtils.SubnetInfo.getAddressCount() returns an int.

      However a CIDR with 0 or 1 bits in the routing mask can represent more than Integer.MAX_VALUE entries, so the method cannot currently return the correct value.

      Unfortunately, if the method were changed to return a long it would break binary compatibility (the return type is part of the API signature).

      One possible solution is to provide a new method which returns a long, and deprecate the old method.

      If the original method cannot return the correct value, it should probably throw a runtime error.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb@apache.org Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: