]> 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:46:13 +0000 (17:46 +0200)
Copy the structure and declare dnskey as const.

(cherry picked from commit 21d828241b47c1fbdc6083c20b21dd95f48acc87)

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

index 01d3ee1f1f016eca9dfde73fb947b5a6daee5ba4..18b0b3394a0bfe1318a5b3c575105e9689dadede 100644 (file)
@@ -1220,7 +1220,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 16f74c9a161d3700e4512ae02afbb53f2829beb4..49c9aee9416ab6e682ea9f082eb3b15b5f0c181e 100644 (file)
@@ -2037,26 +2037,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