|
|
edc5f2 |
From a21ba4722268349b9c63000145e5d119e1fddd60 Mon Sep 17 00:00:00 2001
|
|
|
6e8815 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
6e8815 |
Date: Thu, 9 Aug 2018 15:27:59 -0400
|
|
|
6e8815 |
Subject: [PATCH] Ticket 49890 : ldapsearch with server side sort crashes the
|
|
|
6e8815 |
ldap server
|
|
|
6e8815 |
|
|
|
6e8815 |
Bug Description:
|
|
|
6e8815 |
Server side sort with a specified matching rule trigger a crash
|
|
|
6e8815 |
|
|
|
6e8815 |
Fix Description:
|
|
|
6e8815 |
Check if the we are able to index the provided value.
|
|
|
6e8815 |
If we are not then slapd_qsort returns an error (LDAP_OPERATION_ERROR)
|
|
|
6e8815 |
|
|
|
6e8815 |
https://pagure.io/389-ds-base/issue/49890
|
|
|
6e8815 |
|
|
|
6e8815 |
Reviewed by: mreynolds
|
|
|
6e8815 |
|
|
|
6e8815 |
Platforms tested: F27
|
|
|
6e8815 |
|
|
|
6e8815 |
Flag Day: no
|
|
|
6e8815 |
|
|
|
6e8815 |
Doc impact: no
|
|
|
6e8815 |
|
|
|
6e8815 |
(cherry picked from commit c989e18f7a3da060b16d39919b920b6b2a19a0ac)
|
|
|
6e8815 |
---
|
|
|
6e8815 |
dirsrvtests/tests/suites/syntax/mr_test.py | 59 ++++++++++++++++++++++
|
|
|
6e8815 |
ldap/servers/slapd/back-ldbm/sort.c | 14 +++++
|
|
|
6e8815 |
2 files changed, 73 insertions(+)
|
|
|
6e8815 |
create mode 100644 dirsrvtests/tests/suites/syntax/mr_test.py
|
|
|
6e8815 |
|
|
|
6e8815 |
diff --git a/dirsrvtests/tests/suites/syntax/mr_test.py b/dirsrvtests/tests/suites/syntax/mr_test.py
|
|
|
6e8815 |
new file mode 100644
|
|
|
6e8815 |
index 000000000..57061222a
|
|
|
6e8815 |
--- /dev/null
|
|
|
6e8815 |
+++ b/dirsrvtests/tests/suites/syntax/mr_test.py
|
|
|
6e8815 |
@@ -0,0 +1,59 @@
|
|
|
6e8815 |
+import logging
|
|
|
6e8815 |
+import pytest
|
|
|
6e8815 |
+import os
|
|
|
6e8815 |
+import ldap
|
|
|
6e8815 |
+from lib389.dbgen import dbgen
|
|
|
6e8815 |
+from lib389._constants import *
|
|
|
6e8815 |
+from lib389.topologies import topology_st as topo
|
|
|
6e8815 |
+from lib389._controls import SSSRequestControl
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+DEBUGGING = os.getenv("DEBUGGING", default=False)
|
|
|
6e8815 |
+if DEBUGGING:
|
|
|
6e8815 |
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
|
|
|
6e8815 |
+else:
|
|
|
6e8815 |
+ logging.getLogger(__name__).setLevel(logging.INFO)
|
|
|
6e8815 |
+log = logging.getLogger(__name__)
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+def test_sss_mr(topo):
|
|
|
6e8815 |
+ """Test matching rule/server side sort does not crash DS
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ :id: 48c73d76-1694-420f-ab55-187135f2d260
|
|
|
6e8815 |
+ :setup: Standalone Instance
|
|
|
6e8815 |
+ :steps:
|
|
|
6e8815 |
+ 1. Add sample entries to the database
|
|
|
6e8815 |
+ 2. Perform search using server side control (uid:2.5.13.3)
|
|
|
6e8815 |
+ :expectedresults:
|
|
|
6e8815 |
+ 1. Success
|
|
|
6e8815 |
+ 2. Success
|
|
|
6e8815 |
+ """
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ log.info("Creating LDIF...")
|
|
|
6e8815 |
+ ldif_dir = topo.standalone.get_ldif_dir()
|
|
|
6e8815 |
+ ldif_file = os.path.join(ldif_dir, 'mr-crash.ldif')
|
|
|
6e8815 |
+ dbgen(topo.standalone, 5, ldif_file, DEFAULT_SUFFIX)
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ log.info("Importing LDIF...")
|
|
|
6e8815 |
+ topo.standalone.stop()
|
|
|
6e8815 |
+ assert topo.standalone.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
|
|
|
6e8815 |
+ topo.standalone.start()
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ log.info('Search using server side sorting using undefined mr in the attr...')
|
|
|
6e8815 |
+ sort_ctrl = SSSRequestControl(True, ['uid:2.5.13.3'])
|
|
|
6e8815 |
+ controls = [sort_ctrl]
|
|
|
6e8815 |
+ msg_id = topo.standalone.search_ext(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
|
|
|
6e8815 |
+ "objectclass=*", serverctrls=controls)
|
|
|
6e8815 |
+ try:
|
|
|
6e8815 |
+ rtype, rdata, rmsgid, response_ctrl = topo.standalone.result3(msg_id)
|
|
|
6e8815 |
+ except ldap.OPERATIONS_ERROR:
|
|
|
6e8815 |
+ pass
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ log.info("Test PASSED")
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+if __name__ == '__main__':
|
|
|
6e8815 |
+ # Run isolated
|
|
|
6e8815 |
+ # -s for DEBUG mode
|
|
|
6e8815 |
+ CURRENT_FILE = os.path.realpath(__file__)
|
|
|
6e8815 |
+ pytest.main(["-s", CURRENT_FILE])
|
|
|
6e8815 |
+
|
|
|
6e8815 |
diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
|
|
|
6e8815 |
index 5b84d87f3..70ac60803 100644
|
|
|
6e8815 |
--- a/ldap/servers/slapd/back-ldbm/sort.c
|
|
|
6e8815 |
+++ b/ldap/servers/slapd/back-ldbm/sort.c
|
|
|
6e8815 |
@@ -546,6 +546,16 @@ compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s, baggage_carrier *bc, int *e
|
|
|
6e8815 |
/* Now copy it, so the second call doesn't crap on it */
|
|
|
6e8815 |
value_a = slapi_ch_bvecdup(temp_value); /* Really, we'd prefer to not call the chXXX variant...*/
|
|
|
6e8815 |
matchrule_values_to_keys(this_one->mr_pb, actual_value_b, &value_b);
|
|
|
6e8815 |
+
|
|
|
6e8815 |
+ if ((actual_value_a && !value_a) ||
|
|
|
6e8815 |
+ (actual_value_b && !value_b)) {
|
|
|
6e8815 |
+ ber_bvecfree(actual_value_a);
|
|
|
6e8815 |
+ ber_bvecfree(actual_value_b);
|
|
|
6e8815 |
+ CACHE_RETURN(&inst->inst_cache, &a);
|
|
|
6e8815 |
+ CACHE_RETURN(&inst->inst_cache, &b);
|
|
|
6e8815 |
+ *error = 1;
|
|
|
6e8815 |
+ return 0;
|
|
|
6e8815 |
+ }
|
|
|
6e8815 |
if (actual_value_a)
|
|
|
6e8815 |
ber_bvecfree(actual_value_a);
|
|
|
6e8815 |
if (actual_value_b)
|
|
|
6e8815 |
@@ -717,6 +727,8 @@ recurse:
|
|
|
6e8815 |
A[i] >= A[lo] for higuy <= i <= hi */
|
|
|
6e8815 |
|
|
|
6e8815 |
do {
|
|
|
6e8815 |
+ if (error)
|
|
|
6e8815 |
+ return LDAP_OPERATIONS_ERROR;
|
|
|
6e8815 |
loguy++;
|
|
|
6e8815 |
} while (loguy <= hi && compare_entries_sv(loguy, lo, s, bc, &error) <= 0);
|
|
|
6e8815 |
|
|
|
6e8815 |
@@ -724,6 +736,8 @@ recurse:
|
|
|
6e8815 |
either loguy > hi or A[loguy] > A[lo] */
|
|
|
6e8815 |
|
|
|
6e8815 |
do {
|
|
|
6e8815 |
+ if (error)
|
|
|
6e8815 |
+ return LDAP_OPERATIONS_ERROR;
|
|
|
6e8815 |
higuy--;
|
|
|
6e8815 |
} while (higuy > lo && compare_entries_sv(higuy, lo, s, bc, &error) >= 0);
|
|
|
6e8815 |
|
|
|
6e8815 |
--
|
|
|
6e8815 |
2.17.1
|
|
|
6e8815 |
|