diff options
| author | christos <christos@NetBSD.org> | 2015-12-02 18:09:53 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2015-12-02 18:09:53 +0000 |
| commit | 217d1ae9aebd46ca24f55d7808daef2d5f2ba656 (patch) | |
| tree | 1c1a365fca7e16e9d945d20ea185e9e648a3f7c4 /lib/libc/net | |
| parent | ed6d44a87bd024d9f7b06dae4d2f669baa54d80c (diff) | |
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
Diffstat (limited to 'lib/libc/net')
| -rw-r--r-- | lib/libc/net/getaddrinfo.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 4b47766e86b..2f6045d4905 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -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, const char *hostname, 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 *answer, int anslen, const char *qname, 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, va_list ap) 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; |
