Skip to content

Commit 83d64cf

Browse files
authored
Rollup merge of rust-lang#70197 - pnkfelix:issue-53957-revise-test-of-23076, r=LukasKalbertodt
For issue 53957: revise unit test to focus on underlying bug of 23076. Fix rust-lang#53957 by revising unit test to focus on underlying bug of rust-lang#23076. Namely, this version focuses on the end-to-end behavior that the attempt to create the UDP binding will fail, regardless of the semantics of how particular DNS servers handle junk inputs. (I spent some time trying to create a second more-focused test that would sidestep the DNS resolution, but this is not possible without more invasive changes to the internal infrastructure of `ToSocketAddrs` and what not. It is not worth it.)
2 parents 638857f + 3db6d1c commit 83d64cf

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/libstd/net/addr.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,26 @@ mod tests {
989989
// s has been moved into the tsa call
990990
}
991991

992-
// FIXME: figure out why this fails on openbsd and fix it
993992
#[test]
994-
#[cfg(not(any(windows, target_os = "openbsd")))]
995-
fn to_socket_addr_str_bad() {
996-
assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err());
993+
fn bind_udp_socket_bad() {
994+
// rust-lang/rust#53957: This is a regression test for a parsing problem
995+
// discovered as part of issue rust-lang/rust#23076, where we were
996+
// incorrectly parsing invalid input and then that would result in a
997+
// successful `UdpSocket` binding when we would expect failure.
998+
//
999+
// At one time, this test was written as a call to `tsa` with
1000+
// INPUT_23076. However, that structure yields an unreliable test,
1001+
// because it ends up passing junk input to the DNS server, and some DNS
1002+
// servers will respond with `Ok` to such input, with the ip address of
1003+
// the DNS server itself.
1004+
//
1005+
// This form of the test is more robust: even when the DNS server
1006+
// returns its own address, it is still an error to bind a UDP socket to
1007+
// a non-local address, and so we still get an error here in that case.
1008+
1009+
const INPUT_23076: &'static str = "1200::AB00:1234::2552:7777:1313:34300";
1010+
1011+
assert!(crate::net::UdpSocket::bind(INPUT_23076).is_err())
9971012
}
9981013

9991014
#[test]

0 commit comments

Comments
 (0)