summaryrefslogtreecommitdiff
path: root/usr.sbin/named/libresolv
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-05-22 00:47:52 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-05-22 00:47:52 +0000
commitf574c55aa56261d8fc3ce601af6d42c4ebc83fb8 (patch)
treecf686e53be1725a85c2b49d468ffae9daa548f68 /usr.sbin/named/libresolv
parent0d3f8bb38bb58b0a4742f327f9fe73684d125f20 (diff)
bind 4.9.6, 4.9.7 comming soon.
Diffstat (limited to 'usr.sbin/named/libresolv')
-rw-r--r--usr.sbin/named/libresolv/gethnamaddr.c48
-rw-r--r--usr.sbin/named/libresolv/getnetent.c8
-rw-r--r--usr.sbin/named/libresolv/getnetnamadr.c8
-rw-r--r--usr.sbin/named/libresolv/res_comp.c13
-rw-r--r--usr.sbin/named/libresolv/res_debug.c55
-rw-r--r--usr.sbin/named/libresolv/res_init.c9
-rw-r--r--usr.sbin/named/libresolv/res_query.c33
-rw-r--r--usr.sbin/named/libresolv/res_send.c13
8 files changed, 113 insertions, 74 deletions
diff --git a/usr.sbin/named/libresolv/gethnamaddr.c b/usr.sbin/named/libresolv/gethnamaddr.c
index aa93b257643..e60164b728d 100644
--- a/usr.sbin/named/libresolv/gethnamaddr.c
+++ b/usr.sbin/named/libresolv/gethnamaddr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gethnamaddr.c,v 1.1 1997/03/12 10:42:02 downsj Exp $ */
+/* $OpenBSD: gethnamaddr.c,v 1.2 1998/05/22 00:47:18 millert Exp $ */
/*
* ++Copyright++ 1985, 1988, 1993
@@ -58,9 +58,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: gethnamaddr.c,v 8.20 1996/09/28 06:51:07 vixie Exp $";
+static char rcsid[] = "$From: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: gethnamaddr.c,v 1.1 1997/03/12 10:42:02 downsj Exp $";
+static char rcsid[] = "$OpenBSD: gethnamaddr.c,v 1.2 1998/05/22 00:47:18 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -216,6 +216,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;
@@ -260,11 +264,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;
}
@@ -276,14 +284,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;
}
@@ -324,6 +332,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;
}
@@ -332,6 +344,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);
@@ -399,8 +415,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;
@@ -411,8 +427,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);
}
@@ -512,7 +528,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 == '.')
@@ -721,8 +738,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) {
@@ -759,12 +775,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/usr.sbin/named/libresolv/getnetent.c b/usr.sbin/named/libresolv/getnetent.c
index b80ada5f94b..96b0e648773 100644
--- a/usr.sbin/named/libresolv/getnetent.c
+++ b/usr.sbin/named/libresolv/getnetent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetent.c,v 1.1 1997/03/12 10:42:03 downsj Exp $ */
+/* $OpenBSD: getnetent.c,v 1.2 1998/05/22 00:47:19 millert Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -46,9 +46,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: getnetent.c,v 8.3 1996/08/05 08:31:35 vixie Exp $";
+static char rcsid[] = "$From: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: getnetent.c,v 1.1 1997/03/12 10:42:03 downsj Exp $";
+static char rcsid[] = "$OpenBSD: getnetent.c,v 1.2 1998/05/22 00:47:19 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -128,7 +128,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/usr.sbin/named/libresolv/getnetnamadr.c b/usr.sbin/named/libresolv/getnetnamadr.c
index 924bbb1dbb1..5ed407d6d5c 100644
--- a/usr.sbin/named/libresolv/getnetnamadr.c
+++ b/usr.sbin/named/libresolv/getnetnamadr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getnetnamadr.c,v 1.1 1997/03/12 10:42:04 downsj Exp $ */
+/* $OpenBSD: getnetnamadr.c,v 1.2 1998/05/22 00:47:20 millert Exp $ */
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
@@ -44,9 +44,9 @@
#if 0
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[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
+static char rcsid[] = "$From: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.1 1997/03/12 10:42:04 downsj Exp $";
+static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.2 1998/05/22 00:47:20 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -108,7 +108,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/usr.sbin/named/libresolv/res_comp.c b/usr.sbin/named/libresolv/res_comp.c
index a40c00763da..1f71dd70105 100644
--- a/usr.sbin/named/libresolv/res_comp.c
+++ b/usr.sbin/named/libresolv/res_comp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_comp.c,v 1.1 1997/03/12 10:42:08 downsj Exp $ */
+/* $OpenBSD: res_comp.c,v 1.2 1998/05/22 00:47:21 millert Exp $ */
/*
* ++Copyright++ 1985, 1993
@@ -58,9 +58,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: res_comp.c,v 8.11 1996/12/02 09:17:22 vixie Exp $";
+static char rcsid[] = "$From: res_comp.c,v 8.12 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_comp.c,v 1.1 1997/03/12 10:42:08 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_comp.c,v 1.2 1998/05/22 00:47:21 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -100,7 +100,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;
@@ -114,6 +114,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);
@@ -185,6 +188,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/usr.sbin/named/libresolv/res_debug.c b/usr.sbin/named/libresolv/res_debug.c
index ffce419c111..e09e12fb379 100644
--- a/usr.sbin/named/libresolv/res_debug.c
+++ b/usr.sbin/named/libresolv/res_debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_debug.c,v 1.1 1997/03/12 10:42:09 downsj Exp $ */
+/* $OpenBSD: res_debug.c,v 1.2 1998/05/22 00:47:22 millert Exp $ */
/*
* ++Copyright++ 1985, 1990, 1993
@@ -80,9 +80,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $";
+static char rcsid[] = "$From: res_debug.c,v 8.20 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_debug.c,v 1.1 1997/03/12 10:42:09 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_debug.c,v 1.2 1998/05/22 00:47:22 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1136,40 +1136,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/usr.sbin/named/libresolv/res_init.c b/usr.sbin/named/libresolv/res_init.c
index c128e346290..8629d5370e9 100644
--- a/usr.sbin/named/libresolv/res_init.c
+++ b/usr.sbin/named/libresolv/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.2 1997/03/14 03:40:33 downsj Exp $ */
+/* $OpenBSD: res_init.c,v 1.3 1998/05/22 00:47:24 millert Exp $ */
/*
* ++Copyright++ 1985, 1989, 1993
@@ -58,9 +58,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $";
+static char rcsid[] = "$From: res_init.c,v 8.8 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_init.c,v 1.2 1997/03/14 03:40:33 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_init.c,v 1.3 1998/05/22 00:47:24 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -165,7 +165,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;
@@ -438,7 +438,6 @@ res_init()
return (0);
}
-/* ARGSUSED */
static void
res_setoptions(options, source)
char *options, *source;
diff --git a/usr.sbin/named/libresolv/res_query.c b/usr.sbin/named/libresolv/res_query.c
index 852572b1bec..ad91c0374c2 100644
--- a/usr.sbin/named/libresolv/res_query.c
+++ b/usr.sbin/named/libresolv/res_query.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_query.c,v 1.2 1997/03/14 03:40:34 downsj Exp $ */
+/* $OpenBSD: res_query.c,v 1.3 1998/05/22 00:47:25 millert Exp $ */
/*
* ++Copyright++ 1988, 1993
@@ -58,9 +58,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $";
+static char rcsid[] = "$From: res_query.c,v 8.10 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_query.c,v 1.2 1997/03/14 03:40:34 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_query.c,v 1.3 1998/05/22 00:47:25 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -329,7 +329,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;
@@ -345,15 +345,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));
}
@@ -387,8 +398,8 @@ hostalias(name)
break;
for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2)
;
- strncpy(abuf, cp1, sizeof(abuf) - 1);
abuf[sizeof(abuf) - 1] = *cp2 = '\0';
+ strncpy(abuf, cp1, sizeof(abuf) - 1);
fclose(fp);
return (abuf);
}
diff --git a/usr.sbin/named/libresolv/res_send.c b/usr.sbin/named/libresolv/res_send.c
index 437477a3306..436bb8cb9d6 100644
--- a/usr.sbin/named/libresolv/res_send.c
+++ b/usr.sbin/named/libresolv/res_send.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send.c,v 1.1 1997/03/12 10:42:11 downsj Exp $ */
+/* $OpenBSD: res_send.c,v 1.2 1998/05/22 00:47:26 millert Exp $ */
/*
* ++Copyright++ 1985, 1989, 1993
@@ -58,9 +58,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$From: res_send.c,v 8.12 1996/10/08 04:51:06 vixie Exp $";
+static char rcsid[] = "$From: res_send.c,v 8.13 1997/06/01 20:34:37 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_send.c,v 1.1 1997/03/12 10:42:11 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_send.c,v 1.2 1998/05/22 00:47:26 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -607,7 +607,14 @@ read_len:
if ((long) timeout.tv_sec <= 0)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
+ /* XXX - kernel can deal with > FD_SETSIZE */
+ if (s+1 > FD_SETSIZE) {
+ Perror(stderr, "s+1 > FD_SETSIZE", EMFILE);
+ res_close();
+ goto next_ns;
+ }
wait:
+ /* XXX - kernel can deal with > FD_SETSIZE */
FD_ZERO(&dsmask);
FD_SET(s, &dsmask);
n = select(s+1, &dsmask, (fd_set *)NULL,