Skip to content

Test to_socket_addr_str_bad is broken on macOS too #53957

@stepancheg

Description

@stepancheg

This is the test from rust source repository.

 // FIXME: figure out why this fails on openbsd and bitrig and fix it #[test] #[cfg(not(any(windows, target_os = "openbsd", target_os = "bitrig")))] fn to_socket_addr_str_bad() { assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err()); } 

It says, the test fails on openbsd and bitrig, but it also fails on macOS.

 let a: Vec<_> = "1200::AB00:1234::2552:7777:1313:34300" .to_socket_addrs().unwrap().collect(); println!("{:?}", a); // prints [V4(92.242.132.24:34300)] 

I guess the reason is this:

% host random::junk random::junk has address 92.242.132.24 Host random::junk not found: 3(NXDOMAIN) 
% dig random::junk ; <<>> DiG 9.10.6 <<>> random::junk ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 581 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;random::junk.	IN	A ;; ANSWER SECTION: random::junk.	0	IN	A	92.242.132.24 ;; Query time: 30 msec ;; SERVER: 194.168.4.100#53(194.168.4.100) ;; WHEN: Wed Sep 05 04:07:34 BST 2018 ;; MSG SIZE rcvd: 57 

194.168.4.100 is an IP address of DNS of my ISP.

So for some reason, macOS decides to resolve string 1200::AB00:1234::2552:7777:1313 using DNS, and on certain ISP this resolution success.

I think rust should either:

  • disable this test on macOS as well
  • or explicitly check if hostname contains a colon, immediately fail without passing the string to libc resolver

Metadata

Metadata

Assignees

Labels

O-macosOperating system: macOS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions