Source-Changes-HG archive

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

[src/netbsd-1-6]: src/dist/bind/lib/irs Pull up revision 1.2 (requested by it...



details:   https://anonhg.NetBSD.org/src/rev/e51070cf39bd
branches:  netbsd-1-6
changeset: 528217:e51070cf39bd
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Jun 28 11:51:43 2002 +0000

description:
Pull up revision 1.2 (requested by itojun in ticket #387):
Update to BIND 8.3.3.  Fixes buffer overrun in resolver code.

diffstat:

 dist/bind/lib/irs/lcl_gr.c |   8 ++-
 dist/bind/lib/irs/lcl_ho.c |  79 ++++++++++++++++++++++++++++++++++++++++++++-
 dist/bind/lib/irs/lcl_ng.c |  18 ++++++---
 dist/bind/lib/irs/lcl_nw.c |   6 ++-
 dist/bind/lib/irs/lcl_pw.c |   6 ++-
 dist/bind/lib/irs/lcl_sv.c |  17 ++++-----
 6 files changed, 109 insertions(+), 25 deletions(-)

diffs (truncated from 352 to 300 lines):

diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_gr.c
--- a/dist/bind/lib/irs/lcl_gr.c        Fri Jun 28 11:51:23 2002 +0000
+++ b/dist/bind/lib/irs/lcl_gr.c        Fri Jun 28 11:51:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcl_gr.c,v 1.1.1.1 1999/11/20 18:54:10 veego Exp $     */
+/*     $NetBSD: lcl_gr.c,v 1.1.1.1.10.1 2002/06/28 11:51:43 lukem Exp $        */
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -51,7 +51,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "Id: lcl_gr.c,v 1.25 1999/10/13 17:11:19 vixie Exp";
+static const char rcsid[] = "Id: lcl_gr.c,v 1.26 2001/05/29 05:49:03 marka Exp";
 /* from getgrent.c 8.2 (Berkeley) 3/21/94"; */
 /* from BSDI Id: getgrent.c,v 2.8 1996/05/28 18:15:14 bostic Exp $     */
 #endif /* LIBC_SCCS and not lint */
@@ -131,6 +131,8 @@
        struct irs_gr *gr;
        struct pvt *pvt;
 
+       UNUSED(this);
+
        if (!(gr = memget(sizeof *gr))) {
                errno = ENOMEM;
                return (NULL);
@@ -315,7 +317,7 @@
                        continue;
                }
                pvt->group.gr_gid = atoi(p);
-               if (search && name == NULL && pvt->group.gr_gid != gid)
+               if (search && name == NULL && (gid_t)pvt->group.gr_gid != gid)
                        continue;
 
                /* We want this record. */
diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_ho.c
--- a/dist/bind/lib/irs/lcl_ho.c        Fri Jun 28 11:51:23 2002 +0000
+++ b/dist/bind/lib/irs/lcl_ho.c        Fri Jun 28 11:51:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcl_ho.c,v 1.1.1.1 1999/11/20 18:54:10 veego Exp $     */
+/*     $NetBSD: lcl_ho.c,v 1.1.1.1.10.1 2002/06/28 11:51:52 lukem Exp $        */
 
 /*
  * Copyright (c) 1985, 1988, 1993
@@ -54,7 +54,7 @@
 /* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "Id: lcl_ho.c,v 1.25 1999/10/13 17:11:19 vixie Exp";
+static const char rcsid[] = "Id: lcl_ho.c,v 1.26 2001/05/29 05:49:04 marka Exp";
 #endif /* LIBC_SCCS and not lint */
 
 /* Imports. */
@@ -85,6 +85,7 @@
 
 #include "irs_p.h"
 #include "dns_p.h"
+#include "lcl_p.h"
 
 #ifdef SPRINTF_CHAR
 # define SPRINTF(x) strlen(sprintf/**/x)
@@ -138,6 +139,8 @@
 static void            ho_res_set(struct irs_ho *this,
                                   struct __res_state *res,
                                   void (*free_res)(void *));
+static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
+                                    const struct addrinfo *pai);
 
 static size_t          ns_namelen(const char *);
 static int             init(struct irs_ho *this);
@@ -155,6 +158,8 @@
        struct irs_ho *ho;
        struct pvt *pvt;
 
+       UNUSED(this);
+
        if (!(pvt = memget(sizeof *pvt))) {
                errno = ENOMEM;
                return (NULL);
@@ -176,6 +181,7 @@
        ho->minimize = ho_minimize;
        ho->res_get = ho_res_get;
        ho->res_set = ho_res_set;
+       ho->addrinfo = ho_addrinfo;
        return (ho);
 }
 
@@ -259,7 +265,7 @@
            (!memcmp(uaddr, mapped, sizeof mapped) ||
             !memcmp(uaddr, tunnelled, sizeof tunnelled))) {
                /* Unmap. */
-               addr = (u_char *)addr + sizeof mapped;
+               addr = (const u_char *)addr + sizeof mapped;
                uaddr += sizeof mapped;
                af = AF_INET;
                len = INADDRSZ;
@@ -481,6 +487,73 @@
        pvt->free_res = free_res;
 }
 
