Merge in bind-4.9.6 resolver changes. Note that they resolve the
overflow problem differently.
This commit is contained in:
parent
11e226045a
commit
6c5aff806e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26974
@ -55,8 +55,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
|
||||
static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.20 1996/09/28 06:51:07 vixie Exp";
|
||||
static char rcsid[] = "$Id: gethostbydns.c,v 1.20 1997/02/22 15:00:06 peter Exp $";
|
||||
static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: gethostbydns.c,v 1.21 1997/03/12 11:02:00 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -191,6 +191,10 @@ gethostanswer(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;
|
||||
@ -239,11 +243,15 @@ gethostanswer(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;
|
||||
}
|
||||
@ -255,14 +263,14 @@ gethostanswer(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;
|
||||
}
|
||||
@ -303,6 +311,10 @@ gethostanswer(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;
|
||||
}
|
||||
@ -311,6 +323,10 @@ gethostanswer(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);
|
||||
@ -381,8 +397,8 @@ gethostanswer(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;
|
||||
@ -393,8 +409,8 @@ gethostanswer(answer, anslen, qname, qtype)
|
||||
h_errno = NETDB_SUCCESS;
|
||||
return (&host);
|
||||
}
|
||||
try_again:
|
||||
h_errno = TRY_AGAIN;
|
||||
no_recovery:
|
||||
h_errno = NO_RECOVERY;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "$Id$";
|
||||
static char rcsid[] = "$Id: gethostbyht.c,v 1.9 1997/02/22 15:00:07 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -122,8 +122,7 @@ gethostent()
|
||||
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) {
|
||||
@ -160,12 +159,6 @@ gethostent()
|
||||
*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);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "$Id$";
|
||||
static char rcsid[] = "$Id: getnetbydns.c,v 1.10 1997/02/22 15:00:10 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -117,7 +117,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
|
||||
|
@ -43,6 +43,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
|
||||
static char orig_rcsid[] = "From: Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp";
|
||||
static chat rcsid[] = "$Id$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -94,7 +96,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 == '#')
|
||||
|
@ -24,8 +24,7 @@
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)$Id$";
|
||||
static char rcsid[] = "$Id$";
|
||||
static char rcsid[] = "$Id: getnetnamadr.c,v 1.9 1997/02/22 15:00:12 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -55,8 +55,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
|
||||
static char orig_rcsid[] = "From: Id: res_comp.c,v 8.11 1996/12/02 09:17:22 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_comp.c,v 1.10 1997/02/22 15:00:29 peter Exp $";
|
||||
static char orig_rcsid[] = "From: Id: res_comp.c,v 8.12 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_comp.c,v 1.11 1997/06/13 19:21:54 ache Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -91,12 +91,10 @@ 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;
|
||||
if (length > MAXHOSTNAMELEN-1)
|
||||
length = MAXHOSTNAMELEN-1;
|
||||
eom = exp_dn + length;
|
||||
/*
|
||||
* fetch next label in domain name
|
||||
@ -107,6 +105,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);
|
||||
@ -178,6 +179,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) {
|
||||
|
@ -77,8 +77,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
|
||||
static char orig_rcsid[] = "From: Id: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp";
|
||||
static char rcsid[] = "$Id$";
|
||||
static char orig_rcsid[] = "From: Id: res_debug.c,v 8.20 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_debug.c,v 1.13 1997/02/22 15:00:31 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "res_config.h"
|
||||
@ -1112,40 +1112,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);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
|
||||
static char rcsid[] = "$Id$";
|
||||
static char orig_rcsid[] = "From: Id: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_init.c,v 1.12 1997/02/22 15:00:32 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -120,7 +121,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;
|
||||
|
@ -55,8 +55,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
|
||||
static char orig_rcsid = "From: Id: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_query.c,v 1.12 1997/02/22 15:00:34 peter Exp $";
|
||||
static char orig_rcsid = "From: Id: res_query.c,v 8.10 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_query.c,v 1.13 1997/03/24 06:11:44 imp Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -318,7 +318,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;
|
||||
@ -334,15 +334,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));
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
|
||||
static char orig_rcsid[] = "From: Id: res_send.c,v 8.12 1996/10/08 04:51:06 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_send.c,v 1.14 1997/03/10 19:32:46 guido Exp $";
|
||||
static char orig_rcsid[] = "From: Id: res_send.c,v 8.13 1997/06/01 20:34:37 vixie Exp";
|
||||
static char rcsid[] = "$Id: res_send.c,v 1.15 1997/03/12 11:10:54 peter Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
@ -575,11 +575,7 @@ res_send(buf, buflen, ans, anssiz)
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
if (s+1 > FD_SETSIZE) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr,
|
||||
"res_send: too many files\n");
|
||||
#endif
|
||||
Perror(stderr, "s+1 > FD_SETSIZE", EMFILE);
|
||||
res_close();
|
||||
goto next_ns;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user