fix handling of dns response codes
authorRich Felker <dalias@aerifal.cx>
Fri, 29 Jan 2016 00:23:06 +0000 (19:23 -0500)
committerRich Felker <dalias@aerifal.cx>
Fri, 29 Jan 2016 00:37:35 +0000 (19:37 -0500)
commit0fef7ffac114befc94ab5fa794a1754442dcd531
tree2fedd4eb4efd210ca4089dd1e310058bde1d834a
parentfe8453d2ee128cfcf8777a19659f1c1f19e052ac
fix handling of dns response codes

rcode of 3 (NxDomain) was treated as a hard EAI_NONAME failure, but it
should instead return 0 (no results) so the caller can continue
searching. this will be important for adding search domain support.
the top-level caller will automatically return EAI_NONAME if there are
zero results at the end.

also, the case where rcode is 0 (success) but there are no results was
not handled. this happens when the domain exists but there are no A or
AAAA records for it. in this case a hard EAI_NONAME should be imposed
to inhibit further search, since the name was defined and just does
not have any address associated with it. previously a misleading hard
failure of EAI_FAIL was reported.
src/network/lookup_name.c