Module Name: src Committed By: christos Date: Wed Dec 2 18:09:53 UTC 2015
Modified Files: src/lib/libc/net: getaddrinfo.c Log Message: PR/44915: Havard Eidnes: - Convert NS_NOTFOUND to EAI_NONAME instead of EAI_NODATA which more inline with what other OS's do. - Convert NO_DATA to NS_NOTFOUND since there is no equivalent mapping for nsswitch (perhaps we could add one so what we could recover the exact error and return EAI_NODATA?) - If we end up following a CNAME chain that does not find any data return that instead of internal error. XXX: pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/lib/libc/net/getaddrinfo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/net/getaddrinfo.c diff -u src/lib/libc/net/getaddrinfo.c:1.110 src/lib/libc/net/getaddrinfo.c:1.111 --- src/lib/libc/net/getaddrinfo.c:1.110 Mon Oct 26 10:48:04 2015 +++ src/lib/libc/net/getaddrinfo.c Wed Dec 2 13:09:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.110 2015/10/26 14:48:04 christos Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.111 2015/12/02 18:09:53 christos Exp $ */ /* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ /* @@ -55,7 +55,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getaddrinfo.c,v 1.110 2015/10/26 14:48:04 christos Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.111 2015/12/02 18:09:53 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifndef RUMP_ACTION @@ -667,7 +667,7 @@ explore_fqdn(const struct addrinfo *pai, error = EAI_FAIL; goto free; case NS_NOTFOUND: - error = EAI_NODATA; + error = EAI_NONAME; goto free; case NS_SUCCESS: error = 0; @@ -1453,7 +1453,9 @@ getanswer(res_state res, const querybuf return sentinel.ai_next; } - h_errno = NO_RECOVERY; + /* We could have walked a CNAME chain, */ + /* but the ultimate target may not have what we looked for */ + h_errno = ntohs(hp->ancount) > 0? NO_DATA : NO_RECOVERY; return NULL; } @@ -1724,6 +1726,8 @@ _dns_getaddrinfo(void *rv, void *cb_data if (ai == NULL) { switch (h_errno) { case HOST_NOT_FOUND: + case NO_DATA: // XXX: Perhaps we could differentiate + // So that we could return EAI_NODATA? return NS_NOTFOUND; case TRY_AGAIN: return NS_TRYAGAIN;