Comment 4 for bug 1057526

Revision history for this message
Greg Hudson (ghudson) wrote :

I'm attaching a simple test program which can be used to see the problem, which appears to still be present in 12.10:

$ host ptr-mismatch.kerberos.org
ptr-mismatch.kerberos.org is an alias for www.kerberos.org.
www.kerberos.org has address 18.9.62.44
$ host www.kerberos.org
www.kerberos.org has address 18.9.62.44
$ host 18.9.62.44
44.62.9.18.in-addr.arpa domain name pointer KERBEROS-ORG.MIT.EDU.

$ cc canonname.c
$ ./a.out www.kerberos.org
www.kerberos.org
$ ./a.out -a www.kerberos.org
KERBEROS-ORG.MIT.EDU

$ ./a.out ptr-mismatch.kerberos.org
www.kerberos.org
$ ./a.out -a ptr-mismatch.kerberos.org
KERBEROS-ORG.MIT.EDU

Without AI_ADDRCONFIG, getaddrinfo does the right thing: it follows a CNAME record (like ptr-mismatch.kerberos.org) and returns the name of the A record. With AI_ADDRCONFIG, getaddrinfo performs a PTR lookup. This also happens if ai_family is set in the hint (e.g. to AF_INET); that path isn't exercised in the test program.