NetBSD-Bugs archive

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

lib/48926: gethostbyname(3) doesn't appear to work under NetBSD-5.2 and NetBSD-6.1.x when hostnames appear only in /etc/hosts

>Number:         48926
>Category:       lib
>Synopsis:       Hostnames only appearing in /etc/hosts are not reachable using 
>gethostbyname(3) or gethostbyname2(3)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 19 08:55:00 +0000 2014
>Originator:     Brian Buhrow
>Release:        NetBSD 5.2_STABLE, NetBSD-6.1.x and probably Netbsd-current
NFB of California
        hello.  It appears that gethostbyname(3) in NetBSD-5.2 and 6.1.x is
broken if the name you're trying to fetch is listed in /etc/hosts and 
nowhere else.  The problem appears to be with this change:

RCS file: /cvsroot/src/lib/libc/net/gethnamaddr.c

date: 2013-12-23 23:12:44 +0000;  author: riz;  state: Exp;  lines: +10 -7;  
commitid: QLuYhA2iZpQzpjix;
Apply patch (requested by bad in ticket #1887):

src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.

src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.

This should finish addressing PR lib/46454

Here are some scripts that demonstrate the problem.  Note I've only shown
the issue under NetbSD-5.1 and 5.2, but NetBSD-6.1.x exhibits the
NetBSD-5.2 broken behavior.

good script started on Wed Jun 18 23:35:48 2014
stats# uname -a
NetBSD stats 5.1_STABLE NetBSD 5.1_STABLE (X2200) #0: Mon Mar 18 11:05:41 PDT 
2013 i386
stats# ident /lib/ |grep 'gethnamaddr'
     $NetBSD: gethnamaddr.c,v 1.73 2007/01/27 22:27:35 christos Exp $
stats# cat /etc/hosts |tail -1 this_host_only_in_etc_hosts
stats# getent hosts this_host_only_in_etc_hosts this_host_only_in_etc_hosts
stats# exit

bad script started on Wed Jun 18 23:38:58 2014
mirkwood# uname -a
NetBSD 5.2_STABLE NetBSD 5.2_STABLE (RBL) #0: Mon Mar 24 
21:42:05 PDT 2014 i386
mirkwood# ident /lib/ |grep 'gethnamaddr'
     $NetBSD: gethnamaddr.c,v 2013/12/23 23:12:44 riz Exp $
mirkwood# cat /etc/hosts |tail -1 this_host_only_in_etc_hosts
mirkwood# getent hosts this_host_only_in_etc_hosts
mirkwood# exit

        I'm not familiar enough with the libc resolver code to feel confident
enough to make a commitable fix.  Has anyone else run into this behavior?
Even better, has anyone found a fix?

See above.


Home | Main Index | Thread Index | Old Index