ITS#9160 OOM handling in contrib

This commit is contained in:
Ondřej Kuzník 2020-01-30 08:55:59 +00:00
parent af5ed7c6e2
commit 28828e1b40
4 changed files with 13 additions and 17 deletions

View file

@ -277,10 +277,10 @@ aa_operational( Operation *op, SlapReply *rs )
/* just count */ ; /* just count */ ;
if ( got & GOT_A ) { if ( got & GOT_A ) {
bv_allowed = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) ); bv_allowed = ch_calloc( i + 1, sizeof( struct berval ) );
} }
if ( got & GOT_AE ) { if ( got & GOT_AE ) {
bv_effective = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) ); bv_effective = ch_calloc( i + 1, sizeof( struct berval ) );
} }
for ( i = 0, ja = 0, je = 0; atp[ i ] != NULL; i++ ) { for ( i = 0, ja = 0, je = 0; atp[ i ] != NULL; i++ ) {
@ -310,7 +310,6 @@ aa_operational( Operation *op, SlapReply *rs )
ch_free( atp ); ch_free( atp );
if ( ( got & GOT_A ) && ja > 0 ) { if ( ( got & GOT_A ) && ja > 0 ) {
BER_BVZERO( &bv_allowed[ ja ] );
*ap = attr_alloc( ad_allowedAttributes ); *ap = attr_alloc( ad_allowedAttributes );
(*ap)->a_vals = bv_allowed; (*ap)->a_vals = bv_allowed;
(*ap)->a_nvals = bv_allowed; (*ap)->a_nvals = bv_allowed;
@ -319,7 +318,6 @@ aa_operational( Operation *op, SlapReply *rs )
} }
if ( ( got & GOT_AE ) && je > 0 ) { if ( ( got & GOT_AE ) && je > 0 ) {
BER_BVZERO( &bv_effective[ je ] );
*ap = attr_alloc( ad_allowedAttributesEffective ); *ap = attr_alloc( ad_allowedAttributesEffective );
(*ap)->a_vals = bv_effective; (*ap)->a_vals = bv_effective;
(*ap)->a_nvals = bv_effective; (*ap)->a_nvals = bv_effective;
@ -348,10 +346,10 @@ do_oc:;
} }
if ( got & GOT_C ) { if ( got & GOT_C ) {
bv_allowed = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) ); bv_allowed = ch_calloc( i + 1, sizeof( struct berval ) );
} }
if ( got & GOT_CE ) { if ( got & GOT_CE ) {
bv_effective = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) ); bv_effective = ch_calloc( i + 1, sizeof( struct berval ) );
} }
for ( oc_start( &oc ); oc != NULL; oc_next( &oc ) ) { for ( oc_start( &oc ); oc != NULL; oc_next( &oc ) ) {
@ -398,7 +396,6 @@ done_ce:;
} }
if ( ( got & GOT_C ) && ja > 0 ) { if ( ( got & GOT_C ) && ja > 0 ) {
BER_BVZERO( &bv_allowed[ ja ] );
*ap = attr_alloc( ad_allowedChildClasses ); *ap = attr_alloc( ad_allowedChildClasses );
(*ap)->a_vals = bv_allowed; (*ap)->a_vals = bv_allowed;
(*ap)->a_nvals = bv_allowed; (*ap)->a_nvals = bv_allowed;
@ -407,7 +404,6 @@ done_ce:;
} }
if ( ( got & GOT_CE ) && je > 0 ) { if ( ( got & GOT_CE ) && je > 0 ) {
BER_BVZERO( &bv_effective[ je ] );
*ap = attr_alloc( ad_allowedChildClassesEffective ); *ap = attr_alloc( ad_allowedChildClassesEffective );
(*ap)->a_vals = bv_effective; (*ap)->a_vals = bv_effective;
(*ap)->a_nvals = bv_effective; (*ap)->a_nvals = bv_effective;

View file

@ -117,7 +117,7 @@ authzid_conn_insert( Connection *c, char flag )
return -1; return -1;
} }
ac = SLAP_MALLOC( sizeof( authzid_conn_t ) ); ac = ch_malloc( sizeof( authzid_conn_t ) );
ac->conn = c; ac->conn = c;
ac->refcnt = 0; ac->refcnt = 0;
ac->authzid_flag = flag; ac->authzid_flag = flag;
@ -143,7 +143,7 @@ authzid_conn_remove( Connection *c )
ldap_pvt_thread_mutex_unlock( &authzid_mutex ); ldap_pvt_thread_mutex_unlock( &authzid_mutex );
assert( tmp == ac ); assert( tmp == ac );
SLAP_FREE( ac ); ch_free( ac );
return 0; return 0;
} }

View file

@ -223,8 +223,8 @@ rdnval_rdn2vals(
/* NOTE: we assume rdn and nrdn contain the same AVAs! */ /* NOTE: we assume rdn and nrdn contain the same AVAs! */
*valsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 ); *valsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
*nvalsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 ); *nvalsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
/* Add new attribute values to the entry */ /* Add new attribute values to the entry */
for ( i = 0; rdn[ i ]; i++ ) { for ( i = 0; rdn[ i ]; i++ ) {
@ -354,7 +354,7 @@ rdnval_op_rename( Operation *op, SlapReply *rs )
send_ldap_result( op, rs ); send_ldap_result( op, rs );
} }
ml = SLAP_CALLOC( sizeof( Modifications ), 1 ); ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = vals; ml->sml_values = vals;
ml->sml_nvalues = nvals; ml->sml_nvalues = nvals;

View file

@ -121,8 +121,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
/* ITS#6561 */ /* ITS#6561 */
#ifdef SLAP_MOD_ADD_IF_NOT_PRESENT #ifdef SLAP_MOD_ADD_IF_NOT_PRESENT
/* the initial value is only added if the vernum attr is not present */ /* the initial value is only added if the vernum attr is not present */
ml = SLAP_CALLOC( sizeof( Modifications ), 1 ); ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 ); ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
value_add_one( &ml->sml_values, &val_init ); value_add_one( &ml->sml_values, &val_init );
ml->sml_nvalues = NULL; ml->sml_nvalues = NULL;
ml->sml_numvals = 1; ml->sml_numvals = 1;
@ -136,8 +136,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
#endif /* SLAP_MOD_ADD_IF_NOT_PRESENT */ #endif /* SLAP_MOD_ADD_IF_NOT_PRESENT */
/* this increments by 1 the vernum attr */ /* this increments by 1 the vernum attr */
ml = SLAP_CALLOC( sizeof( Modifications ), 1 ); ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 ); ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
value_add_one( &ml->sml_values, &val ); value_add_one( &ml->sml_values, &val );
ml->sml_nvalues = NULL; ml->sml_nvalues = NULL;
ml->sml_numvals = 1; ml->sml_numvals = 1;