krisprice / ipnet

IpNet, Ipv4Net, and Ipv6Net types and methods for Rust
Apache License 2.0
122 stars 26 forks source link

String Representations of `Ipv6Net` allow more than 8 groups #50

Open shaobo-he-aws opened 1 year ago

shaobo-he-aws commented 1 year ago

Consider the following program,

use ipnet::IpNet;
use std::net::IpAddr;

fn main() {
    assert!("ffff:ffff:ffff:ffff:ffff:ffff::ffff:ffff/114".parse::<IpNet>().is_ok());
    assert!("ffff:ffff:ffff:ffff:ffff:ffff::ffff:ffff".parse::<IpAddr>().is_ok());
}

The second assertion fails while the first one holds. ffff:ffff:ffff:ffff:ffff:ffff::ffff:ffff contains 8 ffffs and 1 :: that represents at least one all-zero groups.

shaobo-he-aws commented 1 year ago

Hello @krisprice, could you please confirm if it's a bug? Thank you very much.

krisprice commented 1 year ago

Hi @shaobo-he-aws - interesting, this behavior should get corrected whenever I get around to issue #32. :)