[tbb-commits] [tor-browser/tor-browser-52.1.0esr-7.0-2] Bug 21862: Rip out potentially unsafe rust code

gk at torproject.org gk at torproject.org
Fri Jun 2 07:28:44 UTC 2017


commit 88c25c56d96f8fc0801359358d808f0d0e7d4b93
Author: Georg Koppen <gk at torproject.org>
Date:   Wed May 24 14:30:03 2017 +0000

    Bug 21862: Rip out potentially unsafe rust code
    
    Just ripping out the problematic code leads to compile errors
    complaining about modified third party code. That's fine for now,
    though we need to think harder about this issue once we start building
    with Rust being mandatory.
---
 third_party/rust/url/src/host.rs | 22 +---------------------
 third_party/rust/url/src/lib.rs  | 11 +----------
 2 files changed, 2 insertions(+), 31 deletions(-)

diff --git a/third_party/rust/url/src/host.rs b/third_party/rust/url/src/host.rs
index 47b049a..f2de780 100644
--- a/third_party/rust/url/src/host.rs
+++ b/third_party/rust/url/src/host.rs
@@ -10,7 +10,7 @@
 use std::cmp;
 use std::fmt::{self, Formatter};
 use std::io;
-use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
+use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
 use std::vec;
 use parser::{ParseResult, ParseError};
 use percent_encoding::percent_decode;
@@ -135,26 +135,6 @@ impl<'a> HostAndPort<&'a str> {
     }
 }
 
-impl<S: AsRef<str>> ToSocketAddrs for HostAndPort<S> {
-    type Iter = SocketAddrs;
-
-    fn to_socket_addrs(&self) -> io::Result<Self::Iter> {
-        let port = self.port;
-        match self.host {
-            Host::Domain(ref domain) => Ok(SocketAddrs {
-                // FIXME: use std::net::lookup_host when it’s stable.
-                state: SocketAddrsState::Domain(try!((domain.as_ref(), port).to_socket_addrs()))
-            }),
-            Host::Ipv4(address) => Ok(SocketAddrs {
-                state: SocketAddrsState::One(SocketAddr::V4(SocketAddrV4::new(address, port)))
-            }),
-            Host::Ipv6(address) => Ok(SocketAddrs {
-                state: SocketAddrsState::One(SocketAddr::V6(SocketAddrV6::new(address, port, 0, 0)))
-            }),
-        }
-    }
-}
-
 /// Socket addresses for an URL.
 pub struct SocketAddrs {
     state: SocketAddrsState
diff --git a/third_party/rust/url/src/lib.rs b/third_party/rust/url/src/lib.rs
index 9378318..51607e4 100644
--- a/third_party/rust/url/src/lib.rs
+++ b/third_party/rust/url/src/lib.rs
@@ -130,7 +130,7 @@ use std::fmt::{self, Write};
 use std::hash;
 use std::io;
 use std::mem;
-use std::net::{ToSocketAddrs, IpAddr};
+use std::net::IpAddr;
 use std::ops::{Range, RangeFrom, RangeTo};
 use std::path::{Path, PathBuf};
 use std::str;
@@ -1191,15 +1191,6 @@ impl Url {
     }
 }
 
-/// Return an error if `Url::host` or `Url::port_or_known_default` return `None`.
-impl ToSocketAddrs for Url {
-    type Iter = SocketAddrs;
-
-    fn to_socket_addrs(&self) -> io::Result<Self::Iter> {
-        try!(self.with_default_port(|_| Err(()))).to_socket_addrs()
-    }
-}
-
 /// Parse a string as an URL, without a base URL or encoding override.
 impl str::FromStr for Url {
     type Err = ParseError;



More information about the tbb-commits mailing list