Source-Changes-HG archive

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

[src/netbsd-6]: src/lib/libc/net Apply additional patches (requested by bad i...



details:   https://anonhg.NetBSD.org/src/rev/ba40d1103ea0
branches:  netbsd-6
changeset: 776532:ba40d1103ea0
user:      riz <riz%NetBSD.org@localhost>
date:      Mon Dec 23 22:56:48 2013 +0000

description:
Apply additional patches (requested by bad in ticket #975):

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.

Fixes additional issues in PR lib/46454

diffstat:

 lib/libc/net/getaddrinfo.c |   7 ++++---
 lib/libc/net/gethnamaddr.c |  17 ++++++++++-------
 2 files changed, 14 insertions(+), 10 deletions(-)

diffs (95 lines):

diff -r 38d55e251141 -r ba40d1103ea0 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c        Thu Dec 19 08:16:56 2013 +0000
+++ b/lib/libc/net/getaddrinfo.c        Mon Dec 23 22:56:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getaddrinfo.c,v 1.96.4.1 2012/06/03 21:41:34 jdc Exp $ */
+/*     $NetBSD: getaddrinfo.c,v 1.96.4.2 2013/12/23 22:56:48 riz Exp $ */
 /*     $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $    */
 
 /*
@@ -55,7 +55,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.96.4.1 2012/06/03 21:41:34 jdc Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.96.4.2 2013/12/23 22:56:48 riz Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -1821,6 +1821,7 @@
        const char *cp, * const *domain;
        HEADER *hp;
        u_int dots;
+       char buf[MAXHOSTNAMELEN];
        int trailing_dot, ret, saved_herrno;
        int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
 
@@ -1841,7 +1842,7 @@
        /*
         * if there aren't any dots, it could be a user-level alias
         */
-       if (!dots && (cp = __hostalias(name)) != NULL) {
+       if (!dots && (cp = res_hostalias(res, name, buf, sizeof(buf))) != NULL) {
                ret = res_queryN(cp, target, res);
                return ret;
        }
diff -r 38d55e251141 -r ba40d1103ea0 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c        Thu Dec 19 08:16:56 2013 +0000
+++ b/lib/libc/net/gethnamaddr.c        Mon Dec 23 22:56:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gethnamaddr.c,v 1.77.4.1 2013/12/18 22:39:32 bouyer Exp $      */
+/*     $NetBSD: gethnamaddr.c,v 1.77.4.2 2013/12/23 22:56:48 riz 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.77.4.1 2013/12/18 22:39:32 bouyer Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.77.4.2 2013/12/23 22:56:48 riz Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -514,11 +514,11 @@
        _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 @@
 {
        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 @@
         * 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 @@
                }
                goto done;
        }
+       naddrs++;
 
        while (*cp == ' ' || *cp == '\t')
                cp++;



Home | Main Index | Thread Index | Old Index