+struct lcl_res_target {
+       struct lcl_res_target *next;
+       int family;
+};
+
+/* XXX */
+extern struct addrinfo *hostent2addrinfo __P((struct hostent *,
+                                             const struct addrinfo *pai));
+
+static struct addrinfo *
+ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
+{
+       struct pvt *pvt = (struct pvt *)this->private;
+       struct hostent *hp;
+       struct lcl_res_target q, q2, *p;
+       struct addrinfo sentinel, *cur;
+
+       memset(&q, 0, sizeof(q2));
+       memset(&q2, 0, sizeof(q2));
+       memset(&sentinel, 0, sizeof(sentinel));
+       cur = &sentinel;
+
+       switch(pai->ai_family) {
+       case AF_UNSPEC:         /* INET6 then INET4 */
+               q.family = AF_INET6;
+               q.next = &q2;
+               q2.family = AF_INET;
+               break;
+       case AF_INET6:
+               q.family = AF_INET6;
+               break;
+       case AF_INET:
+               q.family = AF_INET;
+               break;
+       default:
+               RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* ??? */
+               return(NULL);
+       }
+
+       for (p = &q; p; p = p->next) {
+               struct addrinfo *ai;
+
+               hp = (*this->byname2)(this, name, p->family);
+               if (hp == NULL) {
+                       /* byname2 should've set an appropriate error */
+                       continue;
+               }
+               if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
+                   (hp->h_addr_list[0] == NULL)) {
+                       RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
+                       continue;
+               }
+
+               ai = hostent2addrinfo(hp, pai);
+               if (ai) {
+                       cur->ai_next = ai;
+                       while (cur && cur->ai_next)
+                               cur = cur->ai_next;
+               }
+       }
+
+       if (sentinel.ai_next == NULL)
+               RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
+
+       return(sentinel.ai_next);
+}
+
 /* Private. */
 
 static size_t
diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_ng.c
--- a/dist/bind/lib/irs/lcl_ng.c        Fri Jun 28 11:51:23 2002 +0000
+++ b/dist/bind/lib/irs/lcl_ng.c        Fri Jun 28 11:51:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcl_ng.c,v 1.1.1.1 1999/11/20 18:54:10 veego Exp $     */
+/*     $NetBSD: lcl_ng.c,v 1.1.1.1.10.1 2002/06/28 11:52:01 lukem Exp $        */
 
 /*
  * Copyright (c) 1996-1999 by Internet Software Consortium.
@@ -18,7 +18,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "Id: lcl_ng.c,v 1.16 1999/10/13 16:39:32 vixie Exp";
+static const char rcsid[] = "Id: lcl_ng.c,v 1.17 2001/05/29 05:49:05 marka Exp";
 #endif
 
 /* Imports */
@@ -41,6 +41,7 @@
 #include "port_after.h"
 
 #include "irs_p.h"
+#include "lcl_p.h"
 
 /* Definitions */
 
@@ -90,7 +91,8 @@
 
 static void            ng_rewind(struct irs_ng *, const char*);
 static void            ng_close(struct irs_ng *);
