]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a bug in xfrin.c:xfrin_connect_done() 12081/head
authorAram Sargsyan <aram@isc.org>
Fri, 22 May 2026 11:31:37 +0000 (11:31 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Fri, 12 Jun 2026 14:59:47 +0000 (14:59 +0000)
When the connect callback's result is ISC_R_SUCCESS and the callback
changes the result because of some condition, the 'xfr' should not
be detached, because it now belongs to the receive callback.

Detach the reference only if the callback's result is non-success.

lib/dns/xfrin.c

index 4cd74212bceb6e5aa4ac02afe27eac0d9bbc845f..652d2da596bcb7779bd907560bda48b1ef505e22 100644 (file)
@@ -249,7 +249,7 @@ static isc_result_t
 xfrin_start(dns_xfrin_t *xfr);
 
 static void
-xfrin_connect_done(isc_result_t result, isc_region_t *region, void *arg);
+xfrin_connect_done(isc_result_t eresult, isc_region_t *region, void *arg);
 static isc_result_t
 xfrin_send_request(dns_xfrin_t *xfr);
 static void
@@ -1460,19 +1460,18 @@ cleanup:
  * A connection has been established.
  */
 static void
-xfrin_connect_done(isc_result_t result, isc_region_t *region ISC_ATTR_UNUSED,
+xfrin_connect_done(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
                   void *arg) {
        dns_xfrin_t *xfr = (dns_xfrin_t *)arg;
        char addrtext[ISC_SOCKADDR_FORMATSIZE];
        char signerbuf[DNS_NAME_FORMATSIZE];
        const char *signer = "", *sep = "";
        dns_zonemgr_t *zmgr = NULL;
+       isc_result_t result;
 
        REQUIRE(VALID_XFRIN(xfr));
 
-       if (atomic_load(&xfr->shuttingdown)) {
-               result = ISC_R_SHUTTINGDOWN;
-       }
+       result = atomic_load(&xfr->shuttingdown) ? ISC_R_SHUTTINGDOWN : eresult;
 
        LIBDNS_XFRIN_CONNECTED(xfr, xfr->info, result);
 
@@ -1540,7 +1539,13 @@ cleanup:
        }
 
 detach:
-       dns_xfrin_detach(&xfr);
+       /*
+        * If the connection was successful, then the reference now belongs to
+        * the receive callback. Otherwise, detach it.
+        */
+       if (eresult != ISC_R_SUCCESS) {
+               dns_xfrin_detach(&xfr);
+       }
 }
 
 /*