Skip to content

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

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

Closed
achanda opened this issue Apr 11, 2015 · 1 comment · Fixed by #24343
Closed

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

achanda opened this issue Apr 11, 2015 · 1 comment · Fixed by #24343

Comments

@achanda
Copy link
Contributor

achanda commented Apr 11, 2015

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

@achanda
Copy link
Contributor Author

achanda commented Apr 11, 2015

I'd be happy to fix this.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 14, 2015
- Adds two more functions for broadcast address and special
  address classes reserved for documentation
- Modifies the globally routable IP check to include these
  new functions

Fixes rust-lang#24314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants