fix: dev: Fix swapped arguments in redirect2() single-label branch

On a recursive resolver with nxdomain-redirect configured, an
NXDOMAIN result for a query whose qname is the root could corrupt
the view's nxdomain-redirect target, after which the redirect
feature stopped working for every subsequent query in that view
until named was restarted.

Closes #5908

Merge branch '5908-query-redirect2-name-copy-arg-swap' into 'main'

See merge request isc-projects/bind9!11908
This commit is contained in:
Ondřej Surý 2026-04-29 21:46:32 +02:00
commit f5853e765f
2 changed files with 11 additions and 1 deletions

View file

@ -542,6 +542,16 @@ n=$((n + 1))
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
echo_i "checking nxdomain-redirect survives query for root ($n)"
ret=0
$DIG $DIGOPTS . any @10.53.0.4 -b 10.53.0.2 >dig.out.ns4.test$n.a || ret=1
$DIG $DIGOPTS nonexist. @10.53.0.4 -b 10.53.0.2 a >dig.out.ns4.test$n.b || ret=1
grep "status: NOERROR" dig.out.ns4.test$n.b >/dev/null || ret=1
grep "nonexist. .*100.100.100.1" dig.out.ns4.test$n.b >/dev/null || ret=1
n=$((n + 1))
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
echo_i "checking extended error is not set on allow-recursion ($n)"
ret=0
$DIG $DIGOPTS example. @10.53.0.1 -b 10.53.0.2 soa >dig.out.ns1.test$n || ret=1

View file

@ -4900,7 +4900,7 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset,
return ISC_R_NOTFOUND;
}
} else {
dns_name_copy(redirectname, client->inner.view->redirectzone);
dns_name_copy(client->inner.view->redirectzone, redirectname);
}
result = query_getdb(client, redirectname, qtype,