From 0d28e1bed26c9828293ef786daf5574f7f31b918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 6 Mar 2026 17:06:16 +0100 Subject: [PATCH 1/2] Fix copy-paste typos in dns_dispatchmgr comments The v6ports and nv6ports fields are documented as "available ports for IPv4" instead of "IPv6". --- lib/dns/dispatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 9b5c224ef9..771c29b888 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -67,8 +67,8 @@ struct dns_dispatchmgr { in_port_t *v4ports; /*%< available ports for IPv4 */ unsigned int nv4ports; /*%< # of available ports for IPv4 */ - in_port_t *v6ports; /*%< available ports for IPv4 */ - unsigned int nv6ports; /*%< # of available ports for IPv4 */ + in_port_t *v6ports; /*%< available ports for IPv6 */ + unsigned int nv6ports; /*%< # of available ports for IPv6 */ }; typedef enum { From 2da669490ca94b9617257a25d93a52ed67dfdd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 6 Mar 2026 17:06:24 +0100 Subject: [PATCH 2/2] Fix resquery reference imbalance on TCP connect failure In fctx_query(), resquery_ref(query) is called before dns_dispatch_connect() in anticipation of the resquery_connected() callback consuming the reference. When dns_dispatch_connect() fails synchronously on TCP (e.g. from dns_transport_get_tlsctx() failing in tcp_dispatch_connect()), the connect callback is never scheduled, so the extra reference is never consumed. The error path then tears down the query via manual cleanup (isc_mem_put) without going through the refcount destructor, leaving the reference imbalanced. Fix by dropping the extra reference on the error path, just after dns_dispatch_done() which cleans up the dispatch entry. --- lib/dns/resolver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e15243274c..20763e612c 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2284,10 +2284,11 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, isc_log_write( DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_RESOLVER, log_level, - "Unable to establish a connection to %s: %s\n", + "Unable to establish a connection to %s: %s", peerbuf, isc_result_totext(result)); } dns_dispatch_done(&query->dispentry); + resquery_unref(query); goto cleanup_fetch; } else { RUNTIME_CHECK(result == ISC_R_SUCCESS);