]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1808. [bug] zone.c:notify_zone() contained a race condition,
authorMark Andrews <marka@isc.org>
Thu, 3 Feb 2005 05:07:35 +0000 (05:07 +0000)
committerMark Andrews <marka@isc.org>
Thu, 3 Feb 2005 05:07:35 +0000 (05:07 +0000)
                        zone->db could change underneath it.  [RT #13511]

CHANGES
lib/dns/zone.c

diff --git a/CHANGES b/CHANGES
index deb5105dab9df7ed224dc17df5fe328eed1be405..4e628031ec75c4c5da02b9a6f7c0307e97f74a6b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
 1809.  [placeholder]   rt13463
 
-1808.  [placeholder]   rt13511
+1808.  [bug]           zone.c:notify_zone() contained a race condition,
+                       zone->db could change underneath it.  [RT #13511]
 
 1807.  [placeholder]   rt13526
 
index 73cae607395ba9e8b10a96d34b8163ba182866cc..7d3a664eba7ae0f96c5cb8e80d189d54ef611106 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: zone.c,v 1.429 2005/01/11 23:10:05 marka Exp $ */
+/* $Id: zone.c,v 1.430 2005/02/03 05:07:35 marka Exp $ */
 
 #include <config.h>
 
@@ -3042,6 +3042,7 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
        dns_notifytype_t notifytype;
        unsigned int flags = 0;
        isc_boolean_t loggednotify = ISC_FALSE;
+       dns_db_t *db = NULL;
 
        REQUIRE(DNS_ZONE_VALID(zone));
 
@@ -3061,6 +3062,13 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
            zone->type != dns_zone_master)
                return;
 
+       LOCK_ZONE(zone);
+       if (zone->db != NULL)
+               dns_db_attach(zone->db, &db);
+       UNLOCK_ZONE(zone);
+       if (db == NULL)
+               return;
+
        origin = &zone->origin;
 
        /*
@@ -3073,14 +3081,13 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
        /*
         * Get SOA RRset.
         */
-       dns_db_currentversion(zone->db, &version);
-       result = dns_db_findnode(zone->db, origin, ISC_FALSE, &node);
+       dns_db_currentversion(db, &version);
+       result = dns_db_findnode(db, origin, ISC_FALSE, &node);
        if (result != ISC_R_SUCCESS)
                goto cleanup1;
 
        dns_rdataset_init(&soardset);
-       result = dns_db_findrdataset(zone->db, node, version,
-                                    dns_rdatatype_soa,
+       result = dns_db_findrdataset(db, node, version, dns_rdatatype_soa,
                                     dns_rdatatype_none, 0, &soardset, NULL);
        if (result != ISC_R_SUCCESS)
                goto cleanup2;
@@ -3137,8 +3144,7 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
         */
 
        dns_rdataset_init(&nsrdset);
-       result = dns_db_findrdataset(zone->db, node, version,
-                                    dns_rdatatype_ns,
+       result = dns_db_findrdataset(db, node, version, dns_rdatatype_ns,
                                     dns_rdatatype_none, 0, &nsrdset, NULL);
        if (result != ISC_R_SUCCESS)
                goto cleanup3;
@@ -3195,9 +3201,10 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
        if (dns_name_dynamic(&master))
                dns_name_free(&master, zone->mctx);
  cleanup2:
-       dns_db_detachnode(zone->db, &node);
+       dns_db_detachnode(db, &node);
  cleanup1:
-       dns_db_closeversion(zone->db, &version, ISC_FALSE);
+       dns_db_closeversion(db, &version, ISC_FALSE);
+       dns_db_detach(&db);
 }
 
 /***