]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix catalog zone reconfiguration crash
authorAram Sargsyan <aram@isc.org>
Mon, 11 Oct 2021 18:13:39 +0000 (18:13 +0000)
committerAram Sargsyan <aram@isc.org>
Wed, 1 Dec 2021 09:56:59 +0000 (09:56 +0000)
The following scenario triggers a "named" crash:

1. Configure a catalog zone.
2. Start "named".
3. Comment out the "catalog-zone" clause.
4. Run `rndc reconfig`.
5. Uncomment the "catalog-zone" clause.
6. Run `rndc reconfig` again.

Implement the required cleanup of the in-memory catalog zone during
the first `rndc reconfig`, so that the second `rndc reconfig` could
find it in an expected state.

(cherry picked from commit 43ac2cd229813c04438e027c42c0b93b9661adda)

bin/named/server.c
lib/dns/include/dns/zone.h
lib/dns/win32/libdns.def.in
lib/dns/zone.c

index 860ccae8a1ac00474c9d57e4733c60c744c45042..9c0f12f63f6c0ff4b5b5f4db96843acda78ea5ad 100644 (file)
@@ -6523,6 +6523,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
 
        if (zone_is_catz) {
                dns_zone_catz_enable(zone, view->catzs);
+       } else if (dns_zone_catz_is_enabled(zone)) {
+               dns_zone_catz_disable(zone);
        }
 
        /*
index 08e2263c5b269e9496b130d153bef037a360c139..33ab5c60fd58e78dbef92f9a062898fa8684e6ce 100644 (file)
@@ -2605,6 +2605,26 @@ dns_zone_catz_enable(dns_zone_t *zone, dns_catz_zones_t *catzs);
  * \li prior to calling, zone->catzs is NULL or is equal to 'catzs'
  */
 
+void
+dns_zone_catz_disable(dns_zone_t *zone);
+/*%<
+ * Disable zone as catalog zone, if it is one.
+ *
+ * Requires:
+ *
+ * \li 'zone' is a valid zone object
+ */
+
+bool
+dns_zone_catz_is_enabled(dns_zone_t *zone);
+/*%<
+ * Return a boolean indicating whether the zone is enabled as catalog zone.
+ *
+ * Requires:
+ *
+ * \li 'zone' is a valid zone object
+ */
+
 void
 dns_zone_catz_enable_db(dns_zone_t *zone, dns_db_t *db);
 /*%<
index 31f511103fda172a232ab69415af5d20f04a3ef9..1e0f7cf64ae28561fb799b6d80ee3ab7e06ce105 100644 (file)
@@ -1173,8 +1173,10 @@ dns_xfrin_shutdown
 dns_zone_addnsec3chain
 dns_zone_asyncload
 dns_zone_attach
+dns_zone_catz_disable
 dns_zone_catz_enable
 dns_zone_catz_enable_db
+dns_zone_catz_is_enabled
 dns_zone_cdscheck
 dns_zone_checknames
 dns_zone_clearforwardacl
index 65a3aacab7b8f6a1871bf647f3d673e20b4500c5..bc33e6ede85a78b82fd654f8dd3fcbb35067c182 100644 (file)
@@ -1942,6 +1942,24 @@ dns_zone_catz_enable(dns_zone_t *zone, dns_catz_zones_t *catzs) {
        UNLOCK_ZONE(zone);
 }
 
+void
+dns_zone_catz_disable(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       LOCK_ZONE(zone);
+       if (zone->catzs != NULL) {
+               dns_catz_catzs_detach(&zone->catzs);
+       }
+       UNLOCK_ZONE(zone);
+}
+
+bool
+dns_zone_catz_is_enabled(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       return (zone->catzs != NULL);
+}
+
 /*
  * If a zone is a catalog zone, attach it to update notification in database.
  */