]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix a possible use-after-detach bug in rndc
authorEvan Hunt <each@isc.org>
Fri, 2 Sep 2022 23:20:33 +0000 (16:20 -0700)
committerEvan Hunt <each@isc.org>
Mon, 12 Sep 2022 21:03:05 +0000 (14:03 -0700)
we need to detach the rndc task when calling isc_app_shutdown(),
otherwise it may be detached before the last reference to it.
while this does not prevent rndc from working, it causes a spurious
core dump on shutdown.

bin/rndc/rndc.c

index b81ed3ed2632a4fb38128d638081217fa0c8268f..c292a66dbf37852b3beb6b32fd90e235d6897b5f 100644 (file)
@@ -307,6 +307,7 @@ rndc_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
            atomic_load_acquire(&recvs) == 0)
        {
                shuttingdown = true;
+               isc_task_detach(&rndc_task);
                isc_app_shutdown();
        }
 }
@@ -392,6 +393,7 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
            atomic_load_acquire(&sends) == 0)
        {
                shuttingdown = true;
+               isc_task_detach(&rndc_task);
                isc_app_shutdown();
        }
 }
@@ -1081,7 +1083,6 @@ main(int argc, char **argv) {
                fatal("isc_app_run() failed: %s", isc_result_totext(result));
        }
 
-       isc_task_detach(&rndc_task);
        isc_managers_destroy(&netmgr, &taskmgr, NULL);
 
        /*