Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
2.0
-
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
- duplicates
-
NET-236 method SubnetUtils.SubnetInfo.isInRange(addr) returns incorrect result
- Closed