summaryrefslogtreecommitdiffstats
path: root/contrib/bind/lib/resolv
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2003-06-17 08:25:13 +0000
committerdougb <dougb@FreeBSD.org>2003-06-17 08:25:13 +0000
commitf97237131f327c9eda67f546f7acffceef5a9fde (patch)
tree04f9050731919faa97a44a524d6a4129aea8e98d /contrib/bind/lib/resolv
parent02f065cde2cf18b6e76deab6f48d7aeb327bd639 (diff)
downloadFreeBSD-src-f97237131f327c9eda67f546f7acffceef5a9fde.zip
FreeBSD-src-f97237131f327c9eda67f546f7acffceef5a9fde.tar.gz
Import of ISC BIND version 8.3.6.
Version 8.3.5 was skipped due to bugs fixed in this version.
Diffstat (limited to 'contrib/bind/lib/resolv')
-rw-r--r--contrib/bind/lib/resolv/res_comp.c8
-rw-r--r--contrib/bind/lib/resolv/res_debug.c38
-rw-r--r--contrib/bind/lib/resolv/res_findzonecut.c113
-rw-r--r--contrib/bind/lib/resolv/res_init.c51
-rw-r--r--contrib/bind/lib/resolv/res_mkquery.c72
-rw-r--r--contrib/bind/lib/resolv/res_mkupdate.c68
-rw-r--r--contrib/bind/lib/resolv/res_private.h1
-rw-r--r--contrib/bind/lib/resolv/res_query.c9
-rw-r--r--contrib/bind/lib/resolv/res_send.c9
-rw-r--r--contrib/bind/lib/resolv/res_update.c15
10 files changed, 257 insertions, 127 deletions
diff --git a/contrib/bind/lib/resolv/res_comp.c b/contrib/bind/lib/resolv/res_comp.c
index d972848..15de91a 100644
--- a/contrib/bind/lib/resolv/res_comp.c
+++ b/contrib/bind/lib/resolv/res_comp.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 8.15 1999/10/13 16:39:39 vixie Exp $";
+static const char rcsid[] = "$Id: res_comp.c,v 8.16 2002/08/07 03:47:34 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -86,10 +86,10 @@ static const char rcsid[] = "$Id: res_comp.c,v 8.15 1999/10/13 16:39:39 vixie Ex
#include "port_after.h"
/*
- * Expand compressed domain name 'comp_dn' to full domain name.
+ * Expand compressed domain name 'src' to full domain name.
* 'msg' is a pointer to the begining of the message,
- * 'eomorig' points to the first location after the message,
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
+ * 'eom' points to the first location after the message,
+ * 'dst' is a pointer to a buffer of size 'dstsiz' for the result.
* Return size of compressed name or -1 if there was an error.
*/
int
diff --git a/contrib/bind/lib/resolv/res_debug.c b/contrib/bind/lib/resolv/res_debug.c
index f2c0689..392796a 100644
--- a/contrib/bind/lib/resolv/res_debug.c
+++ b/contrib/bind/lib/resolv/res_debug.c
@@ -95,7 +95,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_debug.c,v 8.46 2002/05/21 01:57:45 marka Exp $";
+static const char rcsid[] = "$Id: res_debug.c,v 8.49.6.1 2003/06/04 01:09:43 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -615,9 +615,6 @@ p_option(u_long option) {
#ifdef RES_USE_EDNS0 /* KAME extension */
case RES_USE_EDNS0: return "edns0";
#endif
-#ifdef RES_USE_A6
- case RES_USE_A6: return "a6";
-#endif
#ifdef RES_USE_DNAME
case RES_USE_DNAME: return "dname";
#endif
@@ -655,6 +652,33 @@ p_rcode(int rcode) {
}
/*
+ * Return a string for a res_sockaddr_union.
+ */
+const char *
+p_sockun(union res_sockaddr_union u, char *buf, size_t size) {
+ char ret[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:123.123.123.123"];
+
+ switch (u.sin.sin_family) {
+ case AF_INET:
+ inet_ntop(AF_INET, &u.sin.sin_addr, ret, sizeof ret);
+ break;
+#ifdef HAS_INET6_STRUCTS
+ case AF_INET6:
+ inet_ntop(AF_INET6, &u.sin6.sin6_addr, ret, sizeof ret);
+ break;
+#endif
+ default:
+ sprintf(ret, "[af%d]", u.sin.sin_family);
+ break;
+ }
+ if (size > 0) {
+ strncpy(buf, ret, size - 1);
+ buf[size - 1] = '0';
+ }
+ return (buf);
+}
+
+/*
* routines to convert between on-the-wire RR format and zone file format.
* Does not contain conversion to/from decimal degrees; divide or multiply
* by 60*60*1000 for that.
@@ -1101,8 +1125,9 @@ res_nametoclass(const char *buf, int *successp) {
if (strncasecmp(buf, "CLASS", 5) != 0 ||
!isdigit((unsigned char)buf[5]))
goto done;
+ errno = 0;
result = strtoul(buf + 5, &endptr, 10);
- if (*endptr == '\0' && result <= 0xffff)
+ if (errno == 0 && *endptr == '\0' && result <= 0xffff)
success = 1;
done:
if (successp)
@@ -1123,8 +1148,9 @@ res_nametotype(const char *buf, int *successp) {
if (strncasecmp(buf, "type", 4) != 0 ||
!isdigit((unsigned char)buf[4]))
goto done;
+ errno = 0;
result = strtoul(buf + 4, &endptr, 10);
- if (*endptr == '\0' && result <= 0xffff)
+ if (errno == 0 && *endptr == '\0' && result <= 0xffff)
success = 1;
done:
if (successp)
diff --git a/contrib/bind/lib/resolv/res_findzonecut.c b/contrib/bind/lib/resolv/res_findzonecut.c
index a82c3f1..018ec4d 100644
--- a/contrib/bind/lib/resolv/res_findzonecut.c
+++ b/contrib/bind/lib/resolv/res_findzonecut.c
@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 8.16 2002/04/12 06:27:46 marka Exp $";
+static const char rcsid[] = "$Id: res_findzonecut.c,v 8.17.6.2 2003/06/02 09:24:40 marka Exp $";
#endif /* not lint */
/*
@@ -49,19 +49,21 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 8.16 2002/04/12 06:27:46 m
typedef struct rr_a {
LINK(struct rr_a) link;
- union res_sockaddr_union addr;
+ union res_sockaddr_union addr;
} rr_a;
typedef LIST(rr_a) rrset_a;
typedef struct rr_ns {
LINK(struct rr_ns) link;
const char * name;
- int have_v4;
- int have_v6;
+ unsigned int flags;
rrset_a addrs;
} rr_ns;
typedef LIST(rr_ns) rrset_ns;
+#define RR_NS_HAVE_V4 0x01
+#define RR_NS_HAVE_V6 0x02
+
/* Forward. */
static int satisfy(res_state, const char *, rrset_ns *,
@@ -149,7 +151,8 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
int
res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
- char *zname, size_t zsize, struct in_addr *addrs, int naddrs) {
+ char *zname, size_t zsize, struct in_addr *addrs, int naddrs)
+{
int result, i;
union res_sockaddr_union *u;
@@ -267,7 +270,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
rrset_ns *nsrrsp)
{
char tname[NS_MAXDNAME];
- u_char resp[NS_PACKETSZ];
+ u_char *resp = NULL;
int n, i, ancount, nscount;
ns_sect sect;
ns_msg msg;
@@ -279,9 +282,13 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
/* First canonicalize dname (exactly one unescaped trailing "."). */
if (ns_makecanon(dname, tname, sizeof tname) < 0)
- return (-1);
+ goto cleanup;
dname = tname;
+ resp = malloc(NS_MAXMSG);
+ if (resp == NULL)
+ goto cleanup;
+
/* Now grovel the subdomains, hunting for an SOA answer or auth. */
for (;;) {
/* Leading or inter-label '.' are skipped here. */
@@ -293,7 +300,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (n < 0) {
DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
dname, p_class(class), n));
- return (-1);
+ goto cleanup;
}
if (n > 0) {
DPRINTF(("get_soa: CNAME or DNAME found"));
@@ -318,7 +325,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (ns_parserr(&msg, sect, i, &rr) < 0) {
DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
p_section(sect, ns_o_query), i));
- return (-1);
+ goto cleanup;
}
if (ns_rr_type(rr) == ns_t_cname ||
ns_rr_type(rr) == ns_t_dname)
@@ -330,19 +337,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
switch (sect) {
case ns_s_an:
if (ns_samedomain(dname, t) == 0) {
- DPRINTF(("get_soa: ns_samedomain('%s', '%s') == 0",
- dname, t));
+ DPRINTF(
+ ("get_soa: ns_samedomain('%s', '%s') == 0",
+ dname, t)
+ );
errno = EPROTOTYPE;
- return (-1);
+ goto cleanup;
}
break;
case ns_s_ns:
if (ns_samename(dname, t) == 1 ||
ns_samedomain(dname, t) == 0) {
- DPRINTF(("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
- dname, t));
+ DPRINTF(
+ ("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
+ dname, t)
+ );
errno = EPROTOTYPE;
- return (-1);
+ goto cleanup;
}
break;
default:
@@ -352,21 +363,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
DPRINTF(("get_soa: zname(%d) too small (%d)",
zsize, strlen(t) + 1));
errno = EMSGSIZE;
- return (-1);
+ goto cleanup;
}
strcpy(zname, t);
rdata = ns_rr_rdata(rr);
rdlen = ns_rr_rdlen(rr);
if (ns_name_uncompress(resp, ns_msg_end(msg), rdata,
mname, msize) < 0) {
- DPRINTF(("get_soa: ns_name_uncompress failed"));
- return (-1);
+ DPRINTF(("get_soa: ns_name_uncompress failed")
+ );
+ goto cleanup;
}
if (save_ns(statp, &msg, ns_s_ns,
zname, class, opts, nsrrsp) < 0) {
DPRINTF(("get_soa: save_ns failed"));
- return (-1);
+ goto cleanup;
}
+ free(resp);
return (0);
}
@@ -379,13 +392,16 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (*dname == '\\')
if (*++dname == '\0') {
errno = EMSGSIZE;
- return (-1);
+ goto cleanup;
}
dname++;
}
}
DPRINTF(("get_soa: out of labels"));
errno = EDESTADDRREQ;
+ cleanup:
+ if (resp != NULL)
+ free(resp);
return (-1);
}
@@ -393,15 +409,20 @@ static int
get_ns(res_state statp, const char *zname, ns_class class, int opts,
rrset_ns *nsrrsp)
{
- u_char resp[NS_PACKETSZ];
+ u_char *resp;
ns_msg msg;
int n;
+ resp = malloc(NS_MAXMSG);
+ if (resp == NULL)
+ return (-1);
+
/* Go and get the NS RRs for this zone. */
n = do_query(statp, zname, class, ns_t_ns, resp, &msg);
if (n != 0) {
DPRINTF(("get_ns: do_query('%s', %s) failed (%d)",
zname, p_class(class), n));
+ free(resp);
return (-1);
}
@@ -409,31 +430,38 @@ get_ns(res_state statp, const char *zname, ns_class class, int opts,
if (save_ns(statp, &msg, ns_s_an, zname, class, opts, nsrrsp) < 0) {
DPRINTF(("get_ns save_ns('%s', %s) failed",
zname, p_class(class)));
+ free(resp);
return (-1);
}
+ free(resp);
return (0);
}
static int
get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
rr_ns *nsrr, *nsrr_n;
+ u_char *resp;
+
+ resp = malloc(NS_MAXMSG);
+ if (resp == NULL)
+ return(-1);
/* Go and get the A RRs for each empty NS RR on our list. */
for (nsrr = HEAD(*nsrrsp); nsrr != NULL; nsrr = nsrr_n) {
- u_char resp[NS_PACKETSZ];
ns_msg msg;
int n;
nsrr_n = NEXT(nsrr, link);
- if (!nsrr->have_v4) {
+ if ((nsrr->flags & RR_NS_HAVE_V4) == 0) {
n = do_query(statp, nsrr->name, class, ns_t_a,
resp, &msg);
if (n < 0) {
- DPRINTF(("get_glue: do_query('%s', %s') failed",
- nsrr->name, p_class(class)));
- return (-1);
+ DPRINTF(
+ ("get_glue: do_query('%s', %s') failed",
+ nsrr->name, p_class(class)));
+ goto cleanup;
}
if (n > 0) {
DPRINTF((
@@ -444,17 +472,18 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
opts, nsrr) < 0) {
DPRINTF(("get_glue: save_r('%s', %s) failed",
nsrr->name, p_class(class)));
- return (-1);
+ goto cleanup;
}
}
- if (!nsrr->have_v6) {
+ if ((nsrr->flags & RR_NS_HAVE_V6) == 0) {
n = do_query(statp, nsrr->name, class, ns_t_aaaa,
resp, &msg);
if (n < 0) {
- DPRINTF(("get_glue: do_query('%s', %s') failed",
- nsrr->name, p_class(class)));
- return (-1);
+ DPRINTF(
+ ("get_glue: do_query('%s', %s') failed",
+ nsrr->name, p_class(class)));
+ goto cleanup;
}
if (n > 0) {
DPRINTF((
@@ -465,7 +494,7 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
opts, nsrr) < 0) {
DPRINTF(("get_glue: save_r('%s', %s) failed",
nsrr->name, p_class(class)));
- return (-1);
+ goto cleanup;
}
}
@@ -476,7 +505,12 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
free_nsrr(nsrrsp, nsrr);
}
}
+ free(resp);
return (0);
+
+ cleanup:
+ free(resp);
+ return (-1);
}
static int
@@ -514,7 +548,8 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
if (ns_name_uncompress(ns_msg_base(*msg),
ns_msg_end(*msg), rdata,
tname, sizeof tname) < 0) {
- DPRINTF(("save_ns: ns_name_uncompress failed"));
+ DPRINTF(("save_ns: ns_name_uncompress failed")
+ );
free(nsrr);
return (-1);
}
@@ -526,8 +561,7 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
}
INIT_LINK(nsrr, link);
INIT_LIST(nsrr->addrs);
- nsrr->have_v4 = 0;
- nsrr->have_v6 = 0;
+ nsrr->flags = 0;
APPEND(*nsrrsp, nsrr, link);
}
if (save_a(statp, msg, ns_s_ar,
@@ -556,7 +590,8 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
p_section(sect, ns_o_query), i));
return (-1);
}
- if ((ns_rr_type(rr) != ns_t_a && ns_rr_type(rr) != ns_t_aaaa) ||
+ if ((ns_rr_type(rr) != ns_t_a &&
+ ns_rr_type(rr) != ns_t_aaaa) ||
ns_rr_class(rr) != class ||
ns_samename(ns_rr_name(rr), owner) != 1 ||
ns_rr_rdlen(rr) != NS_INADDRSZ)
@@ -581,7 +616,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
memcpy(&arr->addr.sin.sin_addr, ns_rr_rdata(rr),
NS_INADDRSZ);
arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
- nsrr->have_v4 = 1;
+ nsrr->flags |= RR_NS_HAVE_V4;
break;
case ns_t_aaaa:
arr->addr.sin6.sin6_family = AF_INET6;
@@ -590,7 +625,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
#endif
memcpy(&arr->addr.sin6.sin6_addr, ns_rr_rdata(rr), 16);
arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
- nsrr->have_v6 = 1;
+ nsrr->flags |= RR_NS_HAVE_V6;
break;
default:
abort();
@@ -646,7 +681,7 @@ do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
DPRINTF(("do_query: res_nmkquery failed"));
return (-1);
}
- n = res_nsend(statp, req, n, resp, NS_PACKETSZ);
+ n = res_nsend(statp, req, n, resp, NS_MAXMSG);
if (n < 0) {
DPRINTF(("do_query: res_nsend failed"));
return (-1);
diff --git a/contrib/bind/lib/resolv/res_init.c b/contrib/bind/lib/resolv/res_init.c
index 9f99d14..7e507be 100644
--- a/contrib/bind/lib/resolv/res_init.c
+++ b/contrib/bind/lib/resolv/res_init.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 8.29 2002/05/31 06:05:31 marka Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 8.32 2003/04/03 06:31:10 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -161,6 +161,7 @@ __res_vinit(res_state statp, int preinit) {
char *net;
#endif
int dots;
+ union res_sockaddr_union u[2];
if (!preinit) {
statp->retrans = RES_TIMEOUT;
@@ -172,17 +173,32 @@ __res_vinit(res_state statp, int preinit) {
if ((statp->options & RES_INIT) != 0)
res_ndestroy(statp);
+ memset(u, 0, sizeof(u));
#ifdef USELOOPBACK
- statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
+ u[nserv].sin.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
#else
- statp->nsaddr.sin_addr.s_addr = INADDR_ANY;
+ u[nserv].sin.sin_addr.s_addr = INADDR_ANY;
#endif
- statp->nsaddr.sin_family = AF_INET;
- statp->nsaddr.sin_port = htons(NAMESERVER_PORT);
+ u[nserv].sin.sin_family = AF_INET;
+ u[nserv].sin.sin_port = htons(NAMESERVER_PORT);
#ifdef HAVE_SA_LEN
- statp->nsaddr.sin_len = sizeof(struct sockaddr_in);
+ u[nserv].sin.sin_len = sizeof(struct sockaddr_in);
#endif
- statp->nscount = 1;
+ nserv++;
+#ifdef HAS_INET6_STRUCTS
+#ifdef USELOOPBACK
+ u[nserv].sin6.sin6_addr = in6addr_loopback;
+#else
+ u[nserv].sin6.sin6_addr = in6addr_any;
+#endif
+ u[nserv].sin6.sin6_family = AF_INET6;
+ u[nserv].sin6.sin6_port = htons(NAMESERVER_PORT);
+#ifdef HAVE_SA_LEN
+ u[nserv].sin6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ nserv++;
+#endif
+ statp->nscount = 0;
statp->ndots = 1;
statp->pfcode = 0;
statp->_vcsock = -1;
@@ -196,11 +212,11 @@ __res_vinit(res_state statp, int preinit) {
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
- strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa");
}
#ifdef RESOLVSORT
statp->nsort = 0;
#endif
+ res_setservers(statp, u, nserv);
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
@@ -242,6 +258,7 @@ __res_vinit(res_state statp, int preinit) {
(line[sizeof(name) - 1] == ' ' || \
line[sizeof(name) - 1] == '\t'))
+ nserv = 0;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
@@ -507,9 +524,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
statp->options |= RES_USE_EDNS0;
}
#endif
- else if (!strncmp(cp, "a6", sizeof("a6") - 1)) {
- statp->options |= RES_USE_A6;
- }
else if (!strncmp(cp, "dname", sizeof("dname") - 1)) {
statp->options |= RES_USE_DNAME;
}
@@ -529,14 +543,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
strncpy(ext->nsuffix2, cp, i);
ext->nsuffix2[i] = '\0';
}
- else if (!strncmp(cp, "bitstring:", sizeof("bitstring:") - 1)) {
- if (ext == NULL)
- goto skip;
- cp += sizeof("bitstring:") - 1;
- i = MIN(strcspn(cp, " \t"), sizeof(ext->bsuffix) - 1);
- strncpy(ext->bsuffix, cp, i);
- ext->bsuffix[i] = '\0';
- }
else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
cp += sizeof("v6revmode:") - 1;
/* "nibble" and "bitstring" used to be valid */
@@ -628,13 +634,6 @@ res_get_nibblesuffix2(res_state statp) {
return ("ip6.int");
}
-const char *
-res_get_bitstringsuffix(res_state statp) {
- if (statp->_u._ext.ext)
- return (statp->_u._ext.ext->bsuffix);
- return ("ip6.arpa");
-}
-
void
res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
int i, nserv;
diff --git a/contrib/bind/lib/resolv/res_mkquery.c b/contrib/bind/lib/resolv/res_mkquery.c
index 7041227..a45d89b 100644
--- a/contrib/bind/lib/resolv/res_mkquery.c
+++ b/contrib/bind/lib/resolv/res_mkquery.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_mkquery.c,v 8.14 2001/09/24 13:50:27 marka Exp $";
+static const char rcsid[] = "$Id: res_mkquery.c,v 8.15.8.1 2003/06/02 05:59:57 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -105,7 +105,7 @@ res_nmkquery(res_state statp,
int buflen) /* size of buffer */
{
register HEADER *hp;
- register u_char *cp;
+ register u_char *cp, *ep;
register int n;
u_char *dnptrs[20], **dpp, **lastdnptr;
@@ -128,7 +128,7 @@ res_nmkquery(res_state statp,
hp->rd = (statp->options & RES_RECURSE) != 0;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
- buflen -= HFIXEDSZ;
+ ep = buf + buflen;
dpp = dnptrs;
*dpp++ = buf;
*dpp++ = NULL;
@@ -139,15 +139,15 @@ res_nmkquery(res_state statp,
switch (op) {
case QUERY: /*FALLTHROUGH*/
case NS_NOTIFY_OP:
- if ((buflen -= QFIXEDSZ) < 0)
+ if (ep - cp < QFIXEDSZ)
return (-1);
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+ if ((n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs,
+ lastdnptr)) < 0)
return (-1);
cp += n;
- buflen -= n;
- __putshort(type, cp);
+ ns_put16(type, cp);
cp += INT16SZ;
- __putshort(class, cp);
+ ns_put16(class, cp);
cp += INT16SZ;
hp->qdcount = htons(1);
if (op == QUERY || data == NULL)
@@ -155,19 +155,20 @@ res_nmkquery(res_state statp,
/*
* Make an additional record for completion domain.
*/
- buflen -= RRFIXEDSZ;
- n = dn_comp((const char *)data, cp, buflen, dnptrs, lastdnptr);
+ if ((ep - cp) < RRFIXEDSZ)
+ return (-1);
+ n = dn_comp((const char *)data, cp, ep - cp - RRFIXEDSZ,
+ dnptrs, lastdnptr);
if (n < 0)
return (-1);
cp += n;
- buflen -= n;
- __putshort(T_NULL, cp);
+ ns_put16(T_NULL, cp);
cp += INT16SZ;
- __putshort(class, cp);
+ ns_put16(class, cp);
cp += INT16SZ;
- __putlong(0, cp);
+ ns_put32(0, cp);
cp += INT32SZ;
- __putshort(0, cp);
+ ns_put16(0, cp);
cp += INT16SZ;
hp->arcount = htons(1);
break;
@@ -176,16 +177,16 @@ res_nmkquery(res_state statp,
/*
* Initialize answer section
*/
- if (buflen < 1 + RRFIXEDSZ + datalen)
+ if (ep - cp < 1 + RRFIXEDSZ + datalen)
return (-1);
*cp++ = '\0'; /* no domain name */
- __putshort(type, cp);
+ ns_put16(type, cp);
cp += INT16SZ;
- __putshort(class, cp);
+ ns_put16(class, cp);
cp += INT16SZ;
- __putlong(0, cp);
+ ns_put32(0, cp);
cp += INT32SZ;
- __putshort(datalen, cp);
+ ns_put16(datalen, cp);
cp += INT16SZ;
if (datalen) {
memcpy(cp, data, datalen);
@@ -207,15 +208,14 @@ res_nmkquery(res_state statp,
#endif
int
-res_nopt(statp, n0, buf, buflen, anslen)
- res_state statp;
- int n0;
- u_char *buf; /* buffer to put query */
- int buflen; /* size of buffer */
- int anslen; /* answer buffer length */
+res_nopt(res_state statp,
+ int n0, /* current offset in buffer */
+ u_char *buf, /* buffer to put query */
+ int buflen, /* size of buffer */
+ int anslen) /* UDP answer buffer size */
{
register HEADER *hp;
- register u_char *cp;
+ register u_char *cp, *ep;
u_int16_t flags = 0;
#ifdef DEBUG
@@ -225,17 +225,16 @@ res_nopt(statp, n0, buf, buflen, anslen)
hp = (HEADER *) buf;
cp = buf + n0;
- buflen -= n0;
+ ep = buf + buflen;
- if (buflen < 1 + RRFIXEDSZ)
- return -1;
+ if ((ep - cp) < 1 + RRFIXEDSZ)
+ return (-1);
*cp++ = 0; /* "." */
- buflen--;
- __putshort(T_OPT, cp); /* TYPE */
+ ns_put16(T_OPT, cp); /* TYPE */
cp += INT16SZ;
- __putshort(anslen & 0xffff, cp); /* CLASS = UDP payload size */
+ ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */
cp += INT16SZ;
*cp++ = NOERROR; /* extended RCODE */
*cp++ = 0; /* EDNS version */
@@ -246,13 +245,12 @@ res_nopt(statp, n0, buf, buflen, anslen)
#endif
flags |= NS_OPT_DNSSEC_OK;
}
- __putshort(flags, cp);
+ ns_put16(flags, cp);
cp += INT16SZ;
- __putshort(0, cp); /* RDLEN */
+ ns_put16(0, cp); /* RDLEN */
cp += INT16SZ;
hp->arcount = htons(ntohs(hp->arcount) + 1);
- buflen -= RRFIXEDSZ;
- return cp - buf;
+ return (cp - buf);
}
#endif
diff --git a/contrib/bind/lib/resolv/res_mkupdate.c b/contrib/bind/lib/resolv/res_mkupdate.c
index 6071360..3928f9f 100644
--- a/contrib/bind/lib/resolv/res_mkupdate.c
+++ b/contrib/bind/lib/resolv/res_mkupdate.c
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.26 2001/05/29 05:49:47 marka Exp $";
+static const char rcsid[] = "$Id: res_mkupdate.c,v 1.27.8.1 2003/06/02 04:56:28 marka Exp $";
#endif /* not lint */
#include "port_before.h"
@@ -302,7 +302,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
if (!getword_str(buf2, sizeof buf2, &startp, endp))
return (-1);
- n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
+ n = dn_comp(buf2, cp, buflen, NULL, NULL);
if (n < 0)
return (-1);
cp += n;
@@ -482,8 +482,10 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
char *ulendp;
u_int32_t ottl;
+ errno = 0;
ottl = strtoul(buf2, &ulendp, 10);
- if (ulendp != NULL && *ulendp != '\0')
+ if (errno != 0 ||
+ (ulendp != NULL && *ulendp != '\0'))
return (-1);
ShrinkBuffer(INT32SZ);
PUTLONG(ottl, cp);
@@ -572,7 +574,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
/* next name */
if (!getword_str(buf2, sizeof buf2, &startp, endp))
return (-1);
- n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
+ n = dn_comp(buf2, cp, buflen, NULL, NULL);
if (n < 0)
return (-1);
cp += n;
@@ -636,6 +638,62 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
memcpy(cp, &in6a, NS_IN6ADDRSZ);
cp += NS_IN6ADDRSZ;
break;
+ case ns_t_naptr:
+ /* Order Preference Flags Service Replacement Regexp */
+ /* Order */
+ n = getnum_str(&startp, endp);
+ if (n < 0 || n > 65535)
+ return (-1);
+ ShrinkBuffer(INT16SZ);
+ PUTSHORT(n, cp);
+ /* Preference */
+ n = getnum_str(&startp, endp);
+ if (n < 0 || n > 65535)
+ return (-1);
+ ShrinkBuffer(INT16SZ);
+ PUTSHORT(n, cp);
+ /* Flags */
+ if ((n = getstr_str(buf2, sizeof buf2,
+ &startp, endp)) < 0) {
+ return (-1);
+ }
+ if (n > 255)
+ return (-1);
+ ShrinkBuffer(n+1);
+ *cp++ = n;
+ memcpy(cp, buf2, n);
+ cp += n;
+ /* Service Classes */
+ if ((n = getstr_str(buf2, sizeof buf2,
+ &startp, endp)) < 0) {
+ return (-1);
+ }
+ if (n > 255)
+ return (-1);
+ ShrinkBuffer(n+1);
+ *cp++ = n;
+ memcpy(cp, buf2, n);
+ cp += n;
+ /* Pattern */
+ if ((n = getstr_str(buf2, sizeof buf2,
+ &startp, endp)) < 0) {
+ return (-1);
+ }
+ if (n > 255)
+ return (-1);
+ ShrinkBuffer(n+1);
+ *cp++ = n;
+ memcpy(cp, buf2, n);
+ cp += n;
+ /* Replacement */
+ if (!getword_str(buf2, sizeof buf2, &startp, endp))
+ return (-1);
+ n = dn_comp(buf2, cp, buflen, NULL, NULL);
+ if (n < 0)
+ return (-1);
+ cp += n;
+ ShrinkBuffer(n);
+ break;
default:
return (-1);
} /*switch*/
@@ -807,7 +865,7 @@ gethexnum_str(u_char **startpp, u_char *endp) {
}
/*
- * Get a whitespace delimited base 16 number from a string (not file) into buf
+ * Get a whitespace delimited base 10 number from a string (not file) into buf
* update the start pointer to point after the number in the string.
*/
static int
diff --git a/contrib/bind/lib/resolv/res_private.h b/contrib/bind/lib/resolv/res_private.h
index ec9b384..d7b66cd 100644
--- a/contrib/bind/lib/resolv/res_private.h
+++ b/contrib/bind/lib/resolv/res_private.h
@@ -11,7 +11,6 @@ struct __res_state_ext {
} addr, mask;
} sort_list[MAXRESOLVSORT];
char nsuffix[64];
- char bsuffix[64];
char nsuffix2[64];
};
diff --git a/contrib/bind/lib/resolv/res_query.c b/contrib/bind/lib/resolv/res_query.c
index 61f5df9..cda076c 100644
--- a/contrib/bind/lib/resolv/res_query.c
+++ b/contrib/bind/lib/resolv/res_query.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 8.23 2001/09/24 13:50:29 marka Exp $";
+static const char rcsid[] = "$Id: res_query.c,v 8.24 2003/01/31 15:25:58 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -167,8 +167,11 @@ again:
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (statp->options & RES_DEBUG)
- printf(";; rcode = %d, ancount=%d\n", hp->rcode,
- ntohs(hp->ancount));
+ printf(";; rcode = (%s), counts = an:%d ns:%d ar:%d\n",
+ p_rcode(hp->rcode),
+ ntohs(hp->ancount),
+ ntohs(hp->nscount),
+ ntohs(hp->arcount));
#endif
switch (hp->rcode) {
case NXDOMAIN:
diff --git a/contrib/bind/lib/resolv/res_send.c b/contrib/bind/lib/resolv/res_send.c
index 6f0e430..2adc608 100644
--- a/contrib/bind/lib/resolv/res_send.c
+++ b/contrib/bind/lib/resolv/res_send.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 8.49 2002/03/29 21:50:51 marka Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 8.51.2.1 2003/06/02 05:59:57 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -171,6 +171,9 @@ res_ourserver_p(const res_state statp, const struct sockaddr *sa) {
srv6 = (struct sockaddr_in6 *)get_nsaddr(statp, ns);
if (srv6->sin6_family == in6p->sin6_family &&
srv6->sin6_port == in6p->sin6_port &&
+#ifdef HAVE_SIN6_SCOPE_ID
+ srv6->sin6_scope_id == in6p->sin6_scope_id &&
+#endif
(IN6_IS_ADDR_UNSPECIFIED(&srv6->sin6_addr) ||
IN6_ARE_ADDR_EQUAL(&srv6->sin6_addr, &in6p->sin6_addr)))
return (1);
@@ -386,6 +389,8 @@ res_nsend(res_state statp,
int nsaplen;
nsap = get_nsaddr(statp, ns);
nsaplen = get_salen(nsap);
+ statp->_flags &= ~RES_F_LASTMASK;
+ statp->_flags |= (ns << RES_F_LASTSHIFT);
same_ns:
if (statp->qhook) {
int done = 0, loops = 0;
@@ -623,7 +628,7 @@ send_vc(res_state statp,
/*
* Send length & message
*/
- putshort((u_short)buflen, (u_char*)&len);
+ ns_put16((u_short)buflen, (u_char*)&len);
iov[0] = evConsIovec(&len, INT16SZ);
DE_CONST(buf, tmp);
iov[1] = evConsIovec(tmp, buflen);
diff --git a/contrib/bind/lib/resolv/res_update.c b/contrib/bind/lib/resolv/res_update.c
index 12ee326..35c9b07 100644
--- a/contrib/bind/lib/resolv/res_update.c
+++ b/contrib/bind/lib/resolv/res_update.c
@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.34 2002/04/12 06:28:52 marka Exp $";
+static const char rcsid[] = "$Id: res_update.c,v 1.35.8.2 2003/06/02 09:24:40 marka Exp $";
#endif /* not lint */
/*
@@ -77,7 +77,7 @@ struct zonegrp {
/* Forward. */
-static void res_dprintf(const char *, ...);
+static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
/* Macros. */
@@ -92,12 +92,18 @@ static void res_dprintf(const char *, ...);
int
res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
ns_updrec *rrecp;
- u_char answer[PACKETSZ], packet[2*PACKETSZ];
+ u_char answer[PACKETSZ];
+ u_char *packet;
struct zonegrp *zptr, tgrp;
LIST(struct zonegrp) zgrps;
int nzones = 0, nscount = 0, n;
union res_sockaddr_union nsaddrs[MAXNS];
+ packet = malloc(NS_MAXMSG);
+ if (packet == NULL) {
+ DPRINTF(("malloc failed"));
+ return (0);
+ }
/* Thread all of the updates onto a list of groups. */
INIT_LIST(zgrps);
memset(&tgrp, 0, sizeof (tgrp));
@@ -150,7 +156,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
/* Marshall the update message. */
n = res_nmkupdate(statp, HEAD(zptr->z_rrlist),
- packet, sizeof packet);
+ packet, NS_MAXMSG);
DPRINTF(("res_mkupdate -> %d", n));
if (n < 0)
goto done;
@@ -188,6 +194,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
if (nscount != 0)
res_setservers(statp, nsaddrs, nscount);
+ free(packet);
return (nzones);
}
OpenPOWER on IntegriCloud