Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net PR/44915: Havard Eidnes:



details:   https://anonhg.NetBSD.org/src/rev/245f999fc85c
branches:  trunk
changeset: 342009:245f999fc85c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 02 18:09:53 2015 +0000

description:
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:

 lib/libc/net/getaddrinfo.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 5f4405469e88 -r 245f999fc85c lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Wed Dec 02 12:36:53 2015 +0000
+++ b/lib/libc/net/getaddrinfo.c        Wed Dec 02 18:09:53 2015 +0000
@@ -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 @@
                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 @@
                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 @@
                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;



Home | Main Index | Thread Index | Old Index