]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4833. [bug] isc_event_free should check that the event is not
authorMark Andrews <marka@isc.org>
Wed, 29 Nov 2017 23:31:44 +0000 (10:31 +1100)
committerMark Andrews <marka@isc.org>
Wed, 29 Nov 2017 23:31:44 +0000 (10:31 +1100)
                        linked when called. [RT #46725]

4832.   [bug]           Events were not being removed from zone->rss_events.
                        [RT #46725]

CHANGES
lib/dns/rpz.c
lib/dns/zone.c
lib/isc/event.c
lib/isc/task.c

diff --git a/CHANGES b/CHANGES
index db8a6d56cace378ab90ba7d74f581660251e6467..c7cdff34d0b4f95d32fcdcd8e2b7ee35be2082b5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+4833.  [bug]           isc_event_free should check that the event is not
+                       linked when called. [RT #46725]
+
+4832.  [bug]           Events were not being removed from zone->rss_events.
+                       [RT #46725]
+
 4831.  [bug]           Convert the RRSIG expirytime to 64 bits for
                        comparisions in diff.c:resign. [RT #46710]
 
index 800cfc6a4da805c60f7294254861c9689aea093a..2f98e6702123af3f037a5295bc342fc49710ec76 100644 (file)
@@ -1555,6 +1555,8 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) {
        zone->updbit = NULL;
        zone->rpzs = rpzs;
        zone->db_registered = ISC_FALSE;
+       ISC_EVENT_INIT(&zone->updateevent, sizeof(zone->updateevent),
+                      0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
 
        zone->num = rpzs->p.num_zones++;
        rpzs->zones[zone->num] = zone;
@@ -1633,6 +1635,7 @@ dns_rpz_dbupdate_callback(dns_db_t *db, void *fn_arg) {
                        isc_event_t *event;
 
                        dns_db_currentversion(zone->db, &zone->dbversion);
+                       INSIST(!ISC_LINK_LINKED(&zone->updateevent, ev_link));
                        ISC_EVENT_INIT(&zone->updateevent,
                                       sizeof(zone->updateevent), 0, NULL,
                                       DNS_EVENT_RPZUPDATED,
@@ -1669,6 +1672,7 @@ dns_rpz_update_taskaction(isc_task_t *task, isc_event_t *event) {
 
        UNUSED(task);
        zone = (dns_rpz_zone_t *) event->ev_arg;
+       isc_event_free(&event);
        LOCK(&zone->rpzs->maint_lock);
        zone->updatepending = ISC_FALSE;
        zone->updaterunning = ISC_TRUE;
@@ -1679,7 +1683,6 @@ dns_rpz_update_taskaction(isc_task_t *task, isc_event_t *event) {
        result = isc_time_now(&zone->lastupdated);
        RUNTIME_CHECK(result == ISC_R_SUCCESS);
        UNLOCK(&zone->rpzs->maint_lock);
-       isc_event_free(&event);
 }
 
 static isc_result_t
@@ -1943,6 +1946,7 @@ update_quantum(isc_task_t *task, isc_event_t *event) {
                /*
                 * We finished a quantum; trigger the next one and return
                 */
+               INSIST(!ISC_LINK_LINKED(&rpz->updateevent, ev_link));
                ISC_EVENT_INIT(&rpz->updateevent,
                               sizeof(rpz->updateevent), 0, NULL,
                               DNS_EVENT_RPZUPDATED,
@@ -1995,6 +1999,7 @@ dns_rpz_update_from_db(dns_rpz_zone_t *rpz) {
        }
 
        event = &rpz->updateevent;
+       INSIST(!ISC_LINK_LINKED(&rpz->updateevent, ev_link));
        ISC_EVENT_INIT(&rpz->updateevent, sizeof(rpz->updateevent),
                       0, NULL, DNS_EVENT_RPZUPDATED,
                       update_quantum, rpz, rpz, NULL, NULL);
index 1cb07feba1d083e6e57a176af2903ec16dcbb738..45c1754695e8e74429ec373031c461dc82be904d 100644 (file)
@@ -14360,6 +14360,7 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) {
                LOCK_ZONE(zone);
                INSIST(zone->irefs > 1);
                zone->irefs--;
+               ISC_LIST_UNLINK(zone->rss_events, event, ev_link);
                goto nextevent;
        }
        dns_zone_idetach(&zone);
index af02cfdb6541817c87547f5aa5589a32b0ef7632..a369d7f6cba2f1a0d427135a9e520bd5a487e10d 100644 (file)
@@ -91,6 +91,9 @@ isc_event_free(isc_event_t **eventp) {
        event = *eventp;
        REQUIRE(event != NULL);
 
+       REQUIRE(!ISC_LINK_LINKED(event, ev_link));
+       REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink));
+
        if (event->ev_destroy != NULL)
                (event->ev_destroy)(event);
 
index e534d732edd646d68a25c547825d72152bc5199f..3b73e595ed11aa311e812f2ed6921f1fe5728a86 100644 (file)
@@ -703,6 +703,7 @@ isc__task_purgerange(isc_task_t *task0, void *sender, isc_eventtype_t first,
 
        for (event = HEAD(events); event != NULL; event = next_event) {
                next_event = NEXT(event, ev_link);
+               ISC_LIST_UNLINK(events, event, ev_link);
                isc_event_free(&event);
        }