]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't crash when rndc delzone encounters a catz member
authorTony Finch <fanf@isc.org>
Wed, 14 Dec 2022 16:24:19 +0000 (16:24 +0000)
committerTony Finch <dot@dotat.at>
Wed, 4 Jan 2023 18:04:53 +0000 (18:04 +0000)
Try to remove the zone from the NZF config only if it was
dynamically added but not by a catalog zone.

(cherry picked from commit 9fa20d6f6c1d978fa6a8f79fa19d0dd71c0ca4eb)

CHANGES
bin/named/server.c

diff --git a/CHANGES b/CHANGES
index 83fb60cb6a9f9a5832e839f81c74f3d0dda3455e..ed3cf1d4312007e665cfc77c7fe8a4e879218907 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+6058.  [bug]           Prevent named from crashing when "rndc delzone"
+                       attempts to delete a zone added by a catalog zone.
+                       [GL #3745]
+
 6050.  [bug]           Changes to the RPZ response-policy min-update-interval
                        and add-soa options now take effect as expected when
                        named is reconfigured. [GL #3740]
index 29aed792b4f303e2a52ca1c5f86e9e17c3762dbd..20443ff8a9414f0aff7d26a406457c17707d83e7 100644 (file)
@@ -13892,10 +13892,11 @@ typedef struct {
 static void
 rmzone(isc_task_t *task, isc_event_t *event) {
        ns_dzctx_t *dz = (ns_dzctx_t *)event->ev_arg;
-       dns_zone_t *zone, *raw = NULL, *mayberaw;
+       dns_zone_t *zone = NULL, *raw = NULL, *mayberaw = NULL;
+       dns_catz_zone_t *catz = NULL;
        char zonename[DNS_NAME_FORMATSIZE];
-       dns_view_t *view;
-       ns_cfgctx_t *cfg;
+       dns_view_t *view = NULL;
+       ns_cfgctx_t *cfg = NULL;
        dns_db_t *dbp = NULL;
        bool added;
        isc_result_t result;
@@ -13919,10 +13920,14 @@ rmzone(isc_task_t *task, isc_event_t *event) {
                      "deleting zone %s in view %s via delzone", zonename,
                      view->name);
 
-       /* Remove the zone from configuration (and NZF file if applicable) */
+       /*
+        * Remove the zone from configuration (and NZF file if applicable)
+        * (If this is a catalog zone member then nzf_config can be NULL)
+        */
        added = dns_zone_getadded(zone);
+       catz = dns_zone_get_parentcatz(zone);
 
-       if (added && cfg != NULL) {
+       if (added && catz == NULL && cfg != NULL) {
 #ifdef HAVE_LMDB
                /* Make sure we can open the NZD database */
                LOCK(&view->new_zone_lock);
@@ -13939,8 +13944,7 @@ rmzone(isc_task_t *task, isc_event_t *event) {
                if (result != ISC_R_SUCCESS) {
                        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "unable to "
-                                     "delete zone configuration: %s",
+                                     "unable to delete zone configuration: %s",
                                      isc_result_totext(result));
                }
 
@@ -13955,8 +13959,7 @@ rmzone(isc_task_t *task, isc_event_t *event) {
                if (result != ISC_R_SUCCESS) {
                        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "unable to "
-                                     "delete zone configuration: %s",
+                                     "unable to delete zone configuration: %s",
                                      isc_result_totext(result));
                }
 #endif /* HAVE_LMDB */
@@ -13977,8 +13980,7 @@ rmzone(isc_task_t *task, isc_event_t *event) {
                if (result != ISC_R_SUCCESS) {
                        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "unable to "
-                                     "delete zone configuration: %s",
+                                     "unable to delete zone configuration: %s",
                                      isc_result_totext(result));
                }
        }
@@ -14095,8 +14097,8 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
        if (dns_zone_get_rpz_num(zone) != DNS_RPZ_INVALID_NUM) {
                TCHECK(putstr(text, "zone '"));
                TCHECK(putstr(text, zonename));
-               TCHECK(putstr(text, "' cannot be deleted: response-policy "
-                                   "zone."));
+               TCHECK(putstr(text,
+                             "' cannot be deleted: response-policy zone."));
                result = ISC_R_FAILURE;
                goto cleanup;
        }