]> git.ipfire.org Git - thirdparty/bind9.git/commit
and fix another dns_qp_lookup() iterator bug
authorMatthijs Mekking <matthijs@isc.org>
Thu, 7 Dec 2023 09:11:14 +0000 (10:11 +0100)
committerEvan Hunt <each@isc.org>
Mon, 11 Dec 2023 21:01:29 +0000 (21:01 +0000)
commit276bdcf5cff106bc24aad13af68fb350171438ca
treece24d05166a73cbe2ac665e05fa192a1dfd7bbad
parenta71c0f5338c6753d716fee8752cd6a891b7c4e80
and fix another dns_qp_lookup() iterator bug

There was yet another edge case in which an iterator could be
positioned at the wrong node after dns_qp_lookup(). When searching for
a key, it's possible to reach a leaf that matches at the given offset,
but because the offset point is *after* the point where the search key
differs from the leaf's contents, we are now at the wrong leaf.

In other words, the bug fixed the previous commit for dead-end branches
must also be applied on matched leaves.

For example, if searching for the key "monpop", we could reach a branch
containing "moop" and "moor". the branch offset point - i.e., the point
after which the branch's leaves differ from each other - is the
fourth character ("p" or "r"). The search key matches the fourth
character "p", and takes that twig to the next node (which can be
a branch for names starting with "moop", or could be a leaf node for
"moop").

The old code failed to detect this condition, and would have
incorrectly left the iterator pointing at some successor, and not
at the predecessor of the "moop".

To find the right predecessor in this case, we need to get to the
previous branch and get the previous from there.

This has been fixed and the unit test now includes several new
scenarios for testing search names that match and unmatch on the
offset but have a different character before the offset.
lib/dns/qp.c
tests/dns/qp_test.c