-static int             ng_next(struct irs_ng *, char **, char **, char **);
+static int             ng_next(struct irs_ng *, const char **,
+                               const char **, const char **);
 static int             ng_test(struct irs_ng *, const char *,
                                const char *, const char *,
                                const char *);
@@ -106,6 +108,8 @@
 irs_lcl_ng(struct irs_acc *this) {
        struct irs_ng *ng;
        struct pvt *pvt;
+
+       UNUSED(this);
        
        if (!(ng = memget(sizeof *ng))) {
                errno = ENOMEM;
@@ -176,7 +180,9 @@
  * Get the next netgroup off the list.
  */
 static int
-ng_next(struct irs_ng *this, char **host, char **user, char **domain) {
+ng_next(struct irs_ng *this, const char **host, const char **user,
+       const char **domain)
+{
        struct pvt *pvt = (struct pvt *)this->private;
        
        if (pvt->nextgrp) {
@@ -196,7 +202,7 @@
 ng_test(struct irs_ng *this, const char *name,
        const char *host, const char *user, const char *domain)
 {
-       char *ng_host, *ng_user, *ng_domain;
+       const char *ng_host, *ng_user, *ng_domain;
 
        ng_rewind(this, name);
        while (ng_next(this, &ng_host, &ng_user, &ng_domain))
@@ -352,7 +358,7 @@
 static struct linelist *
 read_for_group(struct irs_ng *this, const char *group) {
        struct pvt *pvt = (struct pvt *)this->private;
-       char *pos, *spos, *linep, *olinep;
+       char *pos, *spos, *linep = NULL, *olinep;
        int len, olen, cont;
        struct linelist *lp;
        char line[LINSIZ + 1];
diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_nw.c
--- a/dist/bind/lib/irs/lcl_nw.c        Fri Jun 28 11:51:23 2002 +0000
+++ b/dist/bind/lib/irs/lcl_nw.c        Fri Jun 28 11:51:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcl_nw.c,v 1.1.1.1 1999/11/20 18:54:10 veego Exp $     */
+/*     $NetBSD: lcl_nw.c,v 1.1.1.1.10.1 2002/06/28 11:52:10 lukem Exp $        */
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -51,7 +51,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "Id: lcl_nw.c,v 1.21 1999/10/15 19:49:10 vixie Exp";
+static const char rcsid[] = "Id: lcl_nw.c,v 1.22 2001/05/29 05:49:07 marka Exp";
 /* from getgrent.c 8.2 (Berkeley) 3/21/94"; */
 /* from BSDI Id: getgrent.c,v 2.8 1996/05/28 18:15:14 bostic Exp $     */
 #endif /* LIBC_SCCS and not lint */
@@ -124,6 +124,8 @@
        struct irs_nw *nw;
        struct pvt *pvt;
 
+       UNUSED(this);
+
        if (!(pvt = memget(sizeof *pvt))) {
                errno = ENOMEM;
                return (NULL);
diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_pw.c
--- a/dist/bind/lib/irs/lcl_pw.c        Fri Jun 28 11:51:23 2002 +0000
+++ b/dist/bind/lib/irs/lcl_pw.c        Fri Jun 28 11:51:43 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcl_pw.c,v 1.1.1.1 1999/11/20 18:54:10 veego Exp $     */
+/*     $NetBSD: lcl_pw.c,v 1.1.1.1.10.1 2002/06/28 11:52:19 lukem Exp $        */
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -51,7 +51,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "Id: lcl_pw.c,v 1.19 1999/01/18 07:46:57 vixie Exp";
+static const char rcsid[] = "Id: lcl_pw.c,v 1.20 2001/05/29 05:49:08 marka Exp";
 #endif /* LIBC_SCCS and not lint */
 
 /* Extern */
@@ -121,6 +121,8 @@
 irs_lcl_pw(struct irs_acc *this) {
        struct irs_pw *pw;
        struct pvt *pvt;
+
+       UNUSED(this);
                 
         if (!(pw = memget(sizeof *pw))) {
                errno = ENOMEM;
diff -r d6ba8f8048d9 -r e51070cf39bd dist/bind/lib/irs/lcl_sv.c



Home | Main Index | Thread Index | Old Index