andykimpe / rpms / 389-ds-base

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

Blame 0205-Ticket-47771-Move-parentsdn-initialization-to-avoid-.patch

dc8c34
From 6eb26cfe75743401ddf892b271efccad72656831 Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Mon, 21 Apr 2014 13:06:52 -0400
dc8c34
Subject: [PATCH 205/225] Ticket 47771 - Move parentsdn initialization to avoid
dc8c34
 crash
dc8c34
dc8c34
    Bug Description:  It's possible to call slapi_sdn_done() before parentsdn is
dc8c34
                      initialized - which will crash the server.
dc8c34
dc8c34
    Fix Description:  Initialize parentsdn at the top of the function.
dc8c34
dc8c34
    https://fedorahosted.org/389/ticket/47771
dc8c34
dc8c34
    Reviewed by: nhosoi(Thanks!)
dc8c34
(cherry picked from commit 00a7594e6fd3d1ff5b6fb5100aa5e1bac5e1eada)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/ldbm_delete.c | 6 ++----
dc8c34
 1 file changed, 2 insertions(+), 4 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
index f6e6005..c9ce70f 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
@@ -108,6 +108,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 	slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation );
dc8c34
 	
dc8c34
 	slapi_sdn_init(&nscpEntrySDN);
dc8c34
+	slapi_sdn_init(&parentsdn);
dc8c34
 
dc8c34
 	/* dblayer_txn_init needs to be called before "goto error_return" */
dc8c34
 	dblayer_txn_init(li,&txn);
dc8c34
@@ -321,7 +322,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 	 * seems to deadlock the database when dblayer_txn_begin is
dc8c34
 	 * called.
dc8c34
 	 */
dc8c34
-	slapi_sdn_init(&parentsdn);
dc8c34
 	slapi_sdn_get_backend_parent_ext(sdnp, &parentsdn, pb->pb_backend, is_tombstone_entry);
dc8c34
 	if ( !slapi_sdn_isempty(&parentsdn) )
dc8c34
 	{
dc8c34
@@ -361,7 +361,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 					}
dc8c34
 					retval = -1;
dc8c34
 					CACHE_RETURN(&(inst->inst_cache), &parent);
dc8c34
-					slapi_sdn_done(&parentsdn);
dc8c34
 					goto error_return;
dc8c34
 				} else {
dc8c34
 					/* entry locked, move on */
dc8c34
@@ -398,7 +397,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 			                                      op, &haschildren);
dc8c34
 			/* The modify context now contains info needed later */
dc8c34
 			if (0 != retval) {
dc8c34
-				slapi_sdn_done(&parentsdn);
dc8c34
 				ldap_result_code= LDAP_OPERATIONS_ERROR;
dc8c34
 				goto error_return;
dc8c34
 			}
dc8c34
@@ -418,7 +416,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 			}
dc8c34
 		}
dc8c34
 	}
dc8c34
-	slapi_sdn_done(&parentsdn);
dc8c34
     
dc8c34
 	if(create_tombstone_entry)
dc8c34
 	{
dc8c34
@@ -1249,6 +1246,7 @@ diskfull_return:
dc8c34
 	slapi_ch_free((void**)&errbuf);
dc8c34
 	slapi_sdn_done(&nscpEntrySDN);
dc8c34
 	slapi_ch_free_string(&e_uniqueid);
dc8c34
+	slapi_sdn_done(&parentsdn);
dc8c34
 	if (pb->pb_conn)
dc8c34
 	{
dc8c34
 		slapi_log_error (SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%" NSPRIu64 " op=%d\n", pb->pb_conn->c_connid, operation->o_opid);
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34