]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
dns_view_untrust modifies dnskey->flags when it shouldn't
authorMark Andrews <marka@isc.org>
Tue, 29 Nov 2022 05:11:51 +0000 (16:11 +1100)
committerPetr Špaček <pspacek@isc.org>
Mon, 3 Apr 2023 15:43:43 +0000 (17:43 +0200)
Copy the structure and declare dnskey as const.

lib/dns/include/dns/view.h
lib/dns/view.c

index 32746c38dbad63983e04dcebfb2a03197972b3c4..a552327bad1ff733a927653d4d191709ddc63e62 100644 (file)
@@ -1045,7 +1045,7 @@ dns_view_ntacovers(dns_view_t *view, isc_stdtime_t now, const dns_name_t *name,
 
 void
 dns_view_untrust(dns_view_t *view, const dns_name_t *keyname,
-                dns_rdata_dnskey_t *dnskey);
+                const dns_rdata_dnskey_t *dnskey);
 /*%<
  * Remove keys that match 'keyname' and 'dnskey' from the views trust
  * anchors.
index 7752a9d0ee0ae1fe6385c139b3a15993e26ee6aa..133d6775bb29208b79c75d904b3b6d54181fc29a 100644 (file)
@@ -1639,26 +1639,28 @@ dns_view_issecuredomain(dns_view_t *view, const dns_name_t *name,
 
 void
 dns_view_untrust(dns_view_t *view, const dns_name_t *keyname,
-                dns_rdata_dnskey_t *dnskey) {
+                const dns_rdata_dnskey_t *dnskey) {
        isc_result_t result;
        dns_keytable_t *sr = NULL;
+       dns_rdata_dnskey_t tmpkey;
 
        REQUIRE(DNS_VIEW_VALID(view));
        REQUIRE(keyname != NULL);
        REQUIRE(dnskey != NULL);
 
-       /*
-        * Clear the revoke bit, if set, so that the key will match what's
-        * in secroots now.
-        */
-       dnskey->flags &= ~DNS_KEYFLAG_REVOKE;
-
        result = dns_view_getsecroots(view, &sr);
        if (result != ISC_R_SUCCESS) {
                return;
        }
 
-       result = dns_keytable_deletekey(sr, keyname, dnskey);
+       /*
+        * Clear the revoke bit, if set, so that the key will match what's
+        * in secroots now.
+        */
+       tmpkey = *dnskey;
+       tmpkey.flags &= ~DNS_KEYFLAG_REVOKE;
+
+       result = dns_keytable_deletekey(sr, keyname, &tmpkey);
        if (result == ISC_R_SUCCESS) {
                /*
                 * If key was found in secroots, then it was a