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