Skip to content

Some special IP addresses are being wrongly detected as globally routable #24314

Closed
@achanda

Description

@achanda

An example is the special broadcast address 255.255.255.255/32 which is being detected as globally routable

Abhishek@Abhisheks-MacBook-Pro:~/src/rust (master %=)$ cat ip-test.rs
#![feature(ip)]
use std::net::Ipv4Addr;

fn main() {
    let x = Ipv4Addr::new(255,255,255,255);
    println!("{0}", x.is_global())
}
Abhishek@Abhisheks-MacBook-Pro:~/src/rust (master %=)$ ./ip-test
true
Abhishek@Abhisheks-MacBook-Pro:~/src/rust (master %=)$ ./x86_64-apple-darwin/stage2/bin/rustc --version --verbose
rustc 1.0.0-dev (c897ac04e 2015-04-10) (built 2015-04-10)
binary: rustc
commit-hash: c897ac04e2ebda378fd9e38f6ec0878ae3a2baf7
commit-date: 2015-04-10
build-date: 2015-04-10
host: x86_64-apple-darwin
release: 1.0.0-dev

This is because the code [1] does not take into account these special class of address as defined by RFC 6890 [2].

[1] https://doc.rust-lang.org/src/std/net/ip.rs.html#119
[2] http://tools.ietf.org/html/rfc6890

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions