]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix cleanup of signature buffer in dns_dnssec_signmessage
authorMark Andrews <marka@isc.org>
Wed, 6 Oct 2021 08:10:36 +0000 (19:10 +1100)
committerMark Andrews <marka@isc.org>
Mon, 11 Oct 2021 22:56:44 +0000 (09:56 +1100)
A NULL pointer could be freed if error handling occured.

lib/dns/dnssec.c

index 6e1dc30f7cc8afb9ae71cc0857d7591266c2617e..450c34f7b608a8ec2f99518496cb5b34055fc3bf 100644 (file)
@@ -943,7 +943,6 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
        dst_context_t *ctx = NULL;
        isc_mem_t *mctx;
        isc_result_t result;
-       bool signeedsfree = true;
 
        REQUIRE(msg != NULL);
        REQUIRE(key != NULL);
@@ -1032,7 +1031,6 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
                                    dynbuf));
 
        isc_mem_put(mctx, sig.signature, sig.siglen);
-       signeedsfree = false;
 
        dns_message_takebuffer(msg, &dynbuf);
 
@@ -1053,7 +1051,7 @@ failure:
        if (dynbuf != NULL) {
                isc_buffer_free(&dynbuf);
        }
-       if (signeedsfree) {
+       if (sig.signature != NULL) {
                isc_mem_put(mctx, sig.signature, sig.siglen);
        }
        if (ctx != NULL) {