diff options
author | dougb <dougb@FreeBSD.org> | 2003-06-17 08:25:13 +0000 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2003-06-17 08:25:13 +0000 |
commit | f97237131f327c9eda67f546f7acffceef5a9fde (patch) | |
tree | 04f9050731919faa97a44a524d6a4129aea8e98d /contrib/bind/lib/nameser | |
parent | 02f065cde2cf18b6e76deab6f48d7aeb327bd639 (diff) | |
download | FreeBSD-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/nameser')
-rw-r--r-- | contrib/bind/lib/nameser/ns_name.c | 32 | ||||
-rw-r--r-- | contrib/bind/lib/nameser/ns_parse.c | 5 | ||||
-rw-r--r-- | contrib/bind/lib/nameser/ns_print.c | 14 | ||||
-rw-r--r-- | contrib/bind/lib/nameser/ns_samedomain.c | 14 | ||||
-rw-r--r-- | contrib/bind/lib/nameser/ns_sign.c | 27 |
5 files changed, 59 insertions, 33 deletions
diff --git a/contrib/bind/lib/nameser/ns_name.c b/contrib/bind/lib/nameser/ns_name.c index fff96f4..c57ac3b 100644 --- a/contrib/bind/lib/nameser/ns_name.c +++ b/contrib/bind/lib/nameser/ns_name.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_name.c,v 8.18.4.1 2002/11/14 13:32:08 marka Exp $"; +static const char rcsid[] = "$Id: ns_name.c,v 8.20 2003/04/03 06:00:07 marka Exp $"; #endif #include "port_before.h" @@ -792,7 +792,7 @@ decode_bitstring(const char **cpp, char *dn, const char *eom) { const char *cp = *cpp; char *beg = dn, tc; - int b, blen, plen; + int b, blen, plen, i; if ((blen = (*cp & 0xff)) == 0) blen = 256; @@ -802,18 +802,34 @@ decode_bitstring(const char **cpp, char *dn, const char *eom) return(-1); cp++; - dn += SPRINTF((dn, "\\[x")); - for (b = blen; b > 7; b -= 8, cp++) - dn += SPRINTF((dn, "%02x", *cp & 0xff)); + i = SPRINTF((dn, "\\[x")); + if (i < 0) + return (-1); + dn += i; + for (b = blen; b > 7; b -= 8, cp++) { + i = SPRINTF((dn, "%02x", *cp & 0xff)); + if (i < 0) + return (-1); + dn += i; + } if (b > 4) { tc = *cp++; - dn += SPRINTF((dn, "%02x", tc & (0xff << (8 - b)))); + i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b)))); + if (i < 0) + return (-1); + dn += i; } else if (b > 0) { tc = *cp++; - dn += SPRINTF((dn, "%1x", + i = SPRINTF((dn, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)))); + if (i < 0) + return (-1); + dn += i; } - dn += SPRINTF((dn, "/%d]", blen)); + i = SPRINTF((dn, "/%d]", blen)); + if (i < 0) + return (-1); + dn += i; *cpp = cp; return(dn - beg); diff --git a/contrib/bind/lib/nameser/ns_parse.c b/contrib/bind/lib/nameser/ns_parse.c index f3f92c6..abd48f2 100644 --- a/contrib/bind/lib/nameser/ns_parse.c +++ b/contrib/bind/lib/nameser/ns_parse.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_parse.c,v 8.17 2001/06/20 02:50:49 marka Exp $"; +static const char rcsid[] = "$Id: ns_parse.c,v 8.18 2003/04/03 06:10:10 marka Exp $"; #endif /* Import. */ @@ -132,9 +132,10 @@ ns_initparse(const u_char *msg, int msglen, ns_msg *handle) { int ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) { int b; + int tmp; /* Make section right. */ - if (section >= ns_s_max) + if ((tmp = section) < 0 || section >= ns_s_max) RETERR(ENODEV); if (section != handle->_sect) setsection(handle, section); diff --git a/contrib/bind/lib/nameser/ns_print.c b/contrib/bind/lib/nameser/ns_print.c index b23f805..f8a85e7 100644 --- a/contrib/bind/lib/nameser/ns_print.c +++ b/contrib/bind/lib/nameser/ns_print.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_print.c,v 8.24 2001/06/18 06:40:45 marka Exp $"; +static const char rcsid[] = "$Id: ns_print.c,v 8.26 2003/02/24 23:56:35 vixie Exp $"; #endif /* Import. */ @@ -31,6 +31,7 @@ static const char rcsid[] = "$Id: ns_print.c,v 8.24 2001/06/18 06:40:45 marka Ex #include <arpa/inet.h> #include <isc/assertions.h> +#include <isc/dst.h> #include <errno.h> #include <resolv.h> #include <string.h> @@ -58,10 +59,6 @@ static int addstr(const char *src, size_t len, static int addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen); -/* Proto. */ - -u_int16_t dst_s_dns_key_id(const u_char *, const int); - /* Macros. */ #define T(x) \ @@ -640,9 +637,10 @@ ns_sprintrrf(const u_char *msg, size_t msglen, len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize)); T(addstr(tmp, len, &buf, &buflen)); - /* needs to dump key, print otherdata length & other data */ + /* XXX need to dump key, print otherdata length & other data */ break; } + case ns_t_tsig: { /* BEW - need to complete this */ int n; @@ -690,13 +688,13 @@ ns_sprintrrf(const u_char *msg, size_t msglen, T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); break; - } + } case ns_t_opt: { len = SPRINTF((tmp, "%u bytes", class)); T(addstr(tmp, len, &buf, &buflen)); break; - } + } default: comment = "unknown RR type"; diff --git a/contrib/bind/lib/nameser/ns_samedomain.c b/contrib/bind/lib/nameser/ns_samedomain.c index da6f3b6..6394701 100644 --- a/contrib/bind/lib/nameser/ns_samedomain.c +++ b/contrib/bind/lib/nameser/ns_samedomain.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_samedomain.c,v 8.9.6.2 2002/11/14 22:36:46 marka Exp $"; +static const char rcsid[] = "$Id: ns_samedomain.c,v 8.10.8.1 2003/06/02 05:05:05 marka Exp $"; #endif #include "port_before.h" @@ -125,12 +125,12 @@ ns_samedomain(const char *a, const char *b) { */ escaped = 0; for (i = diff - 2; i >= 0; i--) - if (a[i] == '\\') + if (a[i] == '\\') { if (escaped) escaped = 0; else escaped = 1; - else + } else break; if (escaped) return (0); @@ -166,14 +166,14 @@ int ns_makecanon(const char *src, char *dst, size_t dstsize) { size_t n = strlen(src); - if (n + sizeof "." > dstsize) { + if (n + sizeof "." > dstsize) { /* Note: sizeof == 2 */ errno = EMSGSIZE; return (-1); } strcpy(dst, src); - while (n > 0 && dst[n - 1] == '.') /* Ends in "." */ - if (n > 1 && dst[n - 2] == '\\' && /* Ends in "\." */ - (n < 2 || dst[n - 3] != '\\')) /* But not "\\." */ + while (n >= 1 && dst[n - 1] == '.') /* Ends in "." */ + if (n >= 2 && dst[n - 2] == '\\' && /* Ends in "\." */ + (n < 3 || dst[n - 3] != '\\')) /* But not "\\." */ break; else dst[--n] = '\0'; diff --git a/contrib/bind/lib/nameser/ns_sign.c b/contrib/bind/lib/nameser/ns_sign.c index 8c5fe1d..de8cd14 100644 --- a/contrib/bind/lib/nameser/ns_sign.c +++ b/contrib/bind/lib/nameser/ns_sign.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_sign.c,v 8.11 2002/04/30 03:43:55 marka Exp $"; +static const char rcsid[] = "$Id: ns_sign.c,v 8.12 2002/10/01 06:48:37 marka Exp $"; #endif /* Import. */ @@ -41,6 +41,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 8.11 2002/04/30 03:43:55 marka Exp #include <unistd.h> #include <isc/dst.h> +#include <isc/assertions.h> #include "port_after.h" @@ -90,22 +91,30 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k, DST_KEY *key = (DST_KEY *)k; u_char *cp = msg + *msglen, *eob = msg + msgsize; u_char *lenp; - u_char *name, *alg; + u_char *alg; int n; time_t timesigned; + u_char name[NS_MAXCDNAME]; dst_init(); if (msg == NULL || msglen == NULL || sig == NULL || siglen == NULL) return (-1); /* Name. */ - if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) - n = dn_comp(key->dk_key_name, cp, eob - cp, dnptrs, lastdnptr); - else - n = dn_comp("", cp, eob - cp, NULL, NULL); + if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) { + n = ns_name_pton(key->dk_key_name, name, sizeof name); + if (n != -1) + n = ns_name_pack(name, cp, eob - cp, + (const u_char **)dnptrs, + (const u_char **)lastdnptr); + + } else { + n = ns_name_pton("", name, sizeof name); + if (n != -1) + n = ns_name_pack(name, cp, eob - cp, NULL, NULL); + } if (n < 0) return (NS_TSIG_ERROR_NO_SPACE); - name = cp; cp += n; /* Type, class, ttl, length (not filled in yet). */ @@ -142,7 +151,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k, /* Compute the signature. */ if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) { void *ctx; - u_char buf[MAXDNAME], *cp2; + u_char buf[NS_MAXCDNAME], *cp2; int n; dst_sign_data(SIG_MODE_INIT, key, &ctx, NULL, 0, NULL, 0); @@ -162,6 +171,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k, /* Digest the key name. */ n = ns_name_ntol(name, buf, sizeof(buf)); + INSIST(n > 0); dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0); /* Digest the class and TTL. */ @@ -173,6 +183,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k, /* Digest the algorithm. */ n = ns_name_ntol(alg, buf, sizeof(buf)); + INSIST(n > 0); dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0); /* Digest the time signed, fudge, error, and other data */ |