Skip to content

ldb_match: fix wildcard compare

The last chunk of text in a wildcard ldap search -- that is, after the last asterisk -- must match the last bit of the string being searched against. "a*b" matches "absorb" but not "abba". RFC4517 calls this the "final substring".

The way we have been trying to find this last match is to find the first possible match, then clump our way down the string looking for later matches. This fails badly when there are overlapping matches.

The situation seen in https://bugzilla.samba.org/show_bug.cgi?id=14044 is like this: there is a string "abbbbb" that should match the search term "*bb".

    abbbbb
     ^ ^ ^
     1 2 3

We first match the first pair of bs, then jump to the second pair, then look for a third, but there isn't a complete third pair, so we say it does not match. But it obviously does match, and all that work we are doing is silly: we just need to look at the end of the string.

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code
Edited by Andrew Bartlett

Merge request reports