Created attachment 6187 [details]
Patch to fix the issue
When using a nameserver which doesn't support IPv6, it might returns FORMERR or NOTIMP, though it's not supposed to be the case according to the RFC. When this corresponds to the first answer (which is usually the case as it's faster to just return an error than doing a recursive query), resplen (that is the returned value) ends up being 0 and resplen2 > 0. The tests in __libc_res_nsearch() only look at resplen and totally ignore resplen2.
The attached patch fixes that by testing if resplen > 0 or resplen == 0 (that is empty result, but no error) and resplen2 > 0.
Aurelien, did you send this patch to libc-alpha?
*** This bug has been marked as a duplicate of bug 12994 ***