]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Thu, 27 Jul 2000 22:15:22 +0000 (22:15 +0000)
committerAndreas Gustafsson <source@isc.org>
Thu, 27 Jul 2000 22:15:22 +0000 (22:15 +0000)
dns_dnssec_verifymessage should make sure that it's verifying with the right
key (which should be the case anyway, but it never hurts to check).  Also
fix a memory leak and change a few _tostruct() calls to not allocate memory.

lib/dns/dnssec.c
lib/dns/include/dns/dnssec.h

index e5db778701f250f819564ba825f18bc770298445..32f0583b7f45d152f888db873255bf56651d9074 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: dnssec.c,v 1.43 2000/06/06 22:00:47 bwelling Exp $
+ * $Id: dnssec.c,v 1.43.2.1 2000/07/27 22:15:21 gson Exp $
  * Principal Author: Brian Wellington
  */
 
@@ -322,7 +322,7 @@ dns_dnssec_verify(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
        REQUIRE(mctx != NULL);
        REQUIRE(sigrdata != NULL && sigrdata->type == dns_rdatatype_sig);
 
-       ret = dns_rdata_tostruct(sigrdata, &sig, mctx);
+       ret = dns_rdata_tostruct(sigrdata, &sig, NULL);
        if (ret != ISC_R_SUCCESS)
                return (ret);
 
@@ -599,6 +599,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
 
        isc_buffer_init(&sigbuf, sig.signature, sig.siglen);
        RETERR(dst_context_sign(ctx, &sigbuf));
+       dst_context_destroy(&ctx);
 
        rdata = NULL;
        RETERR(dns_message_gettemprdata(msg, &rdata));
@@ -671,7 +672,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
        RETERR(dns_rdataset_first(msg->sig0));
        dns_rdataset_current(msg->sig0, &rdata);
 
-       RETERR(dns_rdata_tostruct(&rdata, &sig, mctx));
+       RETERR(dns_rdata_tostruct(&rdata, &sig, NULL));
        signeedsfree = ISC_TRUE;
 
        if (sig.labels != 0) {
@@ -691,7 +692,11 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
                goto failure;
        }
 
-       /* XXXBEW ensure that sig.signer refers to this key */
+       if (!dns_name_equal(dst_key_name(key), &sig.signer)) {
+               result = DNS_R_SIGINVALID;
+               msg->sig0status = dns_tsigerror_badkey;
+               goto failure;
+       }
 
        RETERR(dst_context_create(key, mctx, &ctx));
 
@@ -751,6 +756,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
 
        msg->verified_sig = 1;
 
+       dst_context_destroy(&ctx);
        dns_rdata_freestruct(&sig);
 
        return (ISC_R_SUCCESS);
index 0b5fc371d72a0273f3be69b2e50cada4d2e8afb3..67e1c5202a057d9976336a1367d4dbbf09c4840f 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dnssec.h,v 1.15 2000/06/22 21:55:37 tale Exp $ */
+/* $Id: dnssec.h,v 1.15.2.1 2000/07/27 22:15:22 gson Exp $ */
 
 #ifndef DNS_DNSSEC_H
 #define DNS_DNSSEC_H 1
@@ -154,6 +154,8 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
  *             ISC_R_SUCCESS
  *             ISC_R_NOMEMORY
  *             ISC_R_NOTFOUND - no SIG(0) was found
+ *             DNS_R_SIGINVALID - the SIG record is not well-formed or
+ *                                was not generated by the key.
  *             DST_R_*
  */