andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 6 months ago
Clone

Blame SOURCES/0014-Issue-4428-BUG-Paged-Results-with-critical-false-cau.patch

3280a9
From 05b66529117d1cd85a636ab7d8fc84abdec814de Mon Sep 17 00:00:00 2001
3280a9
From: William Brown <william@blackhats.net.au>
3280a9
Date: Thu, 12 Nov 2020 13:04:21 +1000
3280a9
Subject: [PATCH] Issue 4428 - BUG Paged Results with critical false causes
3280a9
 sigsegv in chaining
3280a9
3280a9
Bug Description: When a paged search through chaining backend is
3280a9
received with a false criticality (such as SSSD), chaining backend
3280a9
will sigsegv due to a null context.
3280a9
3280a9
Fix Description: When a NULL ctx is recieved to be freed, this is
3280a9
as paged results have finished being sent, so we check the NULL
3280a9
ctx and move on.
3280a9
3280a9
fixes: #4428
3280a9
3280a9
Author: William Brown <william@blackhats.net.au>
3280a9
3280a9
Review by: @droideck, @mreynolds389
3280a9
---
3280a9
 ldap/servers/plugins/chainingdb/cb_search.c | 6 ++++++
3280a9
 ldap/servers/plugins/chainingdb/cb_utils.c  | 4 ++++
3280a9
 2 files changed, 10 insertions(+)
3280a9
3280a9
diff --git a/ldap/servers/plugins/chainingdb/cb_search.c b/ldap/servers/plugins/chainingdb/cb_search.c
3280a9
index 69d23a6b5..d47cbc8e4 100644
3280a9
--- a/ldap/servers/plugins/chainingdb/cb_search.c
3280a9
+++ b/ldap/servers/plugins/chainingdb/cb_search.c
3280a9
@@ -740,6 +740,12 @@ chaining_back_search_results_release(void **sr)
3280a9
 
3280a9
     slapi_log_err(SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
3280a9
                   "chaining_back_search_results_release\n");
3280a9
+    if (ctx == NULL) {
3280a9
+        /* The paged search is already complete, just return */
3280a9
+        /* Could we have a ctx state flag instead? */
3280a9
+        return;
3280a9
+    }
3280a9
+
3280a9
     if (ctx->readahead != ctx->tobefreed) {
3280a9
         slapi_entry_free(ctx->readahead);
3280a9
     }
3280a9
diff --git a/ldap/servers/plugins/chainingdb/cb_utils.c b/ldap/servers/plugins/chainingdb/cb_utils.c
3280a9
index dfd5dd92c..d52fd25a6 100644
3280a9
--- a/ldap/servers/plugins/chainingdb/cb_utils.c
3280a9
+++ b/ldap/servers/plugins/chainingdb/cb_utils.c
3280a9
@@ -279,7 +279,11 @@ cb_add_suffix(cb_backend_instance *inst, struct berval **bvals, int apply_mod, c
3280a9
     return LDAP_SUCCESS;
3280a9
 }
3280a9
 
3280a9
+#ifdef DEBUG
3280a9
+static int debug_on = 1;
3280a9
+#else
3280a9
 static int debug_on = 0;
3280a9
+#endif
3280a9
 
3280a9
 int
3280a9
 cb_debug_on()
3280a9
-- 
3280a9
2.26.2
3280a9