]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Skip detach when delv's client never created
authorOndřej Surý <ondrej@isc.org>
Thu, 30 Apr 2026 07:38:40 +0000 (09:38 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 30 Apr 2026 10:07:49 +0000 (12:07 +0200)
run_resolve allocates dns_client_t late, but the cleanup epilogue
called dns_client_detach() unconditionally. When convert_name() or
dns_client_create() failed first, the detach hit a NULL client and
the REQUIRE(DNS_CLIENT_VALID) inside it aborted the process with
SIGABRT instead of a clean error exit.

Guard the detach with a NULL check. Add a digdelv test that runs
delv on a query name whose first label exceeds 63 octets and
asserts the process does not exit 134.

Assisted-by: Claude:claude-opus-4-7
(cherry picked from commit dba102ef16821f91f0494f9db5c9a646dcab913f)

bin/delv/delv.c
bin/tests/system/digdelv/tests.sh

index a12c54bb44ebdb31ca81ebcdffa93512c0472674..927100e72e43b1328351c58ed77e9b88fbb56805 100644 (file)
@@ -1982,7 +1982,9 @@ cleanup:
        isc_mem_put(mctx, namelist, sizeof(*namelist));
        isc_loopmgr_shutdown(loopmgr);
 
-       dns_client_detach(&client);
+       if (client != NULL) {
+               dns_client_detach(&client);
+       }
 }
 
 static void
index 6f8dacdaca778c739752b808620aae41cf7b989d..f63033271c6d86af7dc0d210712c10973a0719ee 100644 (file)
@@ -1428,6 +1428,18 @@ if [ -x "$DELV" ]; then
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status + ret))
 
+  n=$((n + 1))
+  echo_i "checking delv exits cleanly on malformed query name ($n)"
+  ret=0
+  longlabel="$(printf 'a%.0s' $(seq 1 64))"
+  delv_with_opts @10.53.0.3 -t a "$longlabel.example.com" >delv.out.test$n 2>&1
+  rc=$?
+  # Pre-fix: SIGABRT (exit 134) from dns_client_detach(NULL) in run_resolve cleanup.
+  [ $rc -eq 134 ] && ret=1
+  grep "label too long" delv.out.test$n >/dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status + ret))
+
   n=$((n + 1))
   echo_i "checking delv with IPv6 on IPv4 does not work ($n)"
   if testsock6 fd92:7065:b8e:ffff::3 2>/dev/null; then