]> 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:19:37 +0000 (05:19 +0000)
committerMark Andrews <marka@isc.org>
Thu, 3 Feb 2005 05:19:37 +0000 (05:19 +0000)
                        zone->db could change underneath it.  [RT #13511]

CHANGES
lib/dns/zone.c

diff --git a/CHANGES b/CHANGES
index 8aa180718a9db62819a446b00d540699c2d1f94d..fb6c156288c8f79b23a1ca8beff785244573f3ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,7 @@
 
+1808.  [bug]           zone.c:notify_zone() contained a race condition,
+                       zone->db could change underneath it.  [RT #13511]
+
        --- 9.3.1beta2 released ---
 
 1800.  [bug]           Changes #1719 allowed a INSIST to be triggered.
index aa61f77ec0350675ca8027434440495c8a901343..3e7894cda63e928a2e25126b17145860b4f19ce4 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: zone.c,v 1.333.2.23.2.53 2004/11/22 23:54:01 marka Exp $ */
+/* $Id: zone.c,v 1.333.2.23.2.54 2005/02/03 05:19:37 marka Exp $ */
 
 #include <config.h>
 
@@ -2923,6 +2923,7 @@ zone_notify(dns_zone_t *zone) {
        dns_notifytype_t notifytype;
        unsigned int flags = 0;
        isc_boolean_t loggednotify = ISC_FALSE;
+       dns_db_t *db = NULL;
 
        REQUIRE(DNS_ZONE_VALID(zone));
 
@@ -2937,6 +2938,13 @@ zone_notify(dns_zone_t *zone) {
        if (notifytype == dns_notifytype_no)
                return;
 
+       LOCK_ZONE(zone);
+       if (zone->db != NULL)
+               dns_db_attach(zone->db, &db);
+       UNLOCK_ZONE(zone);
+       if (db == NULL)
+               return;
+
        origin = &zone->origin;
 
        /*
@@ -2949,14 +2957,13 @@ zone_notify(dns_zone_t *zone) {
        /*
         * 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;
@@ -3013,8 +3020,7 @@ zone_notify(dns_zone_t *zone) {
         */
 
        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;
@@ -3071,9 +3077,10 @@ zone_notify(dns_zone_t *zone) {
        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);
 }
 
 /***