-
Notifications
You must be signed in to change notification settings - Fork 42
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
IpNetwork::size() overflows if the prefix is 0 #130
Comments
Using Possible solutions to
|
I realize the impl Ipv4Network {
pub const BITS: u8 = 32;
}
impl Ipv6Network {
pub const BITS: u8 = 128;
} |
Sounds like the path of least resistance is to document the panic properly so that there are no surprises. I also agree that we should export |
Please mind that the current version only panics in debug mode. In release mode where overflows are not caught it just returns size If we go the path of having it panic. Then the If we go the path of least resistance I think changing Ipv4 to return a |
This issue is still not patched, but the solution to either use As for Ipv6, the This problem with |
I think #179 may fix this? |
Ipv4Network::size
panics ifself.prefix == 0
since the result is too large (2^32
):This could have been fixed by using
u64
if not for the fact that the same problem occurs inIpv6Network::size
, where the type cannot be made any larger.If a
Result
cannot be returned, should the potential panic be documented?The text was updated successfully, but these errors were encountered: