* the predecessor name for a non-exact match.
*
* if 'matched' is true, then the search ended at a leaf.
- * if it was not an exact match, then we're now pointing at
- * the immediate successor of the searched-for name, and can
- * use the qpiter stack we've constructed to step back to
- * the predecessor. if it was an exact match, we don't need to
- * do anything.
+ * if it was not an exact match, then we're now pointing
+ * at either the immediate predecessor or the immediate
+ * successor of the searched-for name; if successor, we can
+ * now use the qpiter stack we've constructed to step back to
+ * the predecessor. if we're pointed at the predecessor
+ * or it was an exact match, we don't need to do anything.
*
* if 'matched' is false, then the search failed at a branch
* node, and we would already have positioned the iterator
* at the predecessor.
*/
if (getpred && matched) {
- if (offset != QPKEY_EQUAL) {
+ if (offset != QPKEY_EQUAL &&
+ (offset <= searchlen && offset <= foundlen &&
+ found[offset] > search[offset]))
+ {
prevleaf(iter);
}
}
{ "a.b.c.e.f.", "a.b.c.d.e.", ISC_R_NOTFOUND },
{ "z.y.x.", "a.b.c.d.e.", ISC_R_NOTFOUND },
{ "w.c.d.", "x.k.c.d.", DNS_R_PARTIALMATCH },
- { "z.z.z.z.k.c.d.", "a.b.c.d.", DNS_R_PARTIALMATCH },
+ { "z.z.z.z.k.c.d.", "x.k.c.d.", DNS_R_PARTIALMATCH },
{ "w.k.c.d.", "a.b.c.d.", DNS_R_PARTIALMATCH },
{ "d.a.", "e.d.c.b.a.", DNS_R_PARTIALMATCH },
{ "0.b.c.d.e.", "x.k.c.d.", ISC_R_NOTFOUND },
{ "a.b.c.e.f.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
{ "z.y.x.", "a.b.c.d.e.", DNS_R_PARTIALMATCH },
{ "w.c.d.", "x.k.c.d.", DNS_R_PARTIALMATCH },
- { "z.z.z.z.k.c.d.", "a.b.c.d.", DNS_R_PARTIALMATCH },
+ { "z.z.z.z.k.c.d.", "x.k.c.d.", DNS_R_PARTIALMATCH },
{ "w.k.c.d.", "a.b.c.d.", DNS_R_PARTIALMATCH },
{ "d.a.", "e.d.c.b.a.", DNS_R_PARTIALMATCH },
{ "0.b.c.d.e.", "x.k.c.d.", DNS_R_PARTIALMATCH },