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

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