Skip to content

Commit 3c2c516

Browse files
committed
rollup merge of #23097: alexcrichton/issue-23076
The `rsplitn` call was called with 2 instead of 1 so the iterator would yield 3 items in some cases, not the 2 that it should have. Closes #23076
2 parents 31af637 + 65b4eda commit 3c2c516

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libstd/net/addr.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl ToSocketAddrs for str {
293293
}
294294

295295
// split the string by ':' and convert the second part to u16
296-
let mut parts_iter = self.rsplitn(2, ':');
296+
let mut parts_iter = self.rsplitn(1, ':');
297297
let port_str = try_opt!(parts_iter.next(), "invalid socket address");
298298
let host = try_opt!(parts_iter.next(), "invalid socket address");
299299
let port: u16 = try_opt!(port_str.parse().ok(), "invalid port value");
@@ -590,4 +590,9 @@ mod tests {
590590
let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
591591
assert!(tsa("localhost:23924").unwrap().contains(&a));
592592
}
593+
594+
#[test]
595+
fn to_socket_addr_str_bad() {
596+
assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err());
597+
}
593598
}

0 commit comments

Comments
 (0)