diff options
Diffstat (limited to 'contrib/bind/lib/nameser/ns_sign.c')
-rw-r--r-- | contrib/bind/lib/nameser/ns_sign.c | 27 |
1 files changed, 19 insertions, 8 deletions
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 */ |