ITS#10067 Account for mods being optional

This commit is contained in:
Ondřej Kuzník 2023-06-19 15:41:09 +01:00 committed by Quanah Gibson-Mount
parent 2414e4a96b
commit 5ae48d085f
2 changed files with 9 additions and 24 deletions

View file

@ -67,21 +67,15 @@ asyncmeta_back_modify_start(Operation *op,
for ( i = 0, ml = op->orm_modlist; ml; i++ ,ml = ml->sml_next )
;
if (i > 0) {
mods = op->o_tmpalloc( sizeof( LDAPMod )*i, op->o_tmpmemctx );
}
if ( mods == NULL ) {
rs->sr_err = LDAP_OTHER;
retcode = META_SEARCH_ERR;
goto doreturn;
}
modv = ( LDAPMod ** )op->o_tmpalloc( ( i + 1 )*sizeof( LDAPMod * ), op->o_tmpmemctx );
modv = op->o_tmpalloc( ( i + 1 )*sizeof( LDAPMod * ) + i*sizeof( LDAPMod ),
op->o_tmpmemctx );
if ( modv == NULL ) {
rs->sr_err = LDAP_OTHER;
retcode = META_SEARCH_ERR;
goto doreturn;
}
mods = (LDAPMod *)&modv[ i + 1 ];
isupdate = be_shadow_update( op );
for ( i = 0, ml = op->orm_modlist; ml; ml = ml->sml_next ) {
@ -224,6 +218,8 @@ done:
op->o_tmpfree( mdn.bv_val, op->o_tmpmemctx );
}
op->o_tmpfree( modv, op->o_tmpmemctx );
doreturn:;
Debug( LDAP_DEBUG_TRACE, "%s <<< asyncmeta_back_modify_start[%p]=%d\n", op->o_log_prefix, msc, candidates[candidate].sr_msgid );
return retcode;

View file

@ -74,18 +74,8 @@ meta_back_modify( Operation *op, SlapReply *rs )
for ( i = 0, ml = op->orm_modlist; ml; i++ ,ml = ml->sml_next )
;
mods = ch_malloc( sizeof( LDAPMod )*i );
if ( mods == NULL ) {
rs->sr_err = LDAP_OTHER;
send_ldap_result( op, rs );
goto cleanup;
}
modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) );
if ( modv == NULL ) {
rs->sr_err = LDAP_OTHER;
send_ldap_result( op, rs );
goto cleanup;
}
modv = ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) + i*sizeof( LDAPMod ) );
mods = (LDAPMod *)&modv[ i + 1 ];
dc.ctx = "modifyAttrDN";
isupdate = be_shadow_update( op );
@ -206,11 +196,10 @@ cleanup:;
}
if ( modv != NULL ) {
for ( i = 0; modv[ i ]; i++ ) {
free( modv[ i ]->mod_bvalues );
ch_free( modv[ i ]->mod_bvalues );
}
}
free( mods );
free( modv );
ch_free( modv );
if ( mc ) {
meta_back_release_conn( mi, mc );