From: Kurt Zeilenga Date: Wed, 24 May 2000 22:55:16 +0000 (+0000) Subject: SLAPD_SCHEMA_NOT_COMPAT: Fix memory stomping X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2873 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c96f12ee496be44c3ed55f6770f5f29bae967f4a;p=openldap SLAPD_SCHEMA_NOT_COMPAT: Fix memory stomping --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 6a3a9869d9..1baf074841 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -657,7 +657,7 @@ Attribute *backend_operational( { Attribute *a = ch_malloc( sizeof( Attribute ) ); #ifdef SLAPD_SCHEMA_NOT_COMPAT - a->a_desc = slap_schema.si_ad_subschemaSubentry; + a->a_desc = ad_dup( slap_schema.si_ad_subschemaSubentry ); #else a->a_type = ch_strdup("subschemasubentry"); a->a_syntax = SYNTAX_DN | SYNTAX_CIS; @@ -665,9 +665,7 @@ Attribute *backend_operational( /* Should be backend specific */ a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) ); - a->a_vals[0] = ch_malloc( sizeof( struct berval ) ); - a->a_vals[0]->bv_val = ch_strdup( SLAPD_SCHEMA_DN ); - a->a_vals[0]->bv_len = sizeof( SLAPD_SCHEMA_DN ) - 1; + a->a_vals[0] = ber_bvstrdup( SLAPD_SCHEMA_DN ); a->a_vals[1] = NULL; a->a_next = NULL; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 0921238ad6..394956569d 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -433,7 +433,7 @@ int slap_mods_opattrs( if( op->o_tag == LDAP_REQ_ADD ) { mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = slap_schema.si_ad_creatorsName; + mod->sml_desc = ad_dup( slap_schema.si_ad_creatorsName ); mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( &name ); mod->sml_bvalues[1] = NULL; @@ -443,7 +443,7 @@ int slap_mods_opattrs( mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) ); mod->sml_op = mop; - mod->sml_desc = slap_schema.si_ad_createTimestamp; + mod->sml_desc = ad_dup( slap_schema.si_ad_createTimestamp ); mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) ); mod->sml_bvalues[0] = ber_bvdup( ×tamp ); mod->sml_bvalues[1] = NULL; diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 91a9945b3d..0231eb6c90 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -129,12 +129,12 @@ struct berval **get_entry_referrals( unsigned i, j; #ifdef SLAPD_SCHEMA_NOT_COMPAT - AttributeDescription *ref = slap_schema.si_ad_ref; + AttributeDescription *ad_ref = slap_schema.si_ad_ref; #else - static const char *ref = "ref"; + static const char *ad_ref = "ref"; #endif - attr = attr_find( e->e_attrs, ref ); + attr = attr_find( e->e_attrs, ad_ref ); if( attr == NULL ) return NULL; @@ -629,15 +629,15 @@ send_search_entry( int opattrs; #ifdef SLAPD_SCHEMA_NOT_COMPAT - AttributeDescription *entry = slap_schema.si_ad_entry; + AttributeDescription *ad_entry = slap_schema.si_ad_entry; #else - static const char *entry = "entry"; + static const char *ad_entry = "entry"; #endif Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: \"%s\"\n", e->e_dn, 0, 0 ); if ( ! access_allowed( be, conn, op, e, - entry, NULL, ACL_READ ) ) + ad_entry, NULL, ACL_READ ) ) { Debug( LDAP_DEBUG_ACL, "acl: access to entry not allowed\n", 0, 0, 0 ); @@ -901,17 +901,17 @@ send_search_reference( int bytes; #ifdef SLAPD_SCHEMA_NOT_COMPAT - AttributeDescription *ref = slap_schema.si_ad_ref; - AttributeDescription *entry = slap_schema.si_ad_entry; + AttributeDescription *ad_ref = slap_schema.si_ad_ref; + AttributeDescription *ad_entry = slap_schema.si_ad_entry; #else - static const char *ref = "ref"; - static const char *entry = "entry"; + static const char *ad_ref = "ref"; + static const char *ad_entry = "entry"; #endif Debug( LDAP_DEBUG_TRACE, "=> send_search_reference (%s)\n", e->e_dn, 0, 0 ); if ( ! access_allowed( be, conn, op, e, - entry, NULL, ACL_READ ) ) + ad_entry, NULL, ACL_READ ) ) { Debug( LDAP_DEBUG_ACL, "send_search_reference: access to entry not allowed\n", @@ -920,7 +920,7 @@ send_search_reference( } if ( ! access_allowed( be, conn, op, e, - ref, NULL, ACL_READ ) ) + ad_ref, NULL, ACL_READ ) ) { Debug( LDAP_DEBUG_ACL, "send_search_reference: access to reference not allowed\n",