From 589b2113330c678c1dfeba49ea489992168e41fa Mon Sep 17 00:00:00 2001
From: Mark Reynolds <mreynolds@redhat.com>
Date: Fri, 4 Apr 2014 13:16:27 -0400
Subject: [PATCH 194/225] Ticket 47766 - Tombstone purging can crash the server
if the backend is stopped/disabled
Bug Description: The tombstone purge thread issues a callback search that will start
reading id2entry, even if the backend is stopped. This can crash the
server.
Fix Description: When performing a search and returning entries, check if the backend
is started before reading id2entry.
https://fedorahosted.org/389/ticket/47766
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 559d70e0a1e3df75a66e41fd1c009b25ca6f6a08)
(cherry picked from commit 0232f37a14bfff6e9865fb4d121bbcdf249e1834)
---
ldap/servers/slapd/back-ldbm/ldbm_search.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index d092b2e..552b65b 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -1487,6 +1487,16 @@ ldbm_back_next_search_entry_ext( Slapi_PBlock *pb, int use_extension )
++sr->sr_lookthroughcount; /* checked above */
+ /* Make sure the backend is available */
+ if( be->be_state != BE_STATE_STARTED ){
+ slapi_send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
+ "Backend is stopped", 0, NULL );
+ slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, NULL );
+ delete_search_result_set(pb, &sr);
+ rc = SLAPI_FAIL_GENERAL;
+ goto bail;
+ }
+
/* get the entry */
e = id2entry( be, id, &txn, &err );
if ( e == NULL )
--
1.8.1.4