From: Hallvard Furuseth Date: Fri, 31 Dec 2010 10:46:22 +0000 (+0000) Subject: ITS#6758 Avoid SlapReply reuse, simple cases. X-Git-Tag: MIGRATION_CVS2GIT~304 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=13f52646b26e3afbb16e78c2487f19f7854a9180;p=openldap ITS#6758 Avoid SlapReply reuse, simple cases. Caller provides and reuses a SlapReply it does not read after initialization. So reinitialize or move the declaration inwards. In case of refint, move the rs parameter into refint_repair(). --- diff --git a/contrib/slapd-modules/addpartial/addpartial-overlay.c b/contrib/slapd-modules/addpartial/addpartial-overlay.c index 8cc099c2d0..824e9a0570 100644 --- a/contrib/slapd-modules/addpartial/addpartial-overlay.c +++ b/contrib/slapd-modules/addpartial/addpartial-overlay.c @@ -43,7 +43,6 @@ static slap_overinst addpartial; static int addpartial_add( Operation *op, SlapReply *rs) { Operation nop = *op; - SlapReply nrs = { REP_RESULT }; Entry *toAdd = NULL; Entry *found = NULL; slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; @@ -258,12 +257,6 @@ static int addpartial_add( Operation *op, SlapReply *rs) Debug(LDAP_DEBUG_TRACE, "%s: mods to do...\n", addpartial.on_bi.bi_type, 0, 0); - memset(&nrs, 0, sizeof(nrs)); - nrs.sr_type = REP_RESULT; - nrs.sr_err = LDAP_SUCCESS; - nrs.sr_entry = NULL; - nrs.sr_text = NULL; - nop.o_tag = LDAP_REQ_MODIFY; nop.orm_modlist = mods; nop.orm_no_opattrs = 0; @@ -281,6 +274,7 @@ static int addpartial_add( Operation *op, SlapReply *rs) if(nop.o_bd->be_modify) { + SlapReply nrs = { REP_RESULT }; rc = (nop.o_bd->be_modify)(&nop, &nrs); } diff --git a/contrib/slapd-modules/autogroup/autogroup.c b/contrib/slapd-modules/autogroup/autogroup.c index a71a083473..97fd28f77d 100644 --- a/contrib/slapd-modules/autogroup/autogroup.c +++ b/contrib/slapd-modules/autogroup/autogroup.c @@ -448,6 +448,8 @@ autogroup_add_members_from_filter( Operation *op, Entry *e, autogroup_entry_t *a o.o_bd->bd_info = (BackendInfo *)on; if ( modify == 1 && agg.agg_mod ) { + rs_reinit( &rs, REP_RESULT ); + o = *op; o.o_callback = &null_cb; o.o_tag = LDAP_REQ_MODIFY; @@ -1703,7 +1705,6 @@ autogroup_db_open( autogroup_def_t *agd; autogroup_sc_t ags; Operation *op; - SlapReply rs = { REP_RESULT }; slap_callback cb = { 0 }; void *thrctx = ldap_pvt_thread_pool_context(); @@ -1746,6 +1747,7 @@ autogroup_db_open( op->o_callback = &cb; for (agd = agi->agi_def ; agd ; agd = agd->agd_next) { + SlapReply rs = { REP_RESULT }; autogroup_build_def_filter(agd, op); diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 5b4e37b917..7a3e18a2b9 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -4193,10 +4193,12 @@ config_setup_ldif( BackendDB *be, const char *dir, int readit ) { op->o_tag = LDAP_REQ_ADD; if ( rc == LDAP_SUCCESS && sc.frontend ) { + rs_reinit( &rs, REP_RESULT ); op->ora_e = sc.frontend; rc = op->o_bd->be_add( op, &rs ); } if ( rc == LDAP_SUCCESS && sc.config ) { + rs_reinit( &rs, REP_RESULT ); op->ora_e = sc.config; rc = op->o_bd->be_add( op, &rs ); } @@ -6866,8 +6868,10 @@ config_back_db_open( BackendDB *be, ConfigReply *cr ) return -1; } ce = e->e_private; - if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd ) + if ( be->be_cf_ocs && be->be_cf_ocs->co_cfadd ) { + rs_reinit( &rs, REP_RESULT ); be->be_cf_ocs->co_cfadd( op, &rs, e, &c ); + } /* Iterate through overlays */ if ( oi ) { slap_overinst *on; @@ -6906,8 +6910,10 @@ config_back_db_open( BackendDB *be, ConfigReply *cr ) if ( !oe ) { return -1; } - if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd ) + if ( c.bi->bi_cf_ocs && c.bi->bi_cf_ocs->co_cfadd ) { + rs_reinit( &rs, REP_RESULT ); c.bi->bi_cf_ocs->co_cfadd( op, &rs, oe, &c ); + } } } } diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 43832ba7ca..12dbb7c1fb 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -702,7 +702,6 @@ static void connection_abandon( Connection *c ) Operation *o, *next, op = {0}; Opheader ohdr = {0}; - SlapReply rs = {0}; op.o_hdr = &ohdr; op.o_conn = c; @@ -710,6 +709,8 @@ static void connection_abandon( Connection *c ) op.o_tag = LDAP_REQ_ABANDON; for ( o = LDAP_STAILQ_FIRST( &c->c_ops ); o; o=next ) { + SlapReply rs = {REP_RESULT}; + next = LDAP_STAILQ_NEXT( o, o_next ); op.orn_msgid = o->o_msgid; o->o_abandon = 1; diff --git a/servers/slapd/overlays/accesslog.c b/servers/slapd/overlays/accesslog.c index 4f4bbafafa..542ad193f0 100644 --- a/servers/slapd/overlays/accesslog.c +++ b/servers/slapd/overlays/accesslog.c @@ -669,8 +669,10 @@ accesslog_purge( void *ctx, void *arg ) for (i=0; io_req_dn = pd.dn[i]; op->o_req_ndn = pd.ndn[i]; - if ( !slapd_shutdown ) + if ( !slapd_shutdown ) { + rs_reinit( &rs, REP_RESULT ); op->o_bd->be_delete( op, &rs ); + } ch_free( pd.ndn[i].bv_val ); ch_free( pd.dn[i].bv_val ); } @@ -680,6 +682,7 @@ accesslog_purge( void *ctx, void *arg ) { Modifications mod; struct berval bv[2]; + rs_reinit( &rs, REP_RESULT ); /* update context's entryCSN to reflect oldest CSN */ mod.sml_numvals = 1; mod.sml_values = bv; diff --git a/servers/slapd/overlays/constraint.c b/servers/slapd/overlays/constraint.c index 9027dbb6b9..fcb2830ee8 100644 --- a/servers/slapd/overlays/constraint.c +++ b/servers/slapd/overlays/constraint.c @@ -556,7 +556,6 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op ) Operation nop = *op; slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; slap_callback cb; - SlapReply nrs = { REP_RESULT }; int i; int found = 0; int rc; @@ -640,6 +639,8 @@ constraint_violation( constraint *c, struct berval *bv, Operation *op ) rc = LDAP_OTHER; } else { + SlapReply nrs = { REP_RESULT }; + Debug(LDAP_DEBUG_TRACE, "==> constraint_violation uri filter = %s\n", filterstr.bv_val, 0, 0); diff --git a/servers/slapd/overlays/dynlist.c b/servers/slapd/overlays/dynlist.c index c9a2427e30..67db47817a 100644 --- a/servers/slapd/overlays/dynlist.c +++ b/servers/slapd/overlays/dynlist.c @@ -348,7 +348,6 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli ) Attribute *a, *id = NULL; slap_callback cb; Operation o = *op; - SlapReply r = { REP_SEARCH }; struct berval *url; Entry *e; int opattrs, @@ -564,6 +563,7 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli ) o.o_bd = select_backend( &o.o_req_ndn, 1 ); if ( o.o_bd && o.o_bd->be_search ) { + SlapReply r = { REP_SEARCH }; r.sr_attr_flags = slap_attr_flags( o.ors_attrs ); (void)o.o_bd->be_search( &o, &r ); } diff --git a/servers/slapd/overlays/memberof.c b/servers/slapd/overlays/memberof.c index 1771febb1e..4fa3946973 100644 --- a/servers/slapd/overlays/memberof.c +++ b/servers/slapd/overlays/memberof.c @@ -243,7 +243,6 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci ) memberof_t *mo = (memberof_t *)on->on_bi.bi_private; Operation op2 = *op; - SlapReply rs2 = { REP_RESULT }; slap_callback cb = { 0 }; BackendInfo *bi = op->o_bd->bd_info; AttributeName an[ 2 ]; @@ -276,6 +275,8 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci ) op2.ors_tlimit = SLAP_NO_LIMIT; if ( mci->what & MEMBEROF_IS_GROUP ) { + SlapReply rs2 = { REP_RESULT }; + mc.ad = mo->mo_ad_member; mc.foundit = 0; mc.vals = NULL; @@ -296,6 +297,8 @@ memberof_isGroupOrMember( Operation *op, memberof_cbinfo_t *mci ) } if ( mci->what & MEMBEROF_IS_MEMBER ) { + SlapReply rs2 = { REP_RESULT }; + mc.ad = mo->mo_ad_memberof; mc.foundit = 0; mc.vals = NULL; diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 7efbff133e..6a4af3bc30 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -863,6 +863,7 @@ merge_entry( if ( rc != LDAP_SUCCESS ) { if ( rc == LDAP_ALREADY_EXISTS ) { + rs_reinit( &sreply, REP_RESULT ); slap_entry2mods( e, &modlist, &text, textbuf, textlen ); modlist->sml_op = LDAP_MOD_ADD; op->o_tag = LDAP_REQ_MODIFY; @@ -1788,6 +1789,7 @@ remove_query_data( op->o_req_dn = qi->xdn; op->o_req_ndn = qi->xdn; + rs_reinit( &sreply, REP_RESULT ); if ( qi->del ) { Debug( pcache_debug, "DELETING ENTRY TEMPLATE=%s\n", @@ -2051,7 +2053,6 @@ pcache_remove_entries_from_cache( OperationBuffer opbuf; Operation op2; slap_callback sc = { 0 }; - SlapReply rs = { REP_RESULT }; Filter f = { 0 }; char filtbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE + STRLENOF( "(entryUUID=)" ) ]; AttributeAssertion ava = ATTRIBUTEASSERTION_INIT; @@ -2098,6 +2099,7 @@ pcache_remove_entries_from_cache( for ( s = 0; !BER_BVISNULL( &entryUUIDs[ s ] ); s++ ) { BerVarray vals = NULL; + SlapReply rs = { REP_RESULT }; op->ors_filterstr.bv_len = snprintf( filtbuf, sizeof( filtbuf ), "(entryUUID=%s)", entryUUIDs[ s ].bv_val ); diff --git a/servers/slapd/overlays/refint.c b/servers/slapd/overlays/refint.c index 063bd5c344..cc5335b6a2 100644 --- a/servers/slapd/overlays/refint.c +++ b/servers/slapd/overlays/refint.c @@ -521,11 +521,11 @@ refint_search_cb( static int refint_repair( Operation *op, - SlapReply *rs, refint_data *id, refint_q *rq ) { dependent_data *dp; + SlapReply rs = {REP_RESULT}; int rc; op->o_callback->sc_response = refint_search_cb; @@ -535,7 +535,7 @@ refint_repair( op->o_ndn = op->o_bd->be_rootndn; /* search */ - rc = op->o_bd->be_search( op, rs ); + rc = op->o_bd->be_search( op, &rs ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -695,7 +695,6 @@ refint_qtask( void *ctx, void *arg ) Connection conn = {0}; OperationBuffer opbuf; Operation *op; - SlapReply rs = {REP_RESULT}; slap_callback cb = { NULL, NULL, NULL, NULL }; Filter ftop, *fptr; refint_q *rq; @@ -772,7 +771,7 @@ refint_qtask( void *ctx, void *arg ) if ( rq->db != NULL ) { op->o_bd = rq->db; - refint_repair( op, &rs, id, rq ); + refint_repair( op, id, rq ); } else { BackendDB *be; @@ -785,7 +784,7 @@ refint_qtask( void *ctx, void *arg ) if ( be->be_search && be->be_modify ) { op->o_bd = be; - refint_repair( op, &rs, id, rq ); + refint_repair( op, id, rq ); } } } diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 0dc00c9427..6f8fb7f338 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -735,6 +735,7 @@ again: /* If we didn't find an exact match, then try for <= */ if ( findcsn_retry ) { findcsn_retry = 0; + rs_reinit( &frs, REP_RESULT ); goto again; } rc = LDAP_NO_SUCH_OBJECT; @@ -1423,7 +1424,7 @@ syncprov_checkpoint( Operation *op, slap_overinst *on ) syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private; Modifications mod; Operation opm; - SlapReply rsm = { 0 }; + SlapReply rsm = {REP_RESULT}; slap_callback cb = {0}; BackendDB be; BackendInfo *bi; @@ -1468,6 +1469,7 @@ syncprov_checkpoint( Operation *op, slap_overinst *on ) char txtbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof txtbuf; Entry *e = slap_create_context_csn_entry( opm.o_bd, NULL ); + rs_reinit( &rsm, REP_RESULT ); slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen); opm.ora_e = e; opm.o_bd->be_add( &opm, &rsm ); @@ -1679,7 +1681,6 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, if ( mmods ) { Operation fop; - SlapReply frs = { REP_RESULT }; int rc; Filter mf, af; AttributeAssertion eq = ATTRIBUTEASSERTION_INIT; @@ -1710,11 +1711,11 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl, for ( i=ndel; ibe_search( &fop, &frs ); /* If entry was not found, add to delete list */ diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 0036638ff4..4d5174fd67 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -2789,9 +2789,7 @@ syncrepl_del_nonpresent( { Backend* be = op->o_bd; slap_callback cb = { NULL }; - SlapReply rs_search = {REP_RESULT}; SlapReply rs_delete = {REP_RESULT}; - SlapReply rs_modify = {REP_RESULT}; struct nonpresent_entry *np_list, *np_prev; int rc; AttributeName an[2]; @@ -2838,6 +2836,8 @@ syncrepl_del_nonpresent( si->si_refreshDelete |= NP_DELETE_ONE; for (i=0; uuids[i].bv_val; i++) { + SlapReply rs_search = {REP_RESULT}; + op->ors_slimit = 1; uf.f_av_value = uuids[i]; filter2bv_x( op, op->ors_filter, &op->ors_filterstr ); @@ -2849,6 +2849,7 @@ syncrepl_del_nonpresent( Filter *cf, *of; Filter mmf[2]; AttributeAssertion mmaa; + SlapReply rs_search = {REP_RESULT}; memset( &an[0], 0, 2 * sizeof( AttributeName ) ); an[0].an_name = slap_schema.si_ad_entryUUID->ad_cname; @@ -2933,6 +2934,7 @@ syncrepl_del_nonpresent( si->si_ridtxt, op->o_req_dn.bv_val, rc ); if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) { + SlapReply rs_modify = {REP_RESULT}; Modifications mod1, mod2; mod1.sml_op = LDAP_MOD_REPLACE; mod1.sml_flags = 0;