Hello, While debugging a test suite failure in dnspython [1], we've discovered that the musl implementation of getaddrinfo() fills .ai_canonname field even if flags do not include AI_CANONNAME. We think that this could incorrect. Per POSIX: > If nodename is not null, and if requested by the AI_CANONNAME flag, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > the ai_canonname field of the first returned addrinfo structure shall > point to a null-terminated string containing the canonical name > corresponding to the input nodename; [...] > > All fields in socket address structures returned by getaddrinfo() that > are not filled in through an explicit argument (for example, > sin6_flowinfo) shall be set to zero. [2] I think the correct behavior would be to set the field to zero (i.e. null) when AI_CANONNAME is not present in flags. I've reproduced the problem on Gentoo Linux amd64 with musl 1.2.4, using the following test program: ``` #include #include #include #include int main(void) { struct addrinfo hints = {0}; struct addrinfo *res; struct addrinfo *p; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; if (getaddrinfo("example.com", NULL, &hints, &res) == 0) { printf("%s\n", res->ai_canonname ? res->ai_canonname : "(null)"); freeaddrinfo(res); } return 0; } ``` On glibc system, it produces "(null)". On musl system, it produces "example.com". [1] https://github.com/rthalley/dnspython/issues/1035 [2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html -- Best regards, Michał Górny