Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Return None for Over-Segmented IPv6 Addresses #590

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

razeghi71
Copy link
Contributor

This PR addresses an issue with the current implementation of the Ipv6Address.fromString method. Previously, an IPv6 address with too many segments would cause an exception instead of returning None. This PR introduces a fix to ensure that over-segmented IPv6 addresses correctly return None, aligning with the expected behavior of the method.

Changes:

  • Added a condition to check for negative numCondensedZeroes, which indicates over-segmentation.
  • Adjusted the logic to correctly handle the prefix and suffix of the IPv6 address during parsing.

Examples:

  • Before the fix: For an input like 1:1:1:1:1:1:2:1:3, the Ipv6Address.fromString method would throw a java.lang.ArrayIndexOutOfBoundsException: Index 16 out of bounds for length 16.
  • After the fix: The same input now returns None, indicating an invalid IPv6 address, as expected.
  • Before the fix: For an input like ::1:1:1:1:1:1:2:1:3, the Ipv6Address.fromString method would throw a java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 16.
  • After the fix: The same input now returns None, indicating an invalid IPv6 address, as expected.

@CLAassistant
Copy link

CLAassistant commented Jun 5, 2024

CLA assistant check
All committers have signed the CLA.

@mpilquist
Copy link
Member

Thanks!

@mpilquist mpilquist merged commit 6fefe1d into Comcast:main Jun 6, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants