zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

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

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