diff options
| author | christos <christos@NetBSD.org> | 2013-12-22 02:45:16 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2013-12-22 02:45:16 +0000 |
| commit | cefaede168c475cf4f5ff83e2df65965e48b1b5a (patch) | |
| tree | 5e10ffabdccb0a2aadc36cd59d7f46c1696d039c /lib/libc | |
| parent | 47a846a42f84595b446bfe8bd0f6b37d43552653 (diff) | |
- 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.
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/net/gethnamaddr.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/gethnamaddr.c b/lib/libc/net/gethnamaddr.c index 8a7dd1c78a9..247125d656f 100644 --- a/lib/libc/net/gethnamaddr.c +++ b/lib/libc/net/gethnamaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: gethnamaddr.c,v 1.84 2013/08/27 09:56:12 christos Exp $ */ +/* $NetBSD: gethnamaddr.c,v 1.85 2013/12/22 02:45:16 christos Exp $ */ /* * ++Copyright++ 1985, 1988, 1993 @@ -57,7 +57,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.84 2013/08/27 09:56:12 christos Exp $"); +__RCSID("$NetBSD: gethnamaddr.c,v 1.85 2013/12/22 02:45:16 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -514,11 +514,11 @@ gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, _DIAGASSERT(name != NULL); if (res->options & RES_USE_INET6) { - hp = gethostbyname_internal(name, AF_INET6, res, hp, buf, - buflen, he); - if (hp) { + struct hostent *nhp = gethostbyname_internal(name, AF_INET6, + res, hp, buf, buflen, he); + if (nhp) { __res_put_state(res); - return hp; + return nhp; } } hp = gethostbyname_internal(name, AF_INET, res, hp, buf, buflen, he); @@ -547,6 +547,7 @@ gethostbyname_internal(const char *name, int af, res_state res, { const char *cp; struct getnamaddr info; + char hbuf[MAXHOSTNAMELEN]; size_t size; static const ns_dtab dtab[] = { NS_FILES_CB(_hf_gethtbyname, NULL) @@ -580,7 +581,8 @@ gethostbyname_internal(const char *name, int af, res_state res, * this is also done in res_nquery() since we are not the only * function that looks up host names. */ - if (!strchr(name, '.') && (cp = __hostalias(name))) + if (!strchr(name, '.') && (cp = res_hostalias(res, name, + hbuf, sizeof(hbuf)))) name = cp; /* @@ -1128,6 +1130,7 @@ nextline: } goto done; } + naddrs++; while (*cp == ' ' || *cp == '\t') cp++; |
