Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/net fix behavior when there's dangling CNAME on spe...



details:   https://anonhg.NetBSD.org/src/rev/c8e77fb9eb9d
branches:  trunk
changeset: 474336:c8e77fb9eb9d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sun Jul 04 00:33:14 1999 +0000

description:
fix behavior when there's dangling CNAME on specific AF.
TODO: have getipnodeby{name,addr} and let them do the trick.

diffstat:

 lib/libc/net/getaddrinfo.c |  29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diffs (63 lines):

diff -r 6108b7f34ba8 -r c8e77fb9eb9d lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Sun Jul 04 00:31:57 1999 +0000
+++ b/lib/libc/net/getaddrinfo.c        Sun Jul 04 00:33:14 1999 +0000
@@ -512,29 +512,40 @@
 }
 
 static int
-get_addr(hostname, af, res, pai, port0)
+get_addr(hostname, af, res0, pai, port0)
        const char *hostname;
        int af;
-       struct addrinfo **res;
+       struct addrinfo **res0;
        struct addrinfo *pai;
        int port0;
 {
 #ifdef USE_GETIPNODEBY
        return get_addr0(hostname, af, res, pai, port0);
 #else
-       int i, error;
+       int i, error, ekeep;
        struct addrinfo *cur;
+       struct addrinfo **res;
 
+       res = res0;
+       ekeep = 0;
        for (i = 0; afdl[i].a_af; i++) {
                if (af == AF_UNSPEC || af == afdl[i].a_af) 
                        ;
                else
                        continue;
+               /* It is WRONG, we need getipnodebyname(). */
+again:
                error = get_addr0(hostname, afdl[i].a_af, res, pai, port0);
-               if (error == EAI_FAIL)
+               switch (error) {
+               case EAI_AGAIN:
+                       goto again;
+               case EAI_FAIL:
                        return error;
-               else
-                       error = 0;
+               default:
+                       if (ekeep == 0)
+                               ekeep = error;
+                       break;
+               }
                if (*res) {
                        /* make chain of addrs */
                        for (cur = *res;
@@ -547,7 +558,11 @@
                }
        }
 
-       return error;
+       /* if we got something, it's okay */
+       if (*res0)
+               return 0;
+
+       return error ? error : ekeep;
 #endif
 }
 



Home | Main Index | Thread Index | Old Index