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

IPv4 NNS regex allows for leading zeros #2283

Closed
roman-khimov opened this issue Feb 1, 2021 · 1 comment · Fixed by #2285
Closed

IPv4 NNS regex allows for leading zeros #2283

roman-khimov opened this issue Feb 1, 2021 · 1 comment · Fixed by #2285
Assignees

Comments

@roman-khimov
Copy link
Contributor

Describe the bug
01.02.08.09 is considered to be valid IPv4 address by the checks added in #2262. This can be problematic if anyone is to use this IP (got from NNS contract) as an input for BSD or POSIX compliant inet_aton() and inet_addr() functions which will interpret chunks with leading zeros as octal values rather than decimal (and some other libraries can still interpret them as decimal).

Expected behavior
We better forbid leading zeros.

@roman-khimov
Copy link
Contributor Author

But this notation is forbidden by IPAddress.TryParse() (somewhat surprisingly), so 01.02.08.09 is not actually accepted in the end by the current NNS contract. Still, 00.00.00.00 is and it's very easy to miss these nuances, so we better still fix the regex.

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 a pull request may close this issue.

2 participants