Module Name: src
Committed By: christos
Date: Sun Dec 22 02:45:16 UTC 2013
Modified Files:
src/lib/libc/net: gethnamaddr.c
Log Message:
- 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.
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/lib/libc/net/gethnamaddr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/net/gethnamaddr.c
diff -u src/lib/libc/net/gethnamaddr.c:1.84 src/lib/libc/net/gethnamaddr.c:1.85
--- src/lib/libc/net/gethnamaddr.c:1.84 Tue Aug 27 05:56:12 2013
+++ src/lib/libc/net/gethnamaddr.c Sat Dec 21 21:45:16 2013
@@ -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
_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,
{
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,
* 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++;