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

Ipv4Addr can't parse perfectly valid IP address #100749

Closed
gimbling-away opened this issue Aug 19, 2022 · 2 comments
Closed

Ipv4Addr can't parse perfectly valid IP address #100749

gimbling-away opened this issue Aug 19, 2022 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@gimbling-away
Copy link
Contributor

I tried this code:

"0xac.000000000000000000331.0246.174".parse::<Ipv4Addr>.unwrap()

I expected to see this happen: OK

Instead, this happened: It panicked and failed.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=278845b668106e1318e431ba7c81eb47


IP addresses can contain different representations in every chunk, the IP address is completely valid. For eg. running ping on it, is completely fine.
image

@gimbling-away gimbling-away added the C-bug Category: This is a bug. label Aug 19, 2022
@ilyvion
Copy link

ilyvion commented Aug 19, 2022

This is explicitly stated not to be supported in the docs:

Ipv4Addr provides a FromStr implementation. The four octets are in decimal notation, divided by . (this is called "dot-decimal notation"). Notably, octal numbers (which are indicated with a leading 0) and hexadecimal numbers (which are indicated with a leading 0x) are not allowed per IETF RFC 6943.

See also #83652

@gimbling-away
Copy link
Contributor Author

Ah, interesting. Alright then. Closing. 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants