leaveWhite9088 opened a new pull request, #11531: URL: https://github.com/apache/rocketmq/pull/11531
### Which Issue(s) This PR Fixes - Fixes #11530 ### Brief Description `IPAddressUtils#isIPInRange(String ip, String cidr)` previously converted the target IP and CIDR network address directly into unsigned `BigInteger` values without checking whether both addresses share the same address family or whether the CIDR prefix length is within valid bounds. As a result, IPv4 addresses could match IPv6 CIDRs (such as `::/64` or `::1/128`), IPv6 addresses such as `::1` could match `0.0.0.0/0`, out-of-range prefix lengths caused negative bit shifts, and `isIPInRange(null, null)` returned `true`. This PR updates `IPAddressUtils#isIPInRange`: - Return `false` immediately when `ip` or `cidr` is blank. - Split CIDR with `-1` limit so trailing slashes are not treated as single-IP literals. - Require `cidrBytes.length == ipBytes.length` so IPv4 and IPv6 addresses never match across families. - Validate `0 <= prefixLength <= cidrBytes.length * 8` before computing the subnet mask. - Add unit tests in `IPAddressUtilsTest` covering cross-family matching, prefix length boundaries, invalid prefix lengths, and blank/null inputs. ### How Did You Test This Change? - Ran `mvn test -pl common -Dtest=IPAddressUtilsTest` (Checkstyle: 0 violations, SpotBugs: 0 errors, Tests run: 5, Failures: 0, Errors: 0). - Ran `mvn test -pl auth -Dtest=*Authorization*Test` (Checkstyle: 0 violations, Tests run: 61, Failures: 0, Errors: 0). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
