mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-25 00:59:45 -05:00
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.
This commit is contained in:
parent
f6f6ecb4f3
commit
71d76fbeba
15 changed files with 22 additions and 26 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ return_results:
|
|||
tmp = mod->sml_next;
|
||||
free( mod );
|
||||
}
|
||||
slap_mods_free( mod );
|
||||
slap_mods_free( mod, 1 );
|
||||
}
|
||||
|
||||
/* LDAP v3 Support */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2730,7 +2730,7 @@ LDAPMod **slapi_int_modifications2ldapmods(
|
|||
|
||||
mods[i] = NULL;
|
||||
|
||||
slap_mods_free( modlist );
|
||||
slap_mods_free( modlist, 1 );
|
||||
*pmodlist = NULL;
|
||||
|
||||
return mods;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue