qpzone find() function could set foundname incorrectly

when a requested name is found in the QP trie during a lookup, but its
records have been marked as nonexistent by a previous deletion, then
it's treated as a partial match, but the foundname could be left
pointing to the original qname rather than the parent. this could
lead to an assertion failure in query_findclosestnsec3().
This commit is contained in:
Evan Hunt
2024-12-19 14:19:43 -08:00
parent 9636dc1a1e
commit ad4bab306c
2 changed files with 21 additions and 8 deletions

View File

@@ -170,7 +170,14 @@ ISC_RUN_TEST_IMPL(find) {
dns_rdataset_init(&rdataset);
res = dns_db_find(db1, dns_rootname, v1, dns_rdatatype_soa, 0, 0, NULL,
name, &rdataset, NULL);
assert_int_equal(res, DNS_R_NXDOMAIN);
/*
* Note: in the QPzone database, the root node always exists,
* even if it's empty, so we would get DNS_R_NXRRSET from this
* query. In other databases (including the old RBTDB) the root
* node can be nonexistent, and the query would then return
* DNS_R_NXDOMAIN. Allow for both possibilities.
*/
assert_true(res == DNS_R_NXRRSET || res == DNS_R_NXDOMAIN);
if (dns_rdataset_isassociated(&rdataset)) {
dns_rdataset_disassociate(&rdataset);