s4:dsdb:vlv_pagination: fix LDAP worker crash on by-value VLV when entries lack the sort attribute
BUG: https://bugzilla.samba.org/show_bug.cgi?id=16296
vlv_value_compare() used the sort attribute's first value without checking that the entry has the attribute. server_sort keeps entries that lack it and sorts them last, so a by-value (greaterThanOrEqual) VLV search whose binary search reached such an entry dereferenced NULL and crashed the LDAP worker. The same happens when aclread removes a sort attribute the caller cannot read.
The fix treats a missing or empty sort attribute as sorting after the target value, matching server_sort in both sort directions (vlv_value_compare_rev() negates the result), and fails the search if the per-GUID lookup does not return exactly one entry.
The new test, VLVTests.test_vlv_gte_with_missing_sort_attr, adds entries without roomNumber and checks the returned VLV window in both directions, with some and with all matched entries lacking the attribute. Without the fix it crashes the worker; with it, samba4.ldap.vlv.python passes (all tests OK, the two existing knownfails unchanged).
Checklist
- Commits have
Signed-off-by:with name/author being identical to the commit author - (optional) This MR is just one part towards a larger feature.
- (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
- CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)
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