From: Tony Finch Date: Wed, 14 Dec 2022 16:24:19 +0000 (+0000) Subject: Don't crash when rndc delzone encounters a catz member X-Git-Tag: v9.16.37~13^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=01788b885282f28b1b57cb5f464ea84c4cedfb0d;p=thirdparty%2Fbind9.git Don't crash when rndc delzone encounters a catz member 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) --- diff --git a/CHANGES b/CHANGES index 83fb60cb6a9..ed3cf1d4312 100644 --- 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] diff --git a/bin/named/server.c b/bin/named/server.c index 29aed792b4f..20443ff8a94 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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; }