-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
This should return an error since a /24 would require a zero 4th octet, but it accepts it. Worse, it doesn't seem to transform it, but keeps all the bits set.
use std::str::FromStr;
use ipnet::Ipv4Net;
fn main() {
let net = Ipv4Net::from_str("1.1.1.1/24");
assert!(net.is_ok());
println!("{}", net.unwrap());
}NOTE: I just found the trunc function so now I'm starting to think this is per design. For the record, I think this is broken behavior as these are in no way valid subnets. My preference, and I believe correct behavior, would be to reject these outright. However, if this is kept, it would be nice if trunc could at least run by default so Serde, etc. can properly transform the data. Since there is no way to call trunc in the deserialization path that I'm aware of, it has to be a per call site type thing which is error prone.
Thanks for looking at this.
Metadata
Metadata
Assignees
Labels
No labels