]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Thu, 14 Jun 2001 13:56:40 +0000 (13:56 +0000)
committerAndreas Gustafsson <source@isc.org>
Thu, 14 Jun 2001 13:56:40 +0000 (13:56 +0000)
Signing with a large key didn't work since the static output buffer was too
small; use a dynamic buffer instead.  Also, comment a section

lib/dns/dnssec.c

index b2a4c1b3dd93de093d3401f047f8f3d8857b0a15..9e7c2ece319b5a1dc4c6627821558221b85d63c9 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: dnssec.c,v 1.56.2.6 2001/06/08 19:38:57 bwelling Exp $
+ * $Id: dnssec.c,v 1.56.2.7 2001/06/14 13:56:40 gson Exp $
  */
 
 
@@ -168,11 +168,12 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
        dns_rdata_t tmpsigrdata;
        dns_rdata_t *rdatas;
        int nrdatas, i;
-       isc_buffer_t b, sigbuf, envbuf;
+       isc_buffer_t sigbuf, envbuf;
        isc_region_t r;
        dst_context_t *ctx = NULL;
        isc_result_t ret;
-       unsigned char data[300];
+       isc_buffer_t *databuf = NULL;
+       char data[256 + 8];
        isc_uint32_t flags;
        unsigned int sigsize;
        dns_fixedname_t fnewname;
@@ -219,20 +220,27 @@ dns_dnssec_sign(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
        if (ret != ISC_R_SUCCESS)
                return (ret);
        sig.siglen = sigsize;
+       /*
+        * The actual contents of sig.signature are not important yet, since
+        * they're not used in digest_sig().
+        */
        sig.signature = isc_mem_get(mctx, sig.siglen);
        if (sig.signature == NULL)
                return (ISC_R_NOMEMORY);
 
-       isc_buffer_init(&b, data, sizeof(data));
+       ret = isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
+       if (ret != ISC_R_SUCCESS)
+               goto cleanup_signature;
+
        dns_rdata_init(&tmpsigrdata);
        ret = dns_rdata_fromstruct(&tmpsigrdata, sig.common.rdclass,
-                                  sig.common.rdtype, &sig, &b);
+                                  sig.common.rdtype, &sig, databuf);
        if (ret != ISC_R_SUCCESS)
-               goto cleanup_signature;
+               goto cleanup_databuf;
 
        ret = dst_context_create(key, mctx, &ctx);
        if (ret != ISC_R_SUCCESS)
-               goto cleanup_signature;
+               goto cleanup_databuf;
 
        /*
         * Digest the SIG rdata.
@@ -309,6 +317,9 @@ cleanup_array:
        isc_mem_put(mctx, rdatas, nrdatas * sizeof(dns_rdata_t));
 cleanup_context:
        dst_context_destroy(&ctx);
+cleanup_databuf:
+       if (databuf != NULL)
+               isc_buffer_free(&databuf);
 cleanup_signature:
        isc_mem_put(mctx, sig.signature, sig.siglen);