From: Aram Sargsyan Date: Fri, 22 May 2026 11:31:37 +0000 (+0000) Subject: Fix a bug in xfrin.c:xfrin_connect_done() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb27599b58d8d3fcf89dc05a4f23708831eb88e8;p=thirdparty%2Fbind9.git Fix a bug in xfrin.c:xfrin_connect_done() 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. --- diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 4cd74212bce..652d2da596b 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -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); + } } /*