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.
This commit is contained in:
committed by
Evan Hunt
parent
a71c0f5338
commit
276bdcf5cf
@@ -667,7 +667,16 @@ ISC_RUN_TEST_IMPL(predecessors) {
|
||||
{ "b.d.", "c.b.b.", ISC_R_NOTFOUND },
|
||||
{ "mon.", "a.b.c.d.e.", ISC_R_NOTFOUND },
|
||||
{ "moor.", "moops.", ISC_R_NOTFOUND },
|
||||
{ "mopbop.", "moops.", ISC_R_NOTFOUND },
|
||||
{ "moppop.", "moops.", ISC_R_NOTFOUND },
|
||||
{ "mopzop.", "moops.", ISC_R_NOTFOUND },
|
||||
{ "mop.", "moops.", ISC_R_NOTFOUND },
|
||||
{ "monbop.", "a.b.c.d.e.", ISC_R_NOTFOUND },
|
||||
{ "monpop.", "a.b.c.d.e.", ISC_R_NOTFOUND },
|
||||
{ "monzop.", "a.b.c.d.e.", ISC_R_NOTFOUND },
|
||||
{ "mon.", "a.b.c.d.e.", ISC_R_NOTFOUND },
|
||||
{ "moop.", "moon.", ISC_R_NOTFOUND },
|
||||
{ "moopser.", "moops.", ISC_R_NOTFOUND },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -695,7 +704,16 @@ ISC_RUN_TEST_IMPL(predecessors) {
|
||||
{ "0.b.c.d.e.", "x.k.c.d.", DNS_R_PARTIALMATCH },
|
||||
{ "mon.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
|
||||
{ "moor.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ "mopbop.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ "moppop.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ "mopzop.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ "mop.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ "monbop.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
|
||||
{ "monpop.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
|
||||
{ "monzop.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
|
||||
{ "mon.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
|
||||
{ "moop.", "moon.", DNS_R_PARTIALMATCH },
|
||||
{ "moopser.", "moops.", DNS_R_PARTIALMATCH },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user