]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9160 OOM handling in contrib
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 30 Jan 2020 08:55:59 +0000 (08:55 +0000)
committerOndřej Kuzník <ondra@mistotebe.net>
Fri, 7 Feb 2020 09:46:52 +0000 (09:46 +0000)
contrib/slapd-modules/allowed/allowed.c
contrib/slapd-modules/authzid/authzid.c
contrib/slapd-modules/samba4/rdnval.c
contrib/slapd-modules/samba4/vernum.c

index a625fc5aaab174586fade42e6937fb5b8a0da659..42af5454496635cc87e1a7a8ad95be267eb76fe5 100644 (file)
@@ -277,10 +277,10 @@ aa_operational( Operation *op, SlapReply *rs )
                        /* just count */ ;
        
                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 ) {
-                       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++ ) {
@@ -310,7 +310,6 @@ aa_operational( Operation *op, SlapReply *rs )
                ch_free( atp );
 
                if ( ( got & GOT_A ) && ja > 0 ) {
-                       BER_BVZERO( &bv_allowed[ ja ] );
                        *ap = attr_alloc( ad_allowedAttributes );
                        (*ap)->a_vals = bv_allowed;
                        (*ap)->a_nvals = bv_allowed;
@@ -319,7 +318,6 @@ aa_operational( Operation *op, SlapReply *rs )
                }
 
                if ( ( got & GOT_AE ) && je > 0 ) {
-                       BER_BVZERO( &bv_effective[ je ] );
                        *ap = attr_alloc( ad_allowedAttributesEffective );
                        (*ap)->a_vals = bv_effective;
                        (*ap)->a_nvals = bv_effective;
@@ -348,10 +346,10 @@ do_oc:;
                }
 
                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 ) {
-                       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 ) ) {
@@ -398,7 +396,6 @@ done_ce:;
                }
 
                if ( ( got & GOT_C ) && ja > 0 ) {
-                       BER_BVZERO( &bv_allowed[ ja ] );
                        *ap = attr_alloc( ad_allowedChildClasses );
                        (*ap)->a_vals = bv_allowed;
                        (*ap)->a_nvals = bv_allowed;
@@ -407,7 +404,6 @@ done_ce:;
                }
 
                if ( ( got & GOT_CE ) && je > 0 ) {
-                       BER_BVZERO( &bv_effective[ je ] );
                        *ap = attr_alloc( ad_allowedChildClassesEffective );
                        (*ap)->a_vals = bv_effective;
                        (*ap)->a_nvals = bv_effective;
index 2c2b38f6f5f9933de94535b16362665a1ebfe65e..4cb087366d31d8ebedde44d261ae51030001b202 100644 (file)
@@ -117,7 +117,7 @@ authzid_conn_insert( Connection *c, char flag )
                return -1;
        }
 
-       ac = SLAP_MALLOC( sizeof( authzid_conn_t ) );
+       ac = ch_malloc( sizeof( authzid_conn_t ) );
        ac->conn = c;
        ac->refcnt = 0;
        ac->authzid_flag = flag;
@@ -143,7 +143,7 @@ authzid_conn_remove( Connection *c )
        ldap_pvt_thread_mutex_unlock( &authzid_mutex );
 
        assert( tmp == ac );
-       SLAP_FREE( ac );
+       ch_free( ac );
 
        return 0;
 }
index 68e29b68a23b3c269cc669c27512f745f3ddfd7d..905c7c4fd1da5c1918758582355c43b345545b70 100644 (file)
@@ -223,8 +223,8 @@ rdnval_rdn2vals(
 
        /* NOTE: we assume rdn and nrdn contain the same AVAs! */
 
-       *valsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
-       *nvalsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
+       *valsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
+       *nvalsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
 
        /* Add new attribute values to the entry */
        for ( i = 0; rdn[ i ]; i++ ) {
@@ -354,7 +354,7 @@ rdnval_op_rename( Operation *op, SlapReply *rs )
                send_ldap_result( op, rs );
        }
 
-       ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
+       ml = ch_calloc( sizeof( Modifications ), 1 );
        ml->sml_values = vals;
        ml->sml_nvalues = nvals;
 
index 17b1933a6a250dd99d48f39bf522bc43286e7577..f4c0a95323e9464bc2ee4c614875369c9fe8c260 100644 (file)
@@ -121,8 +121,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
        /* ITS#6561 */
 #ifdef SLAP_MOD_ADD_IF_NOT_PRESENT
        /* the initial value is only added if the vernum attr is not present */
-       ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
-       ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 );
+       ml = ch_calloc( sizeof( Modifications ), 1 );
+       ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
        value_add_one( &ml->sml_values, &val_init );
        ml->sml_nvalues = NULL;
        ml->sml_numvals = 1;
@@ -136,8 +136,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
 #endif /* SLAP_MOD_ADD_IF_NOT_PRESENT */
 
        /* this increments by 1 the vernum attr */
-       ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
-       ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 );
+       ml = ch_calloc( sizeof( Modifications ), 1 );
+       ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
        value_add_one( &ml->sml_values, &val );
        ml->sml_nvalues = NULL;
        ml->sml_numvals = 1;