From: Luke Howard Date: Mon, 1 Aug 2005 02:16:02 +0000 (+0000) Subject: slap_mods2entry() should not zero pointers into the modifications X-Git-Tag: OPENLDAP_AC_BP~126 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=71d76fbebaf7a1e4518936800d910d4695d60cd8;p=openldap slap_mods2entry() should not zero pointers into the modifications list because checking is performed on these, rather than the entry. slap_mods_free() now takes an extra argument indicating whether to free the values or not. --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index d0fcef1dbe..1c23986c61 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -40,7 +40,7 @@ do_add( Operation *op, SlapReply *rs ) struct berval dn = BER_BVNULL; ber_len_t len; ber_tag_t tag; - Modifications *modlist = NULL; + Modifications *modlist = NULL, *next; Modifications **modtail = &modlist; Modifications tmp; char textbuf[ SLAP_TEXT_BUFLEN ]; @@ -195,8 +195,9 @@ done:; slap_graduate_commit_csn( op ); if ( modlist != NULL ) { - slap_mods_free( modlist ); + slap_mods_free( modlist, 0 ); } + if ( op->ora_e != NULL ) { entry_free( op->ora_e ); } @@ -450,8 +451,6 @@ slap_mods2entry( } else { AC_MEMCPY( &attr->a_vals[i], mods->sml_values, sizeof( struct berval ) * j ); - ch_free( mods->sml_values ); - mods->sml_values = NULL; } if( mods->sml_nvalues ) { @@ -465,8 +464,6 @@ slap_mods2entry( } else { AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues, sizeof( struct berval ) * j ); - ch_free( mods->sml_nvalues ); - mods->sml_nvalues = NULL; } } else { attr->a_nvals = attr->a_vals; @@ -520,7 +517,6 @@ slap_mods2entry( /* move ad to attr structure */ attr->a_desc = mods->sml_desc; - if ( !dup ) mods->sml_desc = NULL; /* move values to attr structure */ /* should check for duplicates */ @@ -534,7 +530,6 @@ slap_mods2entry( BER_BVZERO( &attr->a_vals[i] ); } else { attr->a_vals = mods->sml_values; - mods->sml_values = NULL; } if ( mods->sml_nvalues ) { @@ -548,7 +543,6 @@ slap_mods2entry( BER_BVZERO( &attr->a_nvals[i] ); } else { attr->a_nvals = mods->sml_nvalues; - mods->sml_nvalues = NULL; } } else { attr->a_nvals = attr->a_vals; diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 458d17e3d5..0a6b8d7fd2 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -874,7 +874,7 @@ done: if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val ); free( mod ); } - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } /* LDAP v3 Support */ diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index eb81387ba8..c8ef1e5446 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -529,7 +529,7 @@ return_results: tmp = mod->sml_next; free( mod ); } - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } /* LDAP v3 Support */ diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 12ac2da1fb..becbd71310 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -204,7 +204,7 @@ cleanup: op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist ); + if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist, 1 ); return rs->sr_err; } diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 7ebba1b3e6..4be7849f2d 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -432,14 +432,16 @@ slap_mod_free( void slap_mods_free( - Modifications *ml ) + Modifications *ml, + int freevals ) { Modifications *next; for ( ; ml != NULL; ml = next ) { next = ml->sml_next; - slap_mod_free( &ml->sml_mod, 0 ); + if ( freevals ) + slap_mod_free( &ml->sml_mod, 0 ); free( ml ); } } diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 5d2d1247e2..14a3c25bf6 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -186,7 +186,7 @@ merge_entry( op->o_tag = LDAP_REQ_MODIFY; op->orm_modlist = modlist; op->o_bd->be_modify( op, &sreply ); - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); } else if ( rc == LDAP_REFERRAL || rc == LDAP_NO_SUCH_OBJECT ) { syncrepl_add_glue( op, e ); diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index bbb208161a..64daabd22c 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -919,7 +919,7 @@ locked: op2.o_ndn = op->o_bd->be_rootndn; op2.o_bd->bd_info = (BackendInfo *)on->on_info; rc = op->o_bd->be_modify( &op2, &r2 ); - slap_mods_free( mod ); + slap_mods_free( mod, 1 ); } if ( ppb->send_ctrl ) { diff --git a/servers/slapd/overlays/refint.c b/servers/slapd/overlays/refint.c index b6e175fa72..41e1cbc9cf 100644 --- a/servers/slapd/overlays/refint.c +++ b/servers/slapd/overlays/refint.c @@ -653,7 +653,7 @@ done: for(dp = dd.mods; dp; dp = dd.mods) { dd.mods = dp->next; ch_free(dp->dn.bv_val); - slap_mods_free(dp->mm); + slap_mods_free(dp->mm, 1); } dd.mods = NULL; diff --git a/servers/slapd/overlays/translucent.c b/servers/slapd/overlays/translucent.c index 72b57e76d5..85724d5f50 100644 --- a/servers/slapd/overlays/translucent.c +++ b/servers/slapd/overlays/translucent.c @@ -290,7 +290,7 @@ static int translucent_modify(Operation *op, SlapReply *rs) { mm = m; m = m->sml_next; mm->sml_next = NULL; /* hack */ - slap_mods_free(mm); + slap_mods_free(mm, 1); if(m) continue; } m->sml_op = LDAP_MOD_ADD; diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index 82acabab4a..738d9add84 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -243,7 +243,7 @@ int passwd_extop( op->o_tag = LDAP_REQ_EXTENDED; op->o_callback = sc; } - slap_mods_free( qpw->rs_mods ); + slap_mods_free( qpw->rs_mods, 1 ); if ( rsp ) { free( qpw->rs_new.bv_val ); } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 77eea618ac..660dbdcd51 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1006,7 +1006,7 @@ LDAP_SLAPD_F( int ) modify_increment_values( Entry *e, const char **text, char *textbuf, size_t textlen ); LDAP_SLAPD_F( void ) slap_mod_free( Modification *mod, int freeit ); -LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods ); +LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods, int freevals ); LDAP_SLAPD_F( void ) slap_modlist_free( LDAPModList *ml ); /* diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 385e912c6c..e92780132f 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -439,7 +439,7 @@ slap_auxprop_store( } } } - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); return rc != LDAP_SUCCESS ? SASL_FAIL : SASL_OK; } #endif /* SASL_VERSION_FULL >= 2.1.16 */ diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index d57f3fc651..b5f1c48b5d 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -344,10 +344,10 @@ slapi_int_connection_done_pb( Slapi_PBlock *pb ) } break; case LDAP_REQ_ADD: - slap_mods_free( op->ora_modlist ); + slap_mods_free( op->ora_modlist, 1 ); break; case LDAP_REQ_MODIFY: - slap_mods_free( op->orm_modlist ); + slap_mods_free( op->orm_modlist, 1 ); break; case LDAP_REQ_SEARCH: if ( op->ors_attrs != NULL ) { @@ -498,7 +498,7 @@ cleanup: } if ( entry_orig != NULL ) { pb->pb_op->ora_e = entry_orig; - slap_mods_free( pb->pb_op->ora_modlist ); + slap_mods_free( pb->pb_op->ora_modlist, 1 ); pb->pb_op->ora_modlist = NULL; } diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 4617359318..25f82e872c 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -2730,7 +2730,7 @@ LDAPMod **slapi_int_modifications2ldapmods( mods[i] = NULL; - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); *pmodlist = NULL; return mods; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 79e17094fb..087a7cf46f 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -629,7 +629,7 @@ do_syncrep2( } ldap_controls_free( rctrls ); if ( modlist ) { - slap_mods_free( modlist ); + slap_mods_free( modlist, 1 ); } if ( rc_efree && entry ) { entry_free( entry );