diff options
Diffstat (limited to 'contrib/bind/res')
-rw-r--r-- | contrib/bind/res/Makefile | 5 | ||||
-rw-r--r-- | contrib/bind/res/gethnamaddr.c | 44 | ||||
-rw-r--r-- | contrib/bind/res/getnetent.c | 4 | ||||
-rw-r--r-- | contrib/bind/res/getnetnamadr.c | 4 | ||||
-rw-r--r-- | contrib/bind/res/res_comp.c | 9 | ||||
-rw-r--r-- | contrib/bind/res/res_debug.c | 51 | ||||
-rw-r--r-- | contrib/bind/res/res_init.c | 4 | ||||
-rw-r--r-- | contrib/bind/res/res_query.c | 27 | ||||
-rw-r--r-- | contrib/bind/res/res_send.c | 7 |
9 files changed, 96 insertions, 59 deletions
diff --git a/contrib/bind/res/Makefile b/contrib/bind/res/Makefile index 8aaabab..834d74a 100644 --- a/contrib/bind/res/Makefile +++ b/contrib/bind/res/Makefile @@ -1,6 +1,6 @@ # # from @(#)Makefile 5.16 (Berkeley) 3/14/88 -# $Id: Makefile,v 8.13 1996/08/08 22:49:48 vixie Exp $ +# $Id: Makefile,v 8.14 1997/06/01 20:34:37 vixie Exp $ # ## ++Copyright++ 1988, 1995 @@ -99,8 +99,7 @@ ${DESTDIR}${DESTLIB}/libresolv.a: libresolv.a .c.o: ${CC} ${CFLAGS} -c $*.c - -${LDS} ld -x -r $*.o - ${LDS} mv a.out $*.o + -${LDS} ld -x -r $*.o && ${LDS} mv a.out $*.o clean: FRC rm -f errs a.out core libresolv.a tags .depend diff --git a/contrib/bind/res/gethnamaddr.c b/contrib/bind/res/gethnamaddr.c index 8cc26eb..65b9729 100644 --- a/contrib/bind/res/gethnamaddr.c +++ b/contrib/bind/res/gethnamaddr.c @@ -55,7 +55,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: gethnamaddr.c,v 8.20 1996/09/28 06:51:07 vixie Exp $"; +static char rcsid[] = "$Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -210,6 +210,10 @@ getanswer(answer, anslen, qname, qtype) * (i.e., with the succeeding search-domain tacked on). */ n = strlen(bp) + 1; /* for the \0 */ + if (n >= MAXHOSTNAMELEN) { + h_errno = NO_RECOVERY; + return (NULL); + } host.h_name = bp; bp += n; buflen -= n; @@ -254,11 +258,15 @@ getanswer(answer, anslen, qname, qtype) /* Store alias. */ *ap++ = bp; n = strlen(bp) + 1; /* for the \0 */ + if (n >= MAXHOSTNAMELEN) { + had_error++; + continue; + } bp += n; buflen -= n; /* Get canonical name. */ n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen) { + if (n > buflen || n >= MAXHOSTNAMELEN) { had_error++; continue; } @@ -270,14 +278,14 @@ getanswer(answer, anslen, qname, qtype) } if (qtype == T_PTR && type == T_CNAME) { n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); - if ((n < 0) || !res_hnok(tbuf)) { + if (n < 0 || !res_dnok(tbuf)) { had_error++; continue; } cp += n; /* Get canonical name. */ n = strlen(tbuf) + 1; /* for the \0 */ - if (n > buflen) { + if (n > buflen || n >= MAXHOSTNAMELEN) { had_error++; continue; } @@ -318,6 +326,10 @@ getanswer(answer, anslen, qname, qtype) n = -1; if (n != -1) { n = strlen(bp) + 1; /* for the \0 */ + if (n >= MAXHOSTNAMELEN) { + had_error++; + break; + } bp += n; buflen -= n; } @@ -326,6 +338,10 @@ getanswer(answer, anslen, qname, qtype) host.h_name = bp; if (_res.options & RES_USE_INET6) { n = strlen(bp) + 1; /* for the \0 */ + if (n >= MAXHOSTNAMELEN) { + had_error++; + break; + } bp += n; buflen -= n; map_v4v6_hostent(&host, &bp, &buflen); @@ -393,8 +409,8 @@ getanswer(answer, anslen, qname, qtype) # endif /*RESOLVSORT*/ if (!host.h_name) { n = strlen(qname) + 1; /* for the \0 */ - if (n > buflen) - goto try_again; + if (n > buflen || n >= MAXHOSTNAMELEN) + goto no_recovery; strcpy(bp, qname); host.h_name = bp; bp += n; @@ -405,8 +421,8 @@ getanswer(answer, anslen, qname, qtype) h_errno = NETDB_SUCCESS; return (&host); } - try_again: - h_errno = TRY_AGAIN; + no_recovery: + h_errno = NO_RECOVERY; return (NULL); } @@ -506,7 +522,8 @@ gethostbyname2(name, af) if (!isdigit(*cp) && *cp != '.') break; } - if (isxdigit(name[0]) || name[0] == ':') + if ((isxdigit(name[0]) && strchr(name, ':') != NULL) || + name[0] == ':') for (cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') @@ -715,8 +732,7 @@ _gethtent() if (!(cp = strpbrk(p, " \t"))) goto again; *cp++ = '\0'; - if ((_res.options & RES_USE_INET6) && - inet_pton(AF_INET6, p, host_addr) > 0) { + if (inet_pton(AF_INET6, p, host_addr) > 0) { af = AF_INET6; len = IN6ADDRSZ; } else if (inet_pton(AF_INET, p, host_addr) > 0) { @@ -753,12 +769,6 @@ _gethtent() *cp++ = '\0'; } *q = NULL; - if (_res.options & RES_USE_INET6) { - char *bp = hostbuf; - int buflen = sizeof hostbuf; - - map_v4v6_hostent(&host, &bp, &buflen); - } h_errno = NETDB_SUCCESS; return (&host); } diff --git a/contrib/bind/res/getnetent.c b/contrib/bind/res/getnetent.c index 24ee286..18e5d26 100644 --- a/contrib/bind/res/getnetent.c +++ b/contrib/bind/res/getnetent.c @@ -43,7 +43,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: getnetent.c,v 8.3 1996/08/05 08:31:35 vixie Exp $"; +static char rcsid[] = "$Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -122,7 +122,7 @@ getnetent() if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) return (NULL); again: - p = fgets(line, BUFSIZ, netf); + p = fgets(line, sizeof line, netf); if (p == NULL) return (NULL); if (*p == '#') diff --git a/contrib/bind/res/getnetnamadr.c b/contrib/bind/res/getnetnamadr.c index d2f33a1..d9f06f1 100644 --- a/contrib/bind/res/getnetnamadr.c +++ b/contrib/bind/res/getnetnamadr.c @@ -41,7 +41,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93"; static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; -static char rcsid[] = "$Id: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $"; +static char rcsid[] = "$Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -102,7 +102,7 @@ getnetanswer(answer, anslen, net_i) char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap, *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0; static struct netent net_entry; -static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1]; +static char *net_aliases[MAXALIASES], netbuf[PACKETSZ]; /* * find first satisfactory answer diff --git a/contrib/bind/res/res_comp.c b/contrib/bind/res/res_comp.c index 5008d47..e21a9fb 100644 --- a/contrib/bind/res/res_comp.c +++ b/contrib/bind/res/res_comp.c @@ -55,7 +55,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_comp.c,v 8.11 1996/12/02 09:17:22 vixie Exp $"; +static char rcsid[] = "$Id: res_comp.c,v 8.12 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -94,7 +94,7 @@ dn_expand(msg, eomorig, comp_dn, exp_dn, length) register char *dn; register int n, c; char *eom; - int len = -1, checked = 0; + int len = -1, checked = 0, octets = 0; dn = exp_dn; cp = comp_dn; @@ -108,6 +108,9 @@ dn_expand(msg, eomorig, comp_dn, exp_dn, length) */ switch (n & INDIR_MASK) { case 0: + octets += (n + 1); + if (octets > MAXCDNAME) + return (-1); if (dn != exp_dn) { if (dn >= eom) return (-1); @@ -179,6 +182,8 @@ dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) dn = (u_char *)exp_dn; cp = comp_dn; + if (length > MAXCDNAME) + length = MAXCDNAME; eob = cp + length; lpp = cpp = NULL; if (dnptrs != NULL) { diff --git a/contrib/bind/res/res_debug.c b/contrib/bind/res/res_debug.c index 74dda53..48512fa 100644 --- a/contrib/bind/res/res_debug.c +++ b/contrib/bind/res/res_debug.c @@ -77,7 +77,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $"; +static char rcsid[] = "$Id: res_debug.c,v 8.20 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -1130,40 +1130,47 @@ static u_int8_t precsize_aton(strptr) char **strptr; { - unsigned int mval = 0, cmval = 0; u_int8_t retval = 0; - register char *cp; - register int exponent; - register int mantissa; + char *cp; + int exponent = 0; + int mantissa = 0; cp = *strptr; + while (isdigit(*cp)) { + if (mantissa == 0) + mantissa = *cp - '0'; + else + exponent++; + cp++; + } - while (isdigit(*cp)) - mval = mval * 10 + (*cp++ - '0'); - - if (*cp == '.') { /* centimeters */ + if (*cp == '.') { cp++; if (isdigit(*cp)) { - cmval = (*cp++ - '0') * 10; + if (mantissa == 0) + mantissa = *cp - '0'; + else + exponent++; + cp++; + if (isdigit(*cp)) { - cmval += (*cp++ - '0'); + if (mantissa == 0) + mantissa = *cp - '0'; + else + exponent++; + cp++; } + else + exponent++; } } - cmval = (mval * 100) + cmval; - - for (exponent = 0; exponent < 9; exponent++) - if (cmval < poweroften[exponent+1]) - break; - - mantissa = cmval / poweroften[exponent]; - if (mantissa > 9) - mantissa = 9; + else + exponent += 2; + if (mantissa == 0) + exponent = 0; retval = (mantissa << 4) | exponent; - *strptr = cp; - return (retval); } diff --git a/contrib/bind/res/res_init.c b/contrib/bind/res/res_init.c index c0314c5..de20465 100644 --- a/contrib/bind/res/res_init.c +++ b/contrib/bind/res/res_init.c @@ -55,7 +55,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; -static char rcsid[] = "$Id: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; +static char rcsid[] = "$Id: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -159,7 +159,7 @@ res_init() register FILE *fp; register char *cp, **pp; register int n; - char buf[BUFSIZ]; + char buf[MAXDNAME]; int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; diff --git a/contrib/bind/res/res_query.c b/contrib/bind/res/res_query.c index d2700e4..76d4b8c 100644 --- a/contrib/bind/res/res_query.c +++ b/contrib/bind/res/res_query.c @@ -55,7 +55,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; +static char rcsid[] = "$Id: res_query.c,v 8.10 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -323,7 +323,7 @@ res_querydomain(name, domain, class, type, answer, anslen) { char nbuf[MAXDNAME]; const char *longname = nbuf; - int n; + int n, d; if ((_res.options & RES_INIT) == 0 && res_init() == -1) { h_errno = NETDB_INTERNAL; @@ -339,15 +339,26 @@ res_querydomain(name, domain, class, type, answer, anslen) * Check for trailing '.'; * copy without '.' if present. */ - n = strlen(name) - 1; - if (n != (0 - 1) && name[n] == '.' && n < sizeof(nbuf) - 1) { - bcopy(name, nbuf, n); + n = strlen(name); + if (n >= MAXDNAME) { + h_errno = NO_RECOVERY; + return (-1); + } + n--; + if (n >= 0 && name[n] == '.') { + strncpy(nbuf, name, n); nbuf[n] = '\0'; } else longname = name; - } else - sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain); - + } else { + n = strlen(name); + d = strlen(domain); + if (n + d + 1 >= MAXDNAME) { + h_errno = NO_RECOVERY; + return (-1); + } + sprintf(nbuf, "%s.%s", name, domain); + } return (res_query(longname, class, type, answer, anslen)); } diff --git a/contrib/bind/res/res_send.c b/contrib/bind/res/res_send.c index da9b9ec..0e0dafd 100644 --- a/contrib/bind/res/res_send.c +++ b/contrib/bind/res/res_send.c @@ -55,7 +55,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_send.c,v 8.12 1996/10/08 04:51:06 vixie Exp $"; +static char rcsid[] = "$Id: res_send.c,v 8.13 1997/06/01 20:34:37 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ /* change this to "0" @@ -601,6 +601,11 @@ read_len: if ((long) timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0; + if (s+1 > FD_SETSIZE) { + Perror(stderr, "s+1 > FD_SETSIZE", EMFILE); + res_close(); + goto next_ns; + } wait: FD_ZERO(&dsmask); FD_SET(s, &dsmask); |