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 name resolution problem when you have "host...



details:   https://anonhg.NetBSD.org/src/rev/f605e2079539
branches:  trunk
changeset: 474416:f605e2079539
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Jul 06 02:00:41 1999 +0000

description:
fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
  state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921

diffstat:

 lib/libc/net/getaddrinfo.c |   4 +---
 lib/libc/net/gethnamaddr.c |  11 +++++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r e94d9f9660b9 -r f605e2079539 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Mon Jul 05 22:40:34 1999 +0000
+++ b/lib/libc/net/getaddrinfo.c        Tue Jul 06 02:00:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getaddrinfo.c,v 1.7 1999/07/04 02:02:29 lukem Exp $    */
+/*     $NetBSD: getaddrinfo.c,v 1.8 1999/07/06 02:00:41 itojun Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -541,8 +541,6 @@
                switch (error) {
                case EAI_AGAIN:
                        goto again;
-               case EAI_FAIL:
-                       return error;
                default:
                        if (ekeep == 0)
                                ekeep = error;
diff -r e94d9f9660b9 -r f605e2079539 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c        Mon Jul 05 22:40:34 1999 +0000
+++ b/lib/libc/net/gethnamaddr.c        Tue Jul 06 02:00:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gethnamaddr.c,v 1.20 1999/07/04 22:44:28 itojun Exp $  */
+/*     $NetBSD: gethnamaddr.c,v 1.21 1999/07/06 02:00:41 itojun Exp $  */
 
 /*
  * ++Copyright++ 1985, 1988, 1993
@@ -61,7 +61,7 @@
 static char sccsid[] = "@(#)gethostnamadr.c    8.1 (Berkeley) 6/4/93";
 static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
 #else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.20 1999/07/04 22:44:28 itojun Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.21 1999/07/06 02:00:41 itojun Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -727,6 +727,11 @@
        } else {
                goto again;
        }
+       /* if this is not something we're looking for, skip it. */
+       if (host.h_addrtype != af)
+               goto again;
+       if (host.h_length != len)
+               goto again;
        h_addr_ptrs[0] = (char *)host_addr;
        h_addr_ptrs[1] = NULL;
        host.h_addr_list = h_addr_ptrs;
@@ -885,6 +890,8 @@
        len = va_arg(ap, int);
        af = va_arg(ap, int);
        
+       host.h_length = len;
+       host.h_addrtype = af;
 
        _sethtent(0);
        while ((p = _gethtent()) != NULL)



Home | Main Index | Thread Index | Old Index