|
|
96373c |
From 183517787fe86c1bc2359ad807318b8bca573d17 Mon Sep 17 00:00:00 2001
|
|
|
96373c |
From: Thierry Bordaz <tbordaz@redhat.com>
|
|
|
96373c |
Date: Fri, 19 Jan 2018 16:34:36 +0100
|
|
|
96373c |
Subject: [PATCH] Ticket 49545 - final substring extended filter search returns
|
|
|
96373c |
invalid result
|
|
|
96373c |
|
|
|
96373c |
Bug Description:
|
|
|
96373c |
During a search (using extended filter with final substring), the server
|
|
|
96373c |
checks the filter before returning the matching entries.
|
|
|
96373c |
When checking the attribute value against the filter, it
|
|
|
96373c |
uses the wrong value.
|
|
|
96373c |
|
|
|
96373c |
Fix Description:
|
|
|
96373c |
Make suree it uses the right portion of the attribute value, in order
|
|
|
96373c |
to generate the keys to compare.
|
|
|
96373c |
|
|
|
96373c |
https://pagure.io/389-ds-base/issue/49545
|
|
|
96373c |
|
|
|
96373c |
Reviewed by: Ludwig Krispenz
|
|
|
96373c |
|
|
|
96373c |
Platforms tested: F26
|
|
|
96373c |
|
|
|
96373c |
Flag Day: no
|
|
|
96373c |
|
|
|
96373c |
Doc impact: no
|
|
|
96373c |
|
|
|
96373c |
Signed-off-by: Mark Reynolds <mreynolds@redhat.com>
|
|
|
96373c |
---
|
|
|
96373c |
ldap/servers/plugins/collation/orfilter.c | 20 ++++++++++++++++++--
|
|
|
96373c |
1 file changed, 18 insertions(+), 2 deletions(-)
|
|
|
96373c |
|
|
|
96373c |
diff --git a/ldap/servers/plugins/collation/orfilter.c b/ldap/servers/plugins/collation/orfilter.c
|
|
|
96373c |
index a98d90219..672ee7b19 100644
|
|
|
96373c |
--- a/ldap/servers/plugins/collation/orfilter.c
|
|
|
96373c |
+++ b/ldap/servers/plugins/collation/orfilter.c
|
|
|
96373c |
@@ -182,17 +182,33 @@ ss_filter_match(or_filter_t * or, struct berval **vals)
|
|
|
96373c |
} else { /* final */
|
|
|
96373c |
auto size_t attempts = MAX_CHAR_COMBINING;
|
|
|
96373c |
auto char *limit = v.bv_val;
|
|
|
96373c |
+ auto char *end;
|
|
|
96373c |
auto struct berval **vkeys;
|
|
|
96373c |
auto struct berval *vals[2];
|
|
|
96373c |
auto struct berval key;
|
|
|
96373c |
+
|
|
|
96373c |
rc = -1;
|
|
|
96373c |
vals[0] = &v;
|
|
|
96373c |
vals[1] = NULL;
|
|
|
96373c |
key.bv_val = (*k)->bv_val;
|
|
|
96373c |
key.bv_len = (*k)->bv_len - 1;
|
|
|
96373c |
- v.bv_val = (*vals)->bv_val + (*vals)->bv_len;
|
|
|
96373c |
+ /* In the following lines it will loop to find
|
|
|
96373c |
+ * if the end of the attribute value matches the 'final' of the filter
|
|
|
96373c |
+ * Short summary:
|
|
|
96373c |
+ * vals contains the attribute value :for example "hello world"
|
|
|
96373c |
+ * key contain the key generated from the indexing of final part of the filter.
|
|
|
96373c |
+ * for example filter=(<attribut>=*ld), so key contains the indexing("ld").
|
|
|
96373c |
+ *
|
|
|
96373c |
+ * The loop will iterate over the attribute value (vals) from the end of string
|
|
|
96373c |
+ * to the begining. So it will try to index('d'), index('ld'), index('rld'), index('orld')...
|
|
|
96373c |
+ *
|
|
|
96373c |
+ * At each iteration if the key generated from indexing the portion of vals, matches
|
|
|
96373c |
+ * the key generate from the final part of the filter, then the loop stops => we are done
|
|
|
96373c |
+ */
|
|
|
96373c |
+ end = v.bv_val + v.bv_len - 1;
|
|
|
96373c |
+ v.bv_val = end;
|
|
|
96373c |
while (1) {
|
|
|
96373c |
- v.bv_len = (*vals)->bv_len - (v.bv_val - (*vals)->bv_val);
|
|
|
96373c |
+ v.bv_len = end - v.bv_val + 1;
|
|
|
96373c |
vkeys = ix->ix_index(ix, vals, NULL);
|
|
|
96373c |
if (vkeys && vkeys[0]) {
|
|
|
96373c |
auto const struct berval *vkey = vkeys[0];
|
|
|
96373c |
--
|
|
|
96373c |
2.13.6
|
|
|
96373c |
|