Skip to content

Reject unspecified IP from global #32211

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

Merged
merged 1 commit into from
Mar 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,12 @@ impl Ipv6Addr {
/// - the link-local addresses
/// - the (deprecated) site-local addresses
/// - unique local addresses
/// - the unspecified address
pub fn is_unicast_global(&self) -> bool {
!self.is_multicast()
&& !self.is_loopback() && !self.is_unicast_link_local()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopback is already rejected here

&& !self.is_unicast_site_local() && !self.is_unique_local()
&& !self.is_unspecified()
}

/// Returns the address's multicast scope if the address is multicast.
Expand Down Expand Up @@ -768,7 +770,7 @@ mod tests {

// unspec loopbk uniqlo global unill unisl uniglo mscope
check("::",
true, false, false, true, false, false, true, None);
true, false, false, false, false, false, false, None);
check("::1",
false, true, false, false, false, false, false, None);
check("::0.0.0.2",
Expand Down