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

ip6addr_aton allows invalid IPv6 address strings #33

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

wskellenger-intrepid
Copy link

@wskellenger-intrepid wskellenger-intrepid commented May 28, 2024

I've added two test cases, both of which produce a true (valid IP address) response by aton(). Expected result is false (invalid IP address).

  const char *shortened_ipv6_addr_unexpected_char = "::FFFF:D4CC:65DZ";
  const char *shortened_ipv6_addr_invalid = "::GGGGGGGG";

I'm not sure why, but ip6addr_aton will check for invalid characters and then continue on. My solution was to add a return 0 in these cases, but I'm not sure if this is a robust solution or will cause more problems. All tests pass with this solution.

Update, also found the following failing test case and fixed it:

  const char *ipv6_block_too_long = "1234:5678:9aBc:acDef:1122:3344:5566:7788";

Update, found more problems, added tests and fixed.

  • trailing single colon
  • adding zero compression in an address that is already fully defined

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.

1 participant