From: Howard Chu Date: Sat, 29 Dec 2001 15:01:10 +0000 (+0000) Subject: Change struct berval * to struct berval in various structures X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~413 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=185ff129b59340698f32e9e8ecf26c21fb58b446;p=openldap Change struct berval * to struct berval in various structures --- diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index da6a2e3355..0864a9b9c5 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -21,7 +21,7 @@ ava_free( int freeit ) { - ber_bvfree( ava->aa_value ); + free( ava->aa_value.bv_val ); if ( freeit ) { ch_free( (char *) ava ); } @@ -36,7 +36,7 @@ get_ava( ) { int rc; - struct berval type, value, *nvalue; + struct berval type, value; AttributeAssertion *aa; rc = ber_scanf( ber, "{oo}", &type, &value ); @@ -54,7 +54,7 @@ get_ava( aa = ch_malloc( sizeof( AttributeAssertion ) ); aa->aa_desc = NULL; - aa->aa_value = NULL; + aa->aa_value.bv_val = NULL; rc = slap_bv2ad( &type, &aa->aa_desc, text ); ch_free( type.bv_val ); @@ -65,7 +65,7 @@ get_ava( return rc; } - rc = value_normalize( aa->aa_desc, usage, &value, &nvalue, text ); + rc = value_normalize( aa->aa_desc, usage, &value, &aa->aa_value, text ); ch_free( value.bv_val ); if( rc != LDAP_SUCCESS ) { @@ -73,9 +73,7 @@ get_ava( return rc; } - aa->aa_value = nvalue; *ava = aa; return LDAP_SUCCESS; } - diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index b339141ac6..a9a67d463e 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -86,7 +86,7 @@ bdb_compare( } if ( ! access_allowed( be, conn, op, e, - ava->aa_desc, ava->aa_value, ACL_COMPARE ) ) + ava->aa_desc, &ava->aa_value, ACL_COMPARE ) ) { rc = LDAP_INSUFFICIENT_ACCESS; goto return_results; @@ -100,7 +100,7 @@ bdb_compare( { rc = LDAP_COMPARE_FALSE; - if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { + if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index f1fe17c85f..da857b9e0a 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -263,7 +263,7 @@ equality_candidates( int rc; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates\n", 0, 0, 0 ); @@ -299,7 +299,7 @@ equality_candidates( ava->aa_desc->ad_type->sat_syntax, mr, &prefix, - ava->aa_value, + &ava->aa_value, &keys ); if( rc != LDAP_SUCCESS ) { @@ -316,8 +316,8 @@ equality_candidates( return 0; } - for ( i= 0; keys[i] != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, keys[i], tmp ); + for ( i= 0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, @@ -340,7 +340,7 @@ equality_candidates( break; } - ber_bvecfree( keys ); + bvarray_free( keys ); Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates id=%ld, first=%ld, last=%ld\n", @@ -363,7 +363,7 @@ approx_candidates( int rc; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates\n", 0, 0, 0 ); @@ -404,7 +404,7 @@ approx_candidates( ava->aa_desc->ad_type->sat_syntax, mr, &prefix, - ava->aa_value, + &ava->aa_value, &keys ); if( rc != LDAP_SUCCESS ) { @@ -421,8 +421,8 @@ approx_candidates( return 0; } - for ( i= 0; keys[i] != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, keys[i], tmp ); + for ( i= 0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates key read failed (%d)\n", @@ -443,7 +443,7 @@ approx_candidates( break; } - ber_bvecfree( keys ); + bvarray_free( keys ); Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], @@ -465,7 +465,7 @@ substring_candidates( int rc; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates\n", 0, 0, 0 ); @@ -520,8 +520,8 @@ substring_candidates( return 0; } - for ( i= 0; keys[i] != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, keys[i], tmp ); + for ( i= 0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates key read failed (%d)\n", @@ -542,7 +542,7 @@ substring_candidates( break; } - ber_bvecfree( keys ); + bvarray_free( keys ); Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index 8daaf8fce2..b13e2bcab7 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -151,7 +151,7 @@ static int indexer( const char *text; DB *db; AttributeDescription *ad = NULL; - struct berval **keys; + struct berval *keys; assert( mask ); @@ -188,14 +188,14 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - rc = bdb_key_change( be, db, txn, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_change( be, db, txn, &keys[i], id, op ); if( rc ) { - ber_bvecfree( keys ); + bvarray_free( keys ); goto done; } } - ber_bvecfree( keys ); + bvarray_free( keys ); } rc = LDAP_SUCCESS; } @@ -209,14 +209,14 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - rc = bdb_key_change( be, db, txn, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + rc = bdb_key_change( be, db, txn, &keys[i], id, op ); if( rc ) { - ber_bvecfree( keys ); + bvarray_free( keys ); goto done; } } - ber_bvecfree( keys ); + bvarray_free( keys ); } rc = LDAP_SUCCESS; @@ -231,14 +231,14 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - bdb_key_change( be, db, txn, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + bdb_key_change( be, db, txn, &keys[i], id, op ); if( rc ) { - ber_bvecfree( keys ); + bvarray_free( keys ); goto done; } } - ber_bvecfree( keys ); + bvarray_free( keys ); } rc = LDAP_SUCCESS; diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index a22713c755..74ce8aed1e 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -372,7 +372,7 @@ add_values( int rc; int j; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -386,15 +386,15 @@ add_values( int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { - ber_bvfree( asserted ); + free( asserted.bv_val ); return LDAP_TYPE_OR_VALUE_EXISTS; } } - ber_bvfree( asserted ); + free( asserted.bv_val ); } } @@ -447,7 +447,7 @@ delete_values( int rc; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -462,7 +462,7 @@ delete_values( int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { continue; @@ -481,7 +481,7 @@ delete_values( break; } - ber_bvfree( asserted ); + free( asserted.bv_val ); /* looked through them all w/o finding it */ if ( ! found ) { diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index df25630b8c..9192753e22 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -532,22 +532,22 @@ static int search_candidates( */ if (oc_filter(filter)) { if( !manageDSAit ) { /* match referrals */ - static struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" }; + struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" }; rf.f_choice = LDAP_FILTER_EQUALITY; rf.f_ava = &aa_ref; rf.f_av_desc = slap_schema.si_ad_objectClass; - rf.f_av_value = &bv_ref; + rf.f_av_value = bv_ref; rf.f_next = xf.f_or; xf.f_or = &rf; } #ifdef BDB_ALIASES if( deref & LDAP_DEREF_SEARCHING ) { /* match aliases */ - static struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" }; + struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" }; af.f_choice = LDAP_FILTER_EQUALITY; af.f_ava = &aa_alias; af.f_av_desc = slap_schema.si_ad_objectClass; - af.f_av_value = &bv_alias; + af.f_av_value = bv_alias; af.f_next = xf.f_or; xf.f_or = ⁡ } diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 27e63dcfb8..9d9fa97470 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -105,7 +105,7 @@ ldap_back_compare( if (mapped_oc == NULL) return( -1 ); - mapped_at = ldap_back_map(&li->at_map, ava->aa_value->bv_val, 0); + mapped_at = ldap_back_map(&li->at_map, ava->aa_value.bv_val, 0); if (mapped_at == NULL) return( -1 ); diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index d35bce0739..9453a26571 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -579,7 +579,7 @@ cache_find_entry_dn2id( struct berval ndn; ID id; - bv.bv_val = dn; + bv.bv_val = (char *)dn; bv.bv_len = strlen( dn ); rc = dnNormalize2( NULL, &bv, &ndn ); diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 574c32d8fa..366673a1d9 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -82,7 +82,7 @@ ldbm_back_compare( } if ( ! access_allowed( be, conn, op, e, - ava->aa_desc, ava->aa_value, ACL_COMPARE ) ) + ava->aa_desc, &ava->aa_value, ACL_COMPARE ) ) { send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, NULL, NULL, NULL, NULL ); @@ -98,7 +98,7 @@ ldbm_back_compare( { rc = LDAP_COMPARE_FALSE; - if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { + if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index 048050ca34..92462a45ec 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -331,7 +331,7 @@ equality_candidates( char *dbname; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; #ifdef NEW_LOGGING @@ -389,7 +389,7 @@ equality_candidates( ava->aa_desc->ad_type->sat_syntax, mr, &prefix, - ava->aa_value, + &ava->aa_value, &keys ); if( rc != LDAP_SUCCESS ) { @@ -436,11 +436,11 @@ equality_candidates( return idl; } - for ( i= 0; keys[i] != NULL; i++ ) { + for ( i= 0; keys[i].bv_val != NULL; i++ ) { ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, keys[i], &tmp ); + rc = key_read( be, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -480,7 +480,7 @@ equality_candidates( if( idl == NULL ) break; } - ber_bvecfree( keys ); + bvarray_free( keys ); ldbm_cache_close( be, db ); @@ -510,7 +510,7 @@ approx_candidates( char *dbname; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; #ifdef NEW_LOGGING @@ -573,7 +573,7 @@ approx_candidates( ava->aa_desc->ad_type->sat_syntax, mr, &prefix, - ava->aa_value, + &ava->aa_value, &keys ); if( rc != LDAP_SUCCESS ) { @@ -620,11 +620,11 @@ approx_candidates( return idl; } - for ( i= 0; keys[i] != NULL; i++ ) { + for ( i= 0; keys[i].bv_val != NULL; i++ ) { ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, keys[i], &tmp ); + rc = key_read( be, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -662,7 +662,7 @@ approx_candidates( if( idl == NULL ) break; } - ber_bvecfree( keys ); + bvarray_free( keys ); ldbm_cache_close( be, db ); @@ -751,7 +751,7 @@ substring_candidates( char *dbname; slap_mask_t mask; struct berval prefix = {0}; - struct berval **keys = NULL; + struct berval *keys = NULL; MatchingRule *mr; #ifdef NEW_LOGGING @@ -857,11 +857,11 @@ substring_candidates( return idl; } - for ( i= 0; keys[i] != NULL; i++ ) { + for ( i= 0; keys[i].bv_val != NULL; i++ ) { ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, keys[i], &tmp ); + rc = key_read( be, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -900,7 +900,7 @@ substring_candidates( if( idl == NULL ) break; } - ber_bvecfree( keys ); + bvarray_free( keys ); ldbm_cache_close( be, db ); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index d93b178805..420a3283a6 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -138,7 +138,7 @@ static int indexer( const char *text; DBCache *db; AttributeDescription *ad = NULL; - struct berval **keys; + struct berval *keys; assert( mask ); @@ -175,10 +175,10 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - key_change( be, db, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); } - ber_bvecfree( keys ); + bvarray_free( keys ); } } @@ -191,10 +191,10 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - key_change( be, db, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); } - ber_bvecfree( keys ); + bvarray_free( keys ); } } @@ -207,10 +207,10 @@ static int indexer( atname, vals, &keys ); if( rc == LDAP_SUCCESS && keys != NULL ) { - for( i=0; keys[i] != NULL; i++ ) { - key_change( be, db, keys[i], id, op ); + for( i=0; keys[i].bv_val != NULL; i++ ) { + key_change( be, db, &keys[i], id, op ); } - ber_bvecfree( keys ); + bvarray_free( keys ); } } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 7ff5926457..c0a5c9a06f 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -373,7 +373,7 @@ add_values( int rc; int j; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -387,15 +387,15 @@ add_values( int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { - ber_bvfree( asserted ); + free( asserted.bv_val ); return LDAP_TYPE_OR_VALUE_EXISTS; } } - ber_bvfree( asserted ); + free( asserted.bv_val ); } } @@ -459,7 +459,7 @@ delete_values( int rc; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -474,7 +474,7 @@ delete_values( int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { continue; @@ -493,7 +493,7 @@ delete_values( break; } - ber_bvfree( asserted ); + free( asserted.bv_val ); /* looked through them all w/o finding it */ if ( ! found ) { diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 6586b94764..4f97aa6c1a 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -555,8 +555,8 @@ search_candidates( ID_BLOCK *candidates; Filter f, fand, rf, af, xf; AttributeAssertion aa_ref, aa_alias; - static struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" }; - static struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" }; + struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" }; + struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" }; #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1, @@ -578,7 +578,7 @@ search_candidates( rf.f_choice = LDAP_FILTER_EQUALITY; rf.f_ava = &aa_ref; rf.f_av_desc = slap_schema.si_ad_objectClass; - rf.f_av_value = &bv_ref; + rf.f_av_value = bv_ref; rf.f_next = xf.f_or; xf.f_or = &rf; } @@ -588,7 +588,7 @@ search_candidates( af.f_choice = LDAP_FILTER_EQUALITY; af.f_ava = &aa_alias; af.f_av_desc = slap_schema.si_ad_objectClass; - af.f_av_value = &bv_alias; + af.f_av_value = bv_alias; af.f_next = xf.f_or; xf.f_or = ⁡ } diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 73d8a8e87f..1789ff0c9b 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -318,7 +318,7 @@ add_values( Entry *e, Modification *mod, int *newlevel ) int rc; int j; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -334,15 +334,15 @@ add_values( Entry *e, Modification *mod, int *newlevel ) int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if ( rc == LDAP_SUCCESS && match == 0 ) { - ber_bvfree( asserted ); + free( asserted.bv_val ); return LDAP_TYPE_OR_VALUE_EXISTS; } } - ber_bvfree( asserted ); + free( asserted.bv_val ); } } @@ -398,7 +398,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) int rc; const char *text = NULL; - struct berval *asserted = NULL; + struct berval asserted; rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY, @@ -413,7 +413,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) int match; int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - a->a_vals[j], asserted, &text ); + a->a_vals[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { continue; @@ -432,7 +432,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel ) break; } - ber_bvfree( asserted ); + free( asserted.bv_val ); /* looked through them all w/o finding it */ if ( ! found ) { diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index 6c0e87fffb..9743a0b2e2 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -295,3 +295,40 @@ slap_strcopy( while (*a++ = *b++) ; return a-1; } + +void +bvarray_add( + struct berval **a, + struct berval *bv +) +{ + int n; + + if ( *a == NULL ) { + *a = (struct berval *) ch_malloc( 2 * sizeof(struct berval) ); + n = 0; + } else { + for ( n = 0; *a != NULL && (*a)[n].bv_val != NULL; n++ ) { + ; /* NULL */ + } + + *a = (struct berval *) ch_realloc( (char *) *a, + (n + 2) * sizeof(struct berval) ); + } + + ber_dupbv( (*a)+n, bv ); + n++; + (*a)[n].bv_val = NULL; +} + +void +bvarray_free( + struct berval *a +) +{ + int i; + + for (i=0; a[i].bv_val; i++) + free(a[i].bv_val); + free(a); +} diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index c15fee13a9..d10dec51c9 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -41,7 +41,6 @@ do_compare( struct berval ndn = { 0, NULL }; struct berval desc = { 0, NULL }; struct berval value = { 0, NULL }; - struct berval *nvalue; AttributeAssertion ava; Backend *be; int rc = LDAP_SUCCESS; @@ -137,23 +136,21 @@ do_compare( goto cleanup; } - rc = value_normalize( ava.aa_desc, SLAP_MR_EQUALITY, &value, &nvalue, &text ); + rc = value_normalize( ava.aa_desc, SLAP_MR_EQUALITY, &value, &ava.aa_value, &text ); if( rc != LDAP_SUCCESS ) { send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); goto cleanup; } - ava.aa_value = nvalue; - if( strcasecmp( ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", conn->c_connid, pdn.bv_val, - ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val )); + ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val )); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", - pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val ); + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); #endif Statslog( LDAP_DEBUG_STATS, @@ -178,10 +175,10 @@ do_compare( LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val, - ava.aa_value->bv_val )); + ava.aa_value.bv_val )); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", - pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val ); + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); #endif Statslog( LDAP_DEBUG_STATS, @@ -254,10 +251,10 @@ do_compare( LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, "do_compare: conn %d dn (%s) attr(%s) value (%s)\n", conn->c_connid, pdn.bv_val, ava.aa_desc->ad_cname.bv_val, - ava.aa_value->bv_val )); + ava.aa_value.bv_val )); #else Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", - pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value->bv_val ); + pdn.bv_val, ava.aa_desc->ad_cname.bv_val, ava.aa_value.bv_val ); #endif Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d CMP dn=\"%s\" attr=\"%s\"\n", @@ -296,7 +293,7 @@ static int compare_entry( Attribute *a; if ( ! access_allowed( NULL, conn, op, e, - ava->aa_desc, ava->aa_value, ACL_COMPARE ) ) + ava->aa_desc, &ava->aa_value, ACL_COMPARE ) ) { return LDAP_INSUFFICIENT_ACCESS; } @@ -307,7 +304,7 @@ static int compare_entry( { rc = LDAP_COMPARE_FALSE; - if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { + if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index b1db9f686a..2ecc54369d 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -232,7 +232,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) AttributeDescription *ad; slap_syntax_transform_func *transf = NULL; MatchingRule *mr; - struct berval *bv = NULL; + struct berval bv; assert( ava ); @@ -274,18 +274,17 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) } if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) { - struct berval *s = bv; + char *s = bv.bv_val; - bv = ber_bvstr( UTF8normalize( bv ? bv : &ava->la_value, - UTF8_CASEFOLD ) ); - - ber_bvfree( s ); + ber_str2bv( UTF8normalize( bv.bv_val ? &bv + : &ava->la_value, UTF8_CASEFOLD ), + 0, 0, &bv ); + free( s ); } - if( bv ) { + if( bv.bv_val ) { free( ava->la_value.bv_val ); - ava->la_value = *bv; - free( bv ); + ava->la_value = bv; } AVA_Sort( rdn, iAVA ); diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 0e99f108f3..8422587bf3 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -195,7 +195,7 @@ str2entry( char *s ) } if( slapMode & SLAP_TOOL_MODE ) { - struct berval *pval = NULL; + struct berval pval; slap_syntax_validate_func *validate = ad->ad_type->sat_syntax->ssyn_validate; slap_syntax_transform_func *pretty = @@ -245,8 +245,7 @@ str2entry( char *s ) if( pretty ) { free( value.bv_val ); - value = *pval; - free( pval ); + value = pval; } } diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 0bf9089f8b..aad1a41a08 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -115,7 +115,7 @@ get_filter( assert( f->f_ava != NULL ); - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fstr->bv_len = sizeof("(=)")-1 + f->f_av_desc->ad_cname.bv_len @@ -152,7 +152,7 @@ get_filter( break; } - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fstr->bv_len = sizeof("(>=)")-1 + f->f_av_desc->ad_cname.bv_len @@ -180,7 +180,7 @@ get_filter( } - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fstr->bv_len = sizeof("(<=)")-1 + f->f_av_desc->ad_cname.bv_len @@ -246,7 +246,7 @@ get_filter( break; } - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fstr->bv_len = sizeof("(~=)") - 1 + f->f_av_desc->ad_cname.bv_len @@ -327,7 +327,7 @@ get_filter( assert( f->f_mra != NULL ); - filter_escape_value( f->f_mr_value, &escaped ); + filter_escape_value( &f->f_mr_value, &escaped ); fstr->bv_len = sizeof("(:dn::=)") - 1 + (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_len : 0) @@ -455,11 +455,10 @@ get_substring_filter( ber_tag_t tag; ber_len_t len; ber_tag_t rc; - struct berval *value; + struct berval value; struct berval escaped; char *last; - struct berval type; - struct berval *nvalue; + struct berval bv; *text = "error decoding filter"; #ifdef NEW_LOGGING @@ -468,15 +467,15 @@ get_substring_filter( #else Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); #endif - if ( ber_scanf( ber, "{o" /*}*/, &type ) == LBER_ERROR ) { + if ( ber_scanf( ber, "{o" /*}*/, &bv ) == LBER_ERROR ) { return SLAPD_DISCONNECT; } f->f_sub = ch_calloc( 1, sizeof(SubstringsAssertion) ); f->f_sub_desc = NULL; - rc = slap_bv2ad( &type, &f->f_sub_desc, text ); + rc = slap_bv2ad( &bv, &f->f_sub_desc, text ); - ch_free( type.bv_val ); + ch_free( bv.bv_val ); if( rc != LDAP_SUCCESS ) { text = NULL; @@ -487,9 +486,9 @@ get_substring_filter( return LDAP_SUCCESS; } - f->f_sub_initial = NULL; + f->f_sub_initial.bv_val = NULL; f->f_sub_any = NULL; - f->f_sub_final = NULL; + f->f_sub_final.bv_val = NULL; fstr->bv_len = sizeof("(=" /*)*/) - 1 + f->f_sub_desc->ad_cname.bv_len; @@ -501,14 +500,13 @@ get_substring_filter( { unsigned usage; - rc = ber_scanf( ber, "O", &value ); + rc = ber_scanf( ber, "o", &value ); if ( rc == LBER_ERROR ) { rc = SLAPD_DISCONNECT; goto return_error; } - if ( value == NULL || value->bv_len == 0 ) { - ber_bvfree( value ); + if ( value.bv_val == NULL || value.bv_len == 0 ) { rc = LDAP_INVALID_SYNTAX; goto return_error; } @@ -538,18 +536,18 @@ get_substring_filter( " unknown substring choice=%ld\n", (long) tag, 0, 0 ); #endif - ber_bvfree( value ); + free( value.bv_val ); goto return_error; } - rc = value_normalize( f->f_sub_desc, usage, value, &nvalue, text ); - ber_bvfree( value ); + rc = value_normalize( f->f_sub_desc, usage, &value, &bv, text ); + free( value.bv_val ); if( rc != LDAP_SUCCESS ) { goto return_error; } - value = nvalue; + value = bv; rc = LDAP_PROTOCOL_ERROR; @@ -563,11 +561,11 @@ get_substring_filter( Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); #endif - if ( f->f_sub_initial != NULL + if ( f->f_sub_initial.bv_val != NULL || f->f_sub_any != NULL - || f->f_sub_final != NULL ) + || f->f_sub_final.bv_val != NULL ) { - ber_bvfree( value ); + free( value.bv_val ); goto return_error; } @@ -575,7 +573,7 @@ get_substring_filter( if( fstr->bv_val ) { int i = fstr->bv_len; - filter_escape_value( value, &escaped ); + filter_escape_value( &value, &escaped ); fstr->bv_len += escaped.bv_len; fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); @@ -593,19 +591,16 @@ get_substring_filter( Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); #endif - if ( f->f_sub_final != NULL ) { - ber_bvfree( value ); + if ( f->f_sub_final.bv_val != NULL ) { + free( value.bv_val ); goto return_error; } - if( ber_bvecadd( &f->f_sub_any, value ) < 0 ) { - ber_bvfree( value ); - goto return_error; - } + bvarray_add( &f->f_sub_any, &value ); if( fstr->bv_val ) { int i = fstr->bv_len; - filter_escape_value( value, &escaped ); + filter_escape_value( &value, &escaped ); fstr->bv_len += escaped.bv_len + 2; fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); @@ -624,8 +619,8 @@ get_substring_filter( Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); #endif - if ( f->f_sub_final != NULL ) { - ber_bvfree( value ); + if ( f->f_sub_final.bv_val != NULL ) { + free( value.bv_val ); goto return_error; } @@ -633,7 +628,7 @@ get_substring_filter( if( fstr->bv_val ) { int i = fstr->bv_len; - filter_escape_value( value, &escaped ); + filter_escape_value( &value, &escaped ); fstr->bv_len += escaped.bv_len + 2; fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 1 ); @@ -654,7 +649,7 @@ get_substring_filter( (long) tag, 0, 0 ); #endif - ber_bvfree( value ); + free( value.bv_val ); return_error: #ifdef NEW_LOGGING @@ -671,9 +666,9 @@ return_error: fstr->bv_len = 0; } - ber_bvfree( f->f_sub_initial ); - ber_bvecfree( f->f_sub_any ); - ber_bvfree( f->f_sub_final ); + free( f->f_sub_initial.bv_val ); + bvarray_free( f->f_sub_any ); + free( f->f_sub_final.bv_val ); ch_free( f->f_sub ); return rc; } @@ -683,7 +678,7 @@ return_error: int i = fstr->bv_len; fstr->bv_len += 3; fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 3 ); - if ( f->f_sub_final == NULL ) { + if ( f->f_sub_final.bv_val == NULL ) { strcpy( fstr->bv_val+i, "*" ); i++; } @@ -720,12 +715,12 @@ filter_free( Filter *f ) break; case LDAP_FILTER_SUBSTRINGS: - if ( f->f_sub_initial != NULL ) { - ber_bvfree( f->f_sub_initial ); + if ( f->f_sub_initial.bv_val != NULL ) { + free( f->f_sub_initial.bv_val ); } - ber_bvecfree( f->f_sub_any ); - if ( f->f_sub_final != NULL ) { - ber_bvfree( f->f_sub_final ); + bvarray_free( f->f_sub_any ); + if ( f->f_sub_final.bv_val != NULL ) { + free( f->f_sub_final.bv_val ); } ch_free( f->f_sub ); break; @@ -770,7 +765,7 @@ filter_print( Filter *f ) switch ( f->f_choice ) { case LDAP_FILTER_EQUALITY: - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fprintf( stderr, "(%s=%s)", f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); @@ -778,7 +773,7 @@ filter_print( Filter *f ) break; case LDAP_FILTER_GE: - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fprintf( stderr, "(%s>=%s)", f->f_av_desc->ad_cname.bv_val, escaped.bv_val ); @@ -786,7 +781,7 @@ filter_print( Filter *f ) break; case LDAP_FILTER_LE: - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fprintf( stderr, "(%s<=%s)", f->f_ava->aa_desc->ad_cname.bv_val, escaped.bv_val ); @@ -794,7 +789,7 @@ filter_print( Filter *f ) break; case LDAP_FILTER_APPROX: - filter_escape_value( f->f_av_value, &escaped ); + filter_escape_value( &f->f_av_value, &escaped ); fprintf( stderr, "(%s~=%s)", f->f_ava->aa_desc->ad_cname.bv_val, escaped.bv_val ); @@ -804,22 +799,22 @@ filter_print( Filter *f ) case LDAP_FILTER_SUBSTRINGS: fprintf( stderr, "(%s=" /*)*/, f->f_sub_desc->ad_cname.bv_val ); - if ( f->f_sub_initial != NULL ) { - filter_escape_value( f->f_sub_initial, &escaped ); + if ( f->f_sub_initial.bv_val != NULL ) { + filter_escape_value( &f->f_sub_initial, &escaped ); fprintf( stderr, "%s", escaped.bv_val ); ber_memfree( escaped.bv_val ); } if ( f->f_sub_any != NULL ) { - for ( i = 0; f->f_sub_any[i] != NULL; i++ ) { - filter_escape_value( f->f_sub_any[i], &escaped ); + for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { + filter_escape_value( &f->f_sub_any[i], &escaped ); fprintf( stderr, "*%s", escaped.bv_val ); ber_memfree( escaped.bv_val ); } } - if ( f->f_sub_final != NULL ) { - filter_escape_value( f->f_sub_final, &escaped ); + if ( f->f_sub_final.bv_val != NULL ) { + filter_escape_value( &f->f_sub_final, &escaped ); fprintf( stderr, "*%s", escaped.bv_val ); ber_memfree( escaped.bv_val ); diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 43fd3e84c9..7678b437af 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -229,7 +229,7 @@ static int test_mra_filter( Attribute *a; if( !access_allowed( be, conn, op, e, - mra->ma_desc, mra->ma_value, ACL_SEARCH ) ) + mra->ma_desc, &mra->ma_value, ACL_SEARCH ) ) { return LDAP_INSUFFICIENT_ACCESS; } @@ -256,7 +256,7 @@ static int test_mra_filter( rc = value_match( &ret, a->a_desc, mra->ma_rule, SLAP_MR_ASSERTION_SYNTAX_MATCH, - a->a_vals[i], mra->ma_value, + a->a_vals[i], &mra->ma_value, &text ); if( rc != LDAP_SUCCESS ) { @@ -286,7 +286,7 @@ test_ava_filter( Attribute *a; if ( !access_allowed( be, conn, op, e, - ava->aa_desc, ava->aa_value, ACL_SEARCH ) ) + ava->aa_desc, &ava->aa_value, ACL_SEARCH ) ) { return LDAP_INSUFFICIENT_ACCESS; } @@ -328,7 +328,7 @@ test_ava_filter( rc = value_match( &ret, a->a_desc, mr, SLAP_MR_ASSERTION_SYNTAX_MATCH, - a->a_vals[i], ava->aa_value, + a->a_vals[i], &ava->aa_value, &text ); if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 38f5952c0a..b883966a7c 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -515,7 +515,7 @@ int slap_modlist2mods( * and pretty if appropriate */ for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) { - struct berval *pval = NULL; + struct berval pval; if( pretty ) { rc = pretty( ad->ad_type->sat_syntax, ml->ml_bvalues[nvals], &pval ); @@ -535,8 +535,7 @@ int slap_modlist2mods( if( pretty ) { ber_memfree( ml->ml_bvalues[nvals]->bv_val ); - *ml->ml_bvalues[nvals] = *pval; - free( pval ); + *ml->ml_bvalues[nvals] = pval; } } diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index c5133c07c6..56e15a417f 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -22,7 +22,7 @@ mra_free( ) { ch_free( mra->ma_rule_text.bv_val ); - ber_bvfree( mra->ma_value ); + ch_free( mra->ma_value.bv_val ); if ( freeit ) { ch_free( (char *) mra ); } @@ -37,7 +37,7 @@ get_mra( { int rc, tag; ber_len_t length; - struct berval type, value, *nvalue; + struct berval type, value; MatchingRuleAssertion *ma; ma = ch_malloc( sizeof( MatchingRuleAssertion ) ); @@ -46,7 +46,7 @@ get_mra( ma->ma_rule_text.bv_len = 0; ma->ma_desc = NULL; ma->ma_dnattrs = 0; - ma->ma_value = NULL; + ma->ma_value.bv_val = NULL; rc = ber_scanf( ber, "{t", &tag ); @@ -165,7 +165,7 @@ get_mra( * OK, if no matching rule, normalize for equality, otherwise * normalize for the matching rule. */ - rc = value_normalize( ma->ma_desc, SLAP_MR_EQUALITY, &value, &nvalue, text ); + rc = value_normalize( ma->ma_desc, SLAP_MR_EQUALITY, &value, &ma->ma_value, text ); ch_free( value.bv_val ); if( rc != LDAP_SUCCESS ) { @@ -173,8 +173,6 @@ get_mra( return rc; } - ma->ma_value = nvalue; - tag = ber_peek_tag( ber, &length ); if ( tag == LDAP_FILTER_EXT_DNATTRS ) { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 2a2f2d530b..beead593aa 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -276,6 +276,9 @@ LDAP_SLAPD_F (struct berval **) str2bvec LDAP_P(( struct berval **vec, LDAP_SLAPD_F (int) charray_strcmp LDAP_P(( const char **a1, const char **a2 )); LDAP_SLAPD_F (int) charray_strcasecmp LDAP_P(( const char **a1, const char **a2 )); +LDAP_SLAPD_F (void) bvarray_add LDAP_P(( struct berval **a, struct berval *bv )); +LDAP_SLAPD_F (void) bvarray_free LDAP_P(( struct berval *a )); + LDAP_SLAPD_F (char *) slap_strcopy LDAP_P(( char *dst, const char *src )); LDAP_SLAPD_F (int) bvec_inlist LDAP_P(( @@ -879,7 +882,7 @@ LDAP_SLAPD_F (int) value_normalize LDAP_P(( AttributeDescription *ad, unsigned usage, struct berval *in, - struct berval **out, + struct berval *out, const char ** text )); LDAP_SLAPD_F (int) value_match LDAP_P(( int *match, diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 7d3d5dda48..59b9b4cc33 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -124,11 +124,11 @@ static int octetStringIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -142,7 +142,7 @@ static int octetStringIndexer( /* we should have at least one value at this point */ assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -161,10 +161,10 @@ static int octetStringIndexer( values[i]->bv_val, values[i]->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[i] = ber_bvdup( &digest ); + ber_dupbv( &keys[i], &digest ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; @@ -179,10 +179,10 @@ static int octetStringFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval *value = (struct berval *) assertValue; @@ -193,7 +193,7 @@ static int octetStringFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -208,8 +208,8 @@ static int octetStringFilter( value->bv_val, value->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[0] = ber_bvdup( &digest ); - keys[1] = NULL; + ber_dupbv( keys, &digest ); + keys[1].bv_val = NULL; *keysp = keys; @@ -261,59 +261,60 @@ static int nameUIDNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { - struct berval *out = ber_bvdup( val ); + struct berval out; int rc; - if( out->bv_len != 0 ) { + ber_dupbv( &out, val ); + if( out.bv_len != 0 ) { ber_len_t dnlen; char *uid = NULL; ber_len_t uidlen = 0; - if( out->bv_val[out->bv_len-1] == '\'' ) { + if( out.bv_val[out.bv_len-1] == '\'' ) { /* assume presence of optional UID */ - uid = strrchr( out->bv_val, '#' ); + uid = strrchr( out.bv_val, '#' ); if( uid == NULL ) { - ber_bvfree( out ); + free( out.bv_val ); return LDAP_INVALID_SYNTAX; } - uidlen = out->bv_len - (uid - out->bv_val); + uidlen = out.bv_len - (uid - out.bv_val); /* temporarily trim the UID */ *uid = '\0'; - out->bv_len -= uidlen; + out.bv_len -= uidlen; } #ifdef USE_DN_NORMALIZE - rc = dnNormalize( NULL, out, normalized ); + rc = dnNormalize2( NULL, &out, normalized ); #else - rc = dnPretty( NULL, out, normalized ); + rc = dnPretty2( NULL, &out, normalized ); #endif if( rc != LDAP_SUCCESS ) { - ber_bvfree( out ); + free( out.bv_val ); return LDAP_INVALID_SYNTAX; } - dnlen = (*normalized)->bv_len; + dnlen = normalized->bv_len; if( uidlen ) { - struct berval *b2 = ch_malloc(sizeof(struct berval)); - b2->bv_val = ch_malloc(dnlen + uidlen + 1); - SAFEMEMCPY( b2->bv_val, (*normalized)->bv_val, dnlen ); + struct berval b2; + b2.bv_val = ch_malloc(dnlen + uidlen + 1); + SAFEMEMCPY( b2.bv_val, normalized->bv_val, dnlen ); /* restore the separator */ *uid = '#'; /* shift the UID */ - SAFEMEMCPY( (*normalized)->bv_val+dnlen, uid, uidlen ); - b2->bv_len = dnlen + uidlen; - (*normalized)->bv_val[dnlen+uidlen] = '\0'; - ber_bvfree(*normalized); + SAFEMEMCPY( normalized->bv_val+dnlen, uid, uidlen ); + b2.bv_len = dnlen + uidlen; + normalized->bv_val[dnlen+uidlen] = '\0'; + free(normalized->bv_val); *normalized = b2; } - ber_bvfree( out ); + free( out.bv_val ); } return LDAP_SUCCESS; @@ -378,14 +379,13 @@ static int bitStringNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { /* - * A normalized bitString is has no extaneous (leading) zero bits. + * A normalized bitString is has no extaneous (leading) zero bits. * That is, '00010'B is normalized to '10'B * However, as a special case, '0'B requires no normalization. - */ - struct berval *newval; + */ char *p; /* start at the first bit */ @@ -394,28 +394,24 @@ bitStringNormalize( /* Find the first non-zero bit */ while ( *p == '0' ) p++; - newval = (struct berval *) ch_malloc( sizeof(struct berval) ); - if( *p == '\'' ) { /* no non-zero bits */ - newval->bv_val = ch_strdup("\'0\'B"); - newval->bv_len = sizeof("\'0\'B") - 1; + ber_str2bv( "\'0\'B", sizeof("\'0\'B") - 1, 1, normalized ); goto done; } - newval->bv_val = ch_malloc( val->bv_len + 1 ); + normalized->bv_val = ch_malloc( val->bv_len + 1 ); - newval->bv_val[0] = '\''; - newval->bv_len = 1; + normalized->bv_val[0] = '\''; + normalized->bv_len = 1; for( ; *p != '\0'; p++ ) { - newval->bv_val[newval->bv_len++] = *p; + normalized->bv_val[normalized->bv_len++] = *p; } - newval->bv_val[newval->bv_len] = '\0'; + normalized->bv_val[normalized->bv_len] = '\0'; done: - *normalized = newval; return LDAP_SUCCESS; } @@ -494,13 +490,10 @@ static int UTF8StringNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { - struct berval *newval; char *p, *q, *s; - newval = ch_malloc( sizeof( struct berval ) ); - p = val->bv_val; /* Ignore initial whitespace */ @@ -509,12 +502,14 @@ UTF8StringNormalize( } if( *p == '\0' ) { - ch_free( newval ); return LDAP_INVALID_SYNTAX; } - newval->bv_val = ch_strdup( p ); - p = q = newval->bv_val; + ber_str2bv( p, val->bv_len - (p - val->bv_val), 1, normalized ); + + assert( normalized->bv_val ); + + p = q = normalized->bv_val; s = NULL; while ( *p ) { @@ -538,12 +533,11 @@ UTF8StringNormalize( } } - assert( *newval->bv_val ); - assert( newval->bv_val < p ); + assert( normalized->bv_val < p ); assert( q <= p ); /* cannot start with a space */ - assert( !ldap_utf8_isspace(newval->bv_val) ); + assert( !ldap_utf8_isspace(normalized->bv_val) ); /* * If the string ended in space, backup the pointer one @@ -561,8 +555,7 @@ UTF8StringNormalize( /* null terminate */ *q = '\0'; - newval->bv_len = q - newval->bv_val; - *normalized = newval; + normalized->bv_len = q - normalized->bv_val; return LDAP_SUCCESS; } @@ -582,30 +575,33 @@ UTF8SubstringsassertionNormalize( return NULL; } - if( sa->sa_initial != NULL ) { - nsa->sa_initial = ber_bvstr( UTF8normalize( sa->sa_initial, casefold ) ); - if( nsa->sa_initial == NULL ) { + if( sa->sa_initial.bv_val != NULL ) { + ber_str2bv( UTF8normalize( &sa->sa_initial, casefold ), 0, + 0, &nsa->sa_initial ); + if( nsa->sa_initial.bv_val == NULL ) { goto err; } } if( sa->sa_any != NULL ) { - for( i=0; sa->sa_any[i] != NULL; i++ ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { /* empty */ } - nsa->sa_any = (struct berval **)ch_malloc( (i + 1) * sizeof(struct berval *) ); - for( i=0; sa->sa_any[i] != NULL; i++ ) { - nsa->sa_any[i] = ber_bvstr( UTF8normalize( sa->sa_any[i], casefold ) ); - if( nsa->sa_any[i] == NULL ) { + nsa->sa_any = (struct berval *)ch_malloc( (i + 1) * sizeof(struct berval) ); + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + ber_str2bv( UTF8normalize( &sa->sa_any[i], casefold ), + 0, 0, &nsa->sa_any[i] ); + if( nsa->sa_any[i].bv_val == NULL ) { goto err; } } - nsa->sa_any[i] = NULL; + nsa->sa_any[i].bv_val = NULL; } - if( sa->sa_final != NULL ) { - nsa->sa_final = ber_bvstr( UTF8normalize( sa->sa_final, casefold ) ); - if( nsa->sa_final == NULL ) { + if( sa->sa_final.bv_val != NULL ) { + ber_str2bv( UTF8normalize( &sa->sa_final, casefold ), 0, + 0, &nsa->sa_final ); + if( nsa->sa_final.bv_val == NULL ) { goto err; } } @@ -613,9 +609,9 @@ UTF8SubstringsassertionNormalize( return nsa; err: - ber_bvfree( nsa->sa_final ); - ber_bvecfree( nsa->sa_any ); - ber_bvfree( nsa->sa_initial ); + free( nsa->sa_final.bv_val ); + bvarray_free( nsa->sa_any ); + free( nsa->sa_initial.bv_val ); ch_free( nsa ); return NULL; } @@ -774,11 +770,11 @@ approxIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { char *val, *c; int i,j, len, wordcount, keycount=0; - struct berval **newkeys, **keys=NULL; + struct berval *newkeys, *keys=NULL; for( j=0; values[j] != NULL; j++ ) { /* Yes, this is necessary */ @@ -795,9 +791,9 @@ approxIndexer( } /* Allocate/increase storage to account for new keys */ - newkeys = (struct berval **)ch_malloc( (keycount + wordcount + 1) - * sizeof(struct berval *) ); - memcpy( newkeys, keys, keycount * sizeof(struct berval *) ); + newkeys = (struct berval *)ch_malloc( (keycount + wordcount + 1) + * sizeof(struct berval) ); + memcpy( newkeys, keys, keycount * sizeof(struct berval) ); if( keys ) ch_free( keys ); keys = newkeys; @@ -805,16 +801,14 @@ approxIndexer( for( c=val,i=0; ibv_val = phonetic( c ); - keys[keycount]->bv_len = strlen( keys[keycount]->bv_val ); + ber_str2bv( phonetic( c ), 0, 0, &keys[keycount] ); keycount++; i++; } free( val ); } - keys[keycount] = NULL; + keys[keycount].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; @@ -828,18 +822,18 @@ approxFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { char *val, *c; int i, count, len; - struct berval **keys; + struct berval *keys; /* Yes, this is necessary */ val = UTF8normalize( ((struct berval *)assertValue), UTF8_NOCASEFOLD ); if( val == NULL ) { - keys = (struct berval **)ch_malloc( sizeof(struct berval *) ); - keys[0] = NULL; + keys = (struct berval *)ch_malloc( sizeof(struct berval) ); + keys[0].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -855,19 +849,19 @@ approxFilter( } /* Allocate storage for new keys */ - keys = (struct berval **)ch_malloc( (count + 1) * sizeof(struct berval *) ); + keys = (struct berval *)ch_malloc( (count + 1) * sizeof(struct berval) ); /* Get a phonetic copy of each word */ for( c=val,i=0; i 0 ); - keys = (struct berval **)ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = (struct berval *)ch_malloc( sizeof( struct berval ) * (i+1) ); /* Copy each value and run it through phonetic() */ for( i=0; values[i] != NULL; i++ ) { @@ -948,10 +942,10 @@ approxIndexer( s = UTF8normalize( values[i], UTF8_NOCASEFOLD ); /* strip 8-bit chars and run through phonetic() */ - keys[i] = ber_bvstr( phonetic( strip8bitChars( s ) ) ); + ber_str2bv( phonetic( strip8bitChars( s ) ), 0, 0, &keys[i] ); free( s ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; @@ -966,12 +960,12 @@ approxFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { - struct berval **keys; + struct berval *keys; char *s; - keys = (struct berval **)ch_malloc( sizeof( struct berval * ) * 2 ); + keys = (struct berval *)ch_malloc( sizeof( struct berval * ) * 2 ); /* Yes, this is necessary */ s = UTF8normalize( ((struct berval *)assertValue), @@ -1040,56 +1034,56 @@ caseExactIgnoreSubstringsMatch( } /* Add up asserted input length */ - if( sub->sa_initial ) { - inlen += sub->sa_initial->bv_len; + if( sub->sa_initial.bv_val ) { + inlen += sub->sa_initial.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i] != NULL; i++) { - inlen += sub->sa_any[i]->bv_len; + for(i=0; sub->sa_any[i].bv_val != NULL; i++) { + inlen += sub->sa_any[i].bv_len; } } - if( sub->sa_final ) { - inlen += sub->sa_final->bv_len; + if( sub->sa_final.bv_val ) { + inlen += sub->sa_final.bv_len; } - if( sub->sa_initial ) { + if( sub->sa_initial.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncmp( sub->sa_initial->bv_val, left.bv_val, - sub->sa_initial->bv_len ); + match = strncmp( sub->sa_initial.bv_val, left.bv_val, + sub->sa_initial.bv_len ); if( match != 0 ) { goto done; } - left.bv_val += sub->sa_initial->bv_len; - left.bv_len -= sub->sa_initial->bv_len; - inlen -= sub->sa_initial->bv_len; + left.bv_val += sub->sa_initial.bv_len; + left.bv_len -= sub->sa_initial.bv_len; + inlen -= sub->sa_initial.bv_len; } - if( sub->sa_final ) { + if( sub->sa_final.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncmp( sub->sa_final->bv_val, - &left.bv_val[left.bv_len - sub->sa_final->bv_len], - sub->sa_final->bv_len ); + match = strncmp( sub->sa_final.bv_val, + &left.bv_val[left.bv_len - sub->sa_final.bv_len], + sub->sa_final.bv_len ); if( match != 0 ) { goto done; } - left.bv_len -= sub->sa_final->bv_len; - inlen -= sub->sa_final->bv_len; + left.bv_len -= sub->sa_final.bv_len; + inlen -= sub->sa_final.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i]; i++) { + for(i=0; sub->sa_any[i].bv_val; i++) { ber_len_t idx; char *p; @@ -1100,11 +1094,11 @@ retry: goto done; } - if( sub->sa_any[i]->bv_len == 0 ) { + if( sub->sa_any[i].bv_len == 0 ) { continue; } - p = strchr( left.bv_val, *sub->sa_any[i]->bv_val ); + p = strchr( left.bv_val, *sub->sa_any[i].bv_val ); if( p == NULL ) { match = 1; @@ -1117,9 +1111,9 @@ retry: if( idx >= left.bv_len ) { /* this shouldn't happen */ free( nav ); - ch_free( sub->sa_final ); - ber_bvecfree( sub->sa_any ); - ch_free( sub->sa_initial ); + ch_free( sub->sa_final.bv_val ); + bvarray_free( sub->sa_any ); + ch_free( sub->sa_initial.bv_val ); ch_free( sub ); return LDAP_OTHER; } @@ -1127,15 +1121,15 @@ retry: left.bv_val = p; left.bv_len -= idx; - if( sub->sa_any[i]->bv_len > left.bv_len ) { + if( sub->sa_any[i].bv_len > left.bv_len ) { /* not enough left */ match = 1; goto done; } match = strncmp( left.bv_val, - sub->sa_any[i]->bv_val, - sub->sa_any[i]->bv_len ); + sub->sa_any[i].bv_val, + sub->sa_any[i].bv_len ); if( match != 0 ) { left.bv_val++; @@ -1143,18 +1137,18 @@ retry: goto retry; } - left.bv_val += sub->sa_any[i]->bv_len; - left.bv_len -= sub->sa_any[i]->bv_len; - inlen -= sub->sa_any[i]->bv_len; + left.bv_val += sub->sa_any[i].bv_len; + left.bv_len -= sub->sa_any[i].bv_len; + inlen -= sub->sa_any[i].bv_len; } } done: free( nav ); if( sub != NULL ) { - ber_bvfree( sub->sa_final ); - ber_bvecfree( sub->sa_any ); - ber_bvfree( sub->sa_initial ); + free( sub->sa_final.bv_val ); + bvarray_free( sub->sa_any ); + free( sub->sa_initial.bv_val ); ch_free( sub ); } *matchp = match; @@ -1169,12 +1163,12 @@ static int caseExactIgnoreIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; char casefold; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -1188,7 +1182,7 @@ static int caseExactIgnoreIndexer( /* we should have at least one value at this point */ assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -1197,9 +1191,9 @@ static int caseExactIgnoreIndexer( ? UTF8_CASEFOLD : UTF8_NOCASEFOLD; for( i=0; values[i] != NULL; i++ ) { - struct berval *value; - value = ber_bvstr( UTF8normalize( values[i], - casefold ) ); + struct berval value; + ber_str2bv( UTF8normalize( values[i], casefold ), 0, 0, + &value ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -1211,15 +1205,15 @@ static int caseExactIgnoreIndexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, value->bv_len ); + value.bv_val, value.bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - ber_bvfree( value ); + free( value.bv_val ); - keys[i] = ber_bvdup( &digest ); + ber_dupbv( &keys[i], &digest ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -1232,14 +1226,14 @@ static int caseExactIgnoreFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { char casefold; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; - struct berval *value; + struct berval value; struct berval digest; digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); @@ -1250,16 +1244,16 @@ static int caseExactIgnoreFilter( casefold = strcmp( mr->smr_oid, caseExactMatchOID ) ? UTF8_CASEFOLD : UTF8_NOCASEFOLD; - value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue), - casefold ) ); + ber_str2bv( UTF8normalize( ((struct berval *) assertValue), casefold ), + 0, 0, &value ); /* This usually happens if filter contains bad UTF8 */ - if( value == NULL ) { - keys = ch_malloc( sizeof( struct berval * ) ); - keys[0] = NULL; + if( value.bv_val == NULL ) { + keys = ch_malloc( sizeof( struct berval ) ); + keys[0].bv_val = NULL; return LDAP_SUCCESS; } - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -1271,13 +1265,13 @@ static int caseExactIgnoreFilter( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, value->bv_len ); + value.bv_val, value.bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[0] = ber_bvdup( &digest ); - keys[1] = NULL; + ber_dupbv( keys, &digest ); + keys[1].bv_val = NULL; - ber_bvfree( value ); + free( value.bv_val ); *keysp = keys; return LDAP_SUCCESS; @@ -1291,12 +1285,12 @@ static int caseExactIgnoreSubstringsIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { char casefold; ber_len_t i, nkeys; size_t slen, mlen; - struct berval **keys; + struct berval *keys; struct berval **nvalues; HASH_CONTEXT HASHcontext; @@ -1319,8 +1313,8 @@ static int caseExactIgnoreSubstringsIndexer( nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) ); for( i=0; values[i] != NULL; i++ ) { - nvalues[i] = ber_bvstr( UTF8normalize( values[i], - casefold ) ); + nvalues[i] = ber_str2bv( UTF8normalize( values[i], casefold ), + 0, 0, NULL ); } nvalues[i] = NULL; values = nvalues; @@ -1363,7 +1357,7 @@ static int caseExactIgnoreSubstringsIndexer( return LDAP_SUCCESS; } - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -1371,17 +1365,14 @@ static int caseExactIgnoreSubstringsIndexer( nkeys=0; for( i=0; values[i] != NULL; i++ ) { ber_len_t j,max; - struct berval *value; if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue; - value = values[i]; - if( ( flags & SLAP_INDEX_SUBSTR_ANY ) && - ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) ) + ( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) ) { char pre = SLAP_INDEX_SUBSTR_PREFIX; - max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1); + max = values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1); for( j=0; jsmr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[j], + &values[i]->bv_val[j], SLAP_INDEX_SUBSTR_MAXLEN ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } - max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len - ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; + max = SLAP_INDEX_SUBSTR_MAXLEN < values[i]->bv_len + ? SLAP_INDEX_SUBSTR_MAXLEN : values[i]->bv_len; for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) { char pre; @@ -1425,10 +1416,10 @@ static int caseExactIgnoreSubstringsIndexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, j ); + values[i]->bv_val, j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( flags & SLAP_INDEX_SUBSTR_FINAL ) { @@ -1445,10 +1436,10 @@ static int caseExactIgnoreSubstringsIndexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[value->bv_len-j], j ); + &values[i]->bv_val[values[i]->bv_len-j], j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } @@ -1456,7 +1447,7 @@ static int caseExactIgnoreSubstringsIndexer( } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); @@ -1475,13 +1466,13 @@ static int caseExactIgnoreSubstringsFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { SubstringsAssertion *sa; char pre, casefold; ber_len_t nkeys = 0; size_t slen, mlen, klen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval *value; @@ -1496,33 +1487,33 @@ static int caseExactIgnoreSubstringsFilter( return LDAP_SUCCESS; } - if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { ber_len_t i; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { /* don't bother accounting for stepping */ - nkeys += sa->sa_any[i]->bv_len - + nkeys += sa->sa_any[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 ); } } } - if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } if( nkeys == 0 ) { - ber_bvfree( sa->sa_final ); - ber_bvecfree( sa->sa_any ); - ber_bvfree( sa->sa_initial ); + free( sa->sa_final.bv_val ); + bvarray_free( sa->sa_any ); + free( sa->sa_initial.bv_val ); ch_free( sa ); *keysp = NULL; return LDAP_SUCCESS; @@ -1534,14 +1525,14 @@ static int caseExactIgnoreSubstringsFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); nkeys = 0; - if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX; - value = sa->sa_initial; + value = &sa->sa_initial; klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; @@ -1561,7 +1552,7 @@ static int caseExactIgnoreSubstringsFilter( value->bv_val, klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { @@ -1569,12 +1560,12 @@ static int caseExactIgnoreSubstringsFilter( pre = SLAP_INDEX_SUBSTR_PREFIX; klen = SLAP_INDEX_SUBSTR_MAXLEN; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { continue; } - value = sa->sa_any[i]; + value = &sa->sa_any[i]; for(j=0; j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN; @@ -1595,17 +1586,17 @@ static int caseExactIgnoreSubstringsFilter( &value->bv_val[j], klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } } - if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX; - value = sa->sa_final; + value = &sa->sa_final; klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; @@ -1625,19 +1616,19 @@ static int caseExactIgnoreSubstringsFilter( &value->bv_val[value->bv_len-klen], klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); *keysp = NULL; } - ber_bvfree( sa->sa_final ); - ber_bvecfree( sa->sa_any ); - ber_bvfree( sa->sa_initial ); + free( sa->sa_final.bv_val ); + bvarray_free( sa->sa_any ); + free( sa->sa_initial.bv_val ); ch_free( sa ); return LDAP_SUCCESS; @@ -1815,11 +1806,10 @@ static int integerNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { char *p; int negative=0; - struct berval *newval; ber_len_t len; @@ -1847,24 +1837,21 @@ integerNormalize( len--; } - newval = (struct berval *) ch_malloc( sizeof(struct berval) ); - /* If there are no non-zero digits left, the number is zero, otherwise allocate space for the number and copy it into the buffer */ if( len == 0 ) { - newval->bv_val = ch_strdup("0"); - newval->bv_len = 1; + normalized->bv_val = ch_strdup("0"); + normalized->bv_len = 1; } else { - newval->bv_len = len+negative; - newval->bv_val = ch_malloc( newval->bv_len ); + normalized->bv_len = len+negative; + normalized->bv_val = ch_malloc( normalized->bv_len ); if( negative ) { - newval->bv_val[0] = '-'; + normalized->bv_val[0] = '-'; } - memcpy( newval->bv_val + negative, p, len ); + memcpy( normalized->bv_val + negative, p, len ); } - *normalized = newval; return LDAP_SUCCESS; } @@ -1876,10 +1863,10 @@ static int integerIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; - struct berval **keys; + struct berval *keys; /* we should have at least one value at this point */ assert( values != NULL && values[0] != NULL ); @@ -1888,13 +1875,13 @@ static int integerIndexer( /* empty -- just count them */ } - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); for( i=0; values[i] != NULL; i++ ) { integerNormalize( syntax, values[i], &keys[i] ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -1907,13 +1894,13 @@ static int integerFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { - struct berval **keys; + struct berval *keys; - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); integerNormalize( syntax, assertValue, &keys[0] ); - keys[1] = NULL; + keys[1].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; @@ -1993,13 +1980,10 @@ static int IA5StringNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { - struct berval *newval; char *p, *q; - newval = ch_malloc( sizeof( struct berval ) ); - p = val->bv_val; /* Ignore initial whitespace */ @@ -2008,12 +1992,11 @@ IA5StringNormalize( } if( *p == '\0' ) { - ch_free( newval ); return LDAP_INVALID_SYNTAX; } - newval->bv_val = ch_strdup( p ); - p = q = newval->bv_val; + normalized->bv_val = ch_strdup( p ); + p = q = normalized->bv_val; while ( *p ) { if ( ASCII_SPACE( *p ) ) { @@ -2028,12 +2011,11 @@ IA5StringNormalize( } } - assert( *newval->bv_val ); - assert( newval->bv_val < p ); + assert( normalized->bv_val < p ); assert( q <= p ); /* cannot start with a space */ - assert( !ASCII_SPACE(*newval->bv_val) ); + assert( !ASCII_SPACE(*normalized->bv_val) ); /* * If the string ended in space, backup the pointer one @@ -2051,8 +2033,7 @@ IA5StringNormalize( /* null terminate */ *q = '\0'; - newval->bv_len = q - newval->bv_val; - *normalized = newval; + normalized->bv_len = q - normalized->bv_val; return LDAP_SUCCESS; } @@ -2094,56 +2075,56 @@ caseExactIA5SubstringsMatch( ber_len_t inlen=0; /* Add up asserted input length */ - if( sub->sa_initial ) { - inlen += sub->sa_initial->bv_len; + if( sub->sa_initial.bv_val ) { + inlen += sub->sa_initial.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i] != NULL; i++) { - inlen += sub->sa_any[i]->bv_len; + for(i=0; sub->sa_any[i].bv_val != NULL; i++) { + inlen += sub->sa_any[i].bv_len; } } - if( sub->sa_final ) { - inlen += sub->sa_final->bv_len; + if( sub->sa_final.bv_val ) { + inlen += sub->sa_final.bv_len; } - if( sub->sa_initial ) { + if( sub->sa_initial.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncmp( sub->sa_initial->bv_val, left.bv_val, - sub->sa_initial->bv_len ); + match = strncmp( sub->sa_initial.bv_val, left.bv_val, + sub->sa_initial.bv_len ); if( match != 0 ) { goto done; } - left.bv_val += sub->sa_initial->bv_len; - left.bv_len -= sub->sa_initial->bv_len; - inlen -= sub->sa_initial->bv_len; + left.bv_val += sub->sa_initial.bv_len; + left.bv_len -= sub->sa_initial.bv_len; + inlen -= sub->sa_initial.bv_len; } - if( sub->sa_final ) { + if( sub->sa_final.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncmp( sub->sa_final->bv_val, - &left.bv_val[left.bv_len - sub->sa_final->bv_len], - sub->sa_final->bv_len ); + match = strncmp( sub->sa_final.bv_val, + &left.bv_val[left.bv_len - sub->sa_final.bv_len], + sub->sa_final.bv_len ); if( match != 0 ) { goto done; } - left.bv_len -= sub->sa_final->bv_len; - inlen -= sub->sa_final->bv_len; + left.bv_len -= sub->sa_final.bv_len; + inlen -= sub->sa_final.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i]; i++) { + for(i=0; sub->sa_any[i].bv_val; i++) { ber_len_t idx; char *p; @@ -2154,11 +2135,11 @@ retry: goto done; } - if( sub->sa_any[i]->bv_len == 0 ) { + if( sub->sa_any[i].bv_len == 0 ) { continue; } - p = strchr( left.bv_val, *sub->sa_any[i]->bv_val ); + p = strchr( left.bv_val, *sub->sa_any[i].bv_val ); if( p == NULL ) { match = 1; @@ -2176,15 +2157,15 @@ retry: left.bv_val = p; left.bv_len -= idx; - if( sub->sa_any[i]->bv_len > left.bv_len ) { + if( sub->sa_any[i].bv_len > left.bv_len ) { /* not enough left */ match = 1; goto done; } match = strncmp( left.bv_val, - sub->sa_any[i]->bv_val, - sub->sa_any[i]->bv_len ); + sub->sa_any[i].bv_val, + sub->sa_any[i].bv_len ); if( match != 0 ) { left.bv_val++; @@ -2192,9 +2173,9 @@ retry: goto retry; } - left.bv_val += sub->sa_any[i]->bv_len; - left.bv_len -= sub->sa_any[i]->bv_len; - inlen -= sub->sa_any[i]->bv_len; + left.bv_val += sub->sa_any[i].bv_len; + left.bv_len -= sub->sa_any[i].bv_len; + inlen -= sub->sa_any[i].bv_len; } } @@ -2211,11 +2192,11 @@ static int caseExactIA5Indexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -2229,7 +2210,7 @@ static int caseExactIA5Indexer( /* we should have at least one value at this point */ assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -2250,10 +2231,10 @@ static int caseExactIA5Indexer( value->bv_val, value->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[i] = ber_bvdup( &digest ); + ber_dupbv( &keys[i], &digest ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -2266,10 +2247,10 @@ static int caseExactIA5Filter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval *value; @@ -2282,7 +2263,7 @@ static int caseExactIA5Filter( value = (struct berval *) assertValue; - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -2297,8 +2278,8 @@ static int caseExactIA5Filter( value->bv_val, value->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[0] = ber_bvdup( &digest ); - keys[1] = NULL; + ber_dupbv( &keys[0], &digest ); + keys[1].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; @@ -2312,11 +2293,11 @@ static int caseExactIA5SubstringsIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { ber_len_t i, nkeys; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -2364,7 +2345,7 @@ static int caseExactIA5SubstringsIndexer( return LDAP_SUCCESS; } - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -2401,7 +2382,7 @@ static int caseExactIA5SubstringsIndexer( SLAP_INDEX_SUBSTR_MAXLEN ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } @@ -2428,7 +2409,7 @@ static int caseExactIA5SubstringsIndexer( value->bv_val, j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( flags & SLAP_INDEX_SUBSTR_FINAL ) { @@ -2448,14 +2429,14 @@ static int caseExactIA5SubstringsIndexer( &value->bv_val[value->bv_len-j], j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); @@ -2472,37 +2453,37 @@ static int caseExactIA5SubstringsFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { SubstringsAssertion *sa = assertValue; char pre; ber_len_t nkeys = 0; size_t slen, mlen, klen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval *value; struct berval digest; - if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { ber_len_t i; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { /* don't bother accounting for stepping */ - nkeys += sa->sa_any[i]->bv_len - + nkeys += sa->sa_any[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 ); } } } - if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } @@ -2518,14 +2499,14 @@ static int caseExactIA5SubstringsFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); nkeys = 0; - if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX; - value = sa->sa_initial; + value = &sa->sa_initial; klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; @@ -2545,7 +2526,7 @@ static int caseExactIA5SubstringsFilter( value->bv_val, klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { @@ -2553,12 +2534,12 @@ static int caseExactIA5SubstringsFilter( pre = SLAP_INDEX_SUBSTR_PREFIX; klen = SLAP_INDEX_SUBSTR_MAXLEN; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { continue; } - value = sa->sa_any[i]; + value = &sa->sa_any[i]; for(j=0; j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN; @@ -2579,16 +2560,16 @@ static int caseExactIA5SubstringsFilter( &value->bv_val[j], klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } } - if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX; - value = sa->sa_final; + value = &sa->sa_final; klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; @@ -2608,11 +2589,11 @@ static int caseExactIA5SubstringsFilter( &value->bv_val[value->bv_len-klen], klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); @@ -2659,56 +2640,56 @@ caseIgnoreIA5SubstringsMatch( ber_len_t inlen=0; /* Add up asserted input length */ - if( sub->sa_initial ) { - inlen += sub->sa_initial->bv_len; + if( sub->sa_initial.bv_val ) { + inlen += sub->sa_initial.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i] != NULL; i++) { - inlen += sub->sa_any[i]->bv_len; + for(i=0; sub->sa_any[i].bv_val != NULL; i++) { + inlen += sub->sa_any[i].bv_len; } } - if( sub->sa_final ) { - inlen += sub->sa_final->bv_len; + if( sub->sa_final.bv_val ) { + inlen += sub->sa_final.bv_len; } - if( sub->sa_initial ) { + if( sub->sa_initial.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncasecmp( sub->sa_initial->bv_val, left.bv_val, - sub->sa_initial->bv_len ); + match = strncasecmp( sub->sa_initial.bv_val, left.bv_val, + sub->sa_initial.bv_len ); if( match != 0 ) { goto done; } - left.bv_val += sub->sa_initial->bv_len; - left.bv_len -= sub->sa_initial->bv_len; - inlen -= sub->sa_initial->bv_len; + left.bv_val += sub->sa_initial.bv_len; + left.bv_len -= sub->sa_initial.bv_len; + inlen -= sub->sa_initial.bv_len; } - if( sub->sa_final ) { + if( sub->sa_final.bv_val ) { if( inlen > left.bv_len ) { match = 1; goto done; } - match = strncasecmp( sub->sa_final->bv_val, - &left.bv_val[left.bv_len - sub->sa_final->bv_len], - sub->sa_final->bv_len ); + match = strncasecmp( sub->sa_final.bv_val, + &left.bv_val[left.bv_len - sub->sa_final.bv_len], + sub->sa_final.bv_len ); if( match != 0 ) { goto done; } - left.bv_len -= sub->sa_final->bv_len; - inlen -= sub->sa_final->bv_len; + left.bv_len -= sub->sa_final.bv_len; + inlen -= sub->sa_final.bv_len; } if( sub->sa_any ) { - for(i=0; sub->sa_any[i]; i++) { + for(i=0; sub->sa_any[i].bv_val; i++) { ber_len_t idx; char *p; @@ -2719,11 +2700,11 @@ retry: goto done; } - if( sub->sa_any[i]->bv_len == 0 ) { + if( sub->sa_any[i].bv_len == 0 ) { continue; } - p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val ); + p = strcasechr( left.bv_val, *sub->sa_any[i].bv_val ); if( p == NULL ) { match = 1; @@ -2741,15 +2722,15 @@ retry: left.bv_val = p; left.bv_len -= idx; - if( sub->sa_any[i]->bv_len > left.bv_len ) { + if( sub->sa_any[i].bv_len > left.bv_len ) { /* not enough left */ match = 1; goto done; } match = strncasecmp( left.bv_val, - sub->sa_any[i]->bv_val, - sub->sa_any[i]->bv_len ); + sub->sa_any[i].bv_val, + sub->sa_any[i].bv_len ); if( match != 0 ) { left.bv_val++; @@ -2758,9 +2739,9 @@ retry: goto retry; } - left.bv_val += sub->sa_any[i]->bv_len; - left.bv_len -= sub->sa_any[i]->bv_len; - inlen -= sub->sa_any[i]->bv_len; + left.bv_val += sub->sa_any[i].bv_len; + left.bv_len -= sub->sa_any[i].bv_len; + inlen -= sub->sa_any[i].bv_len; } } @@ -2777,11 +2758,11 @@ static int caseIgnoreIA5Indexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -2795,14 +2776,15 @@ static int caseIgnoreIA5Indexer( /* just count them */ } - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; for( i=0; values[i] != NULL; i++ ) { - struct berval *value = ber_bvdup( values[i] ); - ldap_pvt_str2upper( value->bv_val ); + struct berval value; + ber_dupbv( &value, values[i] ); + ldap_pvt_str2upper( value.bv_val ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -2814,15 +2796,15 @@ static int caseIgnoreIA5Indexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, value->bv_len ); + value.bv_val, value.bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - ber_bvfree( value ); + free( value.bv_val ); - keys[i] = ber_bvdup( &digest ); + ber_dupbv( &keys[i], &digest ); } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -2835,13 +2817,13 @@ static int caseIgnoreIA5Filter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; - struct berval *value; + struct berval value; struct berval digest; digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); @@ -2849,10 +2831,10 @@ static int caseIgnoreIA5Filter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - value = ber_bvdup( (struct berval *) assertValue ); - ldap_pvt_str2upper( value->bv_val ); + ber_dupbv( &value, (struct berval *) assertValue ); + ldap_pvt_str2upper( value.bv_val ); - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -2864,13 +2846,13 @@ static int caseIgnoreIA5Filter( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, value->bv_len ); + value.bv_val, value.bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - keys[0] = ber_bvdup( &digest ); - keys[1] = NULL; + ber_dupbv( &keys[0], &digest ); + keys[1].bv_val = NULL; - ber_bvfree( value ); + free( value.bv_val ); *keysp = keys; @@ -2885,11 +2867,11 @@ static int caseIgnoreIA5SubstringsIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { ber_len_t i, nkeys; size_t slen, mlen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; struct berval digest; @@ -2937,7 +2919,7 @@ static int caseIgnoreIA5SubstringsIndexer( return LDAP_SUCCESS; } - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -2945,18 +2927,18 @@ static int caseIgnoreIA5SubstringsIndexer( nkeys=0; for( i=0; values[i] != NULL; i++ ) { int j,max; - struct berval *value; + struct berval value; if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue; - value = ber_bvdup( values[i] ); - ldap_pvt_str2upper( value->bv_val ); + ber_dupbv( &value, values[i] ); + ldap_pvt_str2upper( value.bv_val ); if( ( flags & SLAP_INDEX_SUBSTR_ANY ) && - ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) ) + ( value.bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) ) { char pre = SLAP_INDEX_SUBSTR_PREFIX; - max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1); + max = value.bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1); for( j=0; jsmr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[j], + &value.bv_val[j], SLAP_INDEX_SUBSTR_MAXLEN ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } - max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len - ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; + max = SLAP_INDEX_SUBSTR_MAXLEN < value.bv_len + ? SLAP_INDEX_SUBSTR_MAXLEN : value.bv_len; for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) { char pre; @@ -3000,10 +2982,10 @@ static int caseIgnoreIA5SubstringsIndexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, j ); + value.bv_val, j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } if( flags & SLAP_INDEX_SUBSTR_FINAL ) { @@ -3020,19 +3002,19 @@ static int caseIgnoreIA5SubstringsIndexer( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[value->bv_len-j], j ); + &value.bv_val[value.bv_len-j], j ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } } - ber_bvfree( value ); + free( value.bv_val ); } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); @@ -3049,37 +3031,37 @@ static int caseIgnoreIA5SubstringsFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { SubstringsAssertion *sa = assertValue; char pre; ber_len_t nkeys = 0; size_t slen, mlen, klen; - struct berval **keys; + struct berval *keys; HASH_CONTEXT HASHcontext; unsigned char HASHdigest[HASH_BYTES]; - struct berval *value; + struct berval value; struct berval digest; - if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) { ber_len_t i; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) { /* don't bother accounting for stepping */ - nkeys += sa->sa_any[i]->bv_len - + nkeys += sa->sa_any[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 ); } } } - if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { nkeys++; } @@ -3095,18 +3077,18 @@ static int caseIgnoreIA5SubstringsFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); + keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); nkeys = 0; - if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL && - sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial.bv_val != NULL && + sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX; - value = ber_bvdup( sa->sa_initial ); - ldap_pvt_str2upper( value->bv_val ); + ber_dupbv( &value, &sa->sa_initial ); + ldap_pvt_str2upper( value.bv_val ); - klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len - ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; + klen = SLAP_INDEX_SUBSTR_MAXLEN < value.bv_len + ? SLAP_INDEX_SUBSTR_MAXLEN : value.bv_len; HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -3120,11 +3102,11 @@ static int caseIgnoreIA5SubstringsFilter( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - value->bv_val, klen ); + value.bv_val, klen ); HASH_Final( HASHdigest, &HASHcontext ); - ber_bvfree( value ); - keys[nkeys++] = ber_bvdup( &digest ); + free( value.bv_val ); + ber_dupbv( &keys[nkeys++], &digest ); } if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) { @@ -3132,16 +3114,16 @@ static int caseIgnoreIA5SubstringsFilter( pre = SLAP_INDEX_SUBSTR_PREFIX; klen = SLAP_INDEX_SUBSTR_MAXLEN; - for( i=0; sa->sa_any[i] != NULL; i++ ) { - if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { + for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { + if( sa->sa_any[i].bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) { continue; } - value = ber_bvdup( sa->sa_any[i] ); - ldap_pvt_str2upper( value->bv_val ); + ber_dupbv( &value, &sa->sa_any[i] ); + ldap_pvt_str2upper( value.bv_val ); for(j=0; - j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN; + j <= value.bv_len - SLAP_INDEX_SUBSTR_MAXLEN; j += SLAP_INDEX_SUBSTR_STEP ) { HASH_Init( &HASHcontext ); @@ -3156,25 +3138,25 @@ static int caseIgnoreIA5SubstringsFilter( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[j], klen ); + &value.bv_val[j], klen ); HASH_Final( HASHdigest, &HASHcontext ); - keys[nkeys++] = ber_bvdup( &digest ); + ber_dupbv( &keys[nkeys++], &digest ); } - ber_bvfree( value ); + free( value.bv_val ); } } - if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL && - sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) + if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final.bv_val != NULL && + sa->sa_final.bv_len >= SLAP_INDEX_SUBSTR_MINLEN ) { pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX; - value = ber_bvdup( sa->sa_final ); - ldap_pvt_str2upper( value->bv_val ); + ber_dupbv( &value, &sa->sa_final ); + ldap_pvt_str2upper( value.bv_val ); - klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len - ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len; + klen = SLAP_INDEX_SUBSTR_MAXLEN < value.bv_len + ? SLAP_INDEX_SUBSTR_MAXLEN : value.bv_len; HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -3188,15 +3170,15 @@ static int caseIgnoreIA5SubstringsFilter( HASH_Update( &HASHcontext, mr->smr_oid, mlen ); HASH_Update( &HASHcontext, - &value->bv_val[value->bv_len-klen], klen ); + &value.bv_val[value.bv_len-klen], klen ); HASH_Final( HASHdigest, &HASHcontext ); - ber_bvfree( value ); - keys[nkeys++] = ber_bvdup( &digest ); + free( value.bv_val ); + ber_dupbv( &keys[nkeys++], &digest ); } if( nkeys > 0 ) { - keys[nkeys] = NULL; + keys[nkeys].bv_val = NULL; *keysp = keys; } else { ch_free( keys ); @@ -3226,17 +3208,15 @@ static int numericStringNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { /* removal all spaces */ - struct berval *newval; char *p, *q; - newval = ch_malloc( sizeof( struct berval ) ); - newval->bv_val = ch_malloc( val->bv_len + 1 ); + normalized->bv_val = ch_malloc( val->bv_len + 1 ); p = val->bv_val; - q = newval->bv_val; + q = normalized->bv_val; while ( *p ) { if ( ASCII_SPACE( *p ) ) { @@ -3248,13 +3228,12 @@ numericStringNormalize( } /* we should have copied no more then is in val */ - assert( (q - newval->bv_val) <= (p - val->bv_val) ); + assert( (q - normalized->bv_val) <= (p - val->bv_val) ); /* null terminate */ *q = '\0'; - newval->bv_len = q - newval->bv_val; - *normalized = newval; + normalized->bv_len = q - normalized->bv_val; return LDAP_SUCCESS; } @@ -3500,7 +3479,7 @@ dn_openssl2ldap(X509_NAME *name) static int certificateExactConvert( struct berval * in, - struct berval ** out ) + struct berval * out ) { X509 *xcert; unsigned char *p = in->bv_val; @@ -3546,10 +3525,9 @@ certificateExactConvert( X509_free(xcert); - *out = ch_malloc(sizeof(struct berval)); - (*out)->bv_len = serial->bv_len + 3 + issuer_dn->bv_len + 1; - (*out)->bv_val = ch_malloc((*out)->bv_len); - p = (*out)->bv_val; + out->bv_len = serial->bv_len + 3 + issuer_dn->bv_len + 1; + out->bv_val = ch_malloc(out->bv_len); + p = out->bv_val; AC_MEMCPY(p, serial->bv_val, serial->bv_len); p += serial->bv_len; AC_MEMCPY(p, " $ ", 3); @@ -3561,11 +3539,11 @@ certificateExactConvert( #ifdef NEW_LOGGING LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, "certificateExactConvert: \n %s\n", - (*out)->bv_val)); + out->bv_val)); #else Debug( LDAP_DEBUG_ARGS, "certificateExactConvert " "\n\t\"%s\"\n", - (*out)->bv_val, NULL, NULL ); + out->bv_val, NULL, NULL ); #endif ber_bvfree(serial); @@ -3713,10 +3691,10 @@ static int certificateExactIndexer( MatchingRule *mr, struct berval *prefix, struct berval **values, - struct berval ***keysp ) + struct berval **keysp ) { int i; - struct berval **keys; + struct berval *keys; X509 *xcert; unsigned char *p; struct berval * serial; @@ -3728,7 +3706,7 @@ static int certificateExactIndexer( /* empty -- just count them */ } - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); + keys = ch_malloc( sizeof( struct berval ) * (i+1) ); for( i=0; values[i] != NULL; i++ ) { p = values[i]->bv_val; @@ -3757,16 +3735,16 @@ static int certificateExactIndexer( #ifdef NEW_LOGGING LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY, "certificateExactIndexer: returning: %s\n", - keys[i]->bv_val)); + keys[i].bv_val)); #else Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: " "returning: %s\n", - keys[i]->bv_val, + keys[i].bv_val, NULL, NULL ); #endif } - keys[i] = NULL; + keys[i].bv_val = NULL; *keysp = keys; return LDAP_SUCCESS; } @@ -3780,9 +3758,9 @@ static int certificateExactFilter( MatchingRule *mr, struct berval *prefix, void * assertValue, - struct berval ***keysp ) + struct berval **keysp ) { - struct berval **keys; + struct berval *keys; struct berval *asserted_serial; struct berval *asserted_issuer_dn; @@ -3790,9 +3768,9 @@ static int certificateExactFilter( &asserted_serial, &asserted_issuer_dn); - keys = ch_malloc( sizeof( struct berval * ) * 2 ); + keys = ch_malloc( sizeof( struct berval ) * 2 ); integerNormalize( syntax, asserted_serial, &keys[0] ); - keys[1] = NULL; + keys[1].bv_val = NULL; *keysp = keys; ber_bvfree(asserted_serial); @@ -3970,9 +3948,8 @@ static int utcTimeNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { - struct berval *out; int parts[9], rc; rc = check_time_syntax(val, 1, parts); @@ -3980,23 +3957,15 @@ utcTimeNormalize( return rc; } - *normalized = NULL; - out = ch_malloc( sizeof(struct berval) ); - if( out == NULL ) { + normalized->bv_val = ch_malloc( 14 ); + if ( normalized->bv_val == NULL ) { return LBER_ERROR_MEMORY; } - out->bv_val = ch_malloc( 14 ); - if ( out->bv_val == NULL ) { - ch_free( out ); - return LBER_ERROR_MEMORY; - } - - sprintf( out->bv_val, "%02d%02d%02d%02d%02d%02dZ", + sprintf( normalized->bv_val, "%02d%02d%02d%02d%02d%02dZ", parts[1], parts[2] + 1, parts[3] + 1, parts[4], parts[5], parts[6] ); - out->bv_len = 13; - *normalized = out; + normalized->bv_len = 13; return LDAP_SUCCESS; } @@ -4025,9 +3994,8 @@ static int generalizedTimeNormalize( Syntax *syntax, struct berval *val, - struct berval **normalized ) + struct berval *normalized ) { - struct berval *out; int parts[9], rc; rc = check_time_syntax(val, 0, parts); @@ -4035,23 +4003,15 @@ generalizedTimeNormalize( return rc; } - *normalized = NULL; - out = ch_malloc( sizeof(struct berval) ); - if( out == NULL ) { - return LBER_ERROR_MEMORY; - } - - out->bv_val = ch_malloc( 16 ); - if ( out->bv_val == NULL ) { - ch_free( out ); + normalized->bv_val = ch_malloc( 16 ); + if ( normalized->bv_val == NULL ) { return LBER_ERROR_MEMORY; } - sprintf( out->bv_val, "%02d%02d%02d%02d%02d%02d%02dZ", + sprintf( normalized->bv_val, "%02d%02d%02d%02d%02d%02d%02dZ", parts[0], parts[1], parts[2] + 1, parts[3] + 1, parts[4], parts[5], parts[6] ); - out->bv_len = 15; - *normalized = out; + normalized->bv_len = 15; return LDAP_SUCCESS; } @@ -4185,7 +4145,7 @@ static struct syntax_defs_rec { {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )", 0, countryStringValidate, IA5StringNormalize, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )", - 0, dnValidate, dnNormalize, dnPretty}, + 0, dnValidate, dnNormalize2, dnPretty2}, {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )", 0, NULL, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )", diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index bff8f8ac03..1216151f0e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -246,7 +246,7 @@ typedef int slap_syntax_validate_func LDAP_P(( typedef int slap_syntax_transform_func LDAP_P(( struct slap_syntax *syntax, struct berval * in, - struct berval ** out)); + struct berval * out)); typedef struct slap_syntax { LDAPSyntax ssyn_syn; @@ -285,7 +285,7 @@ typedef struct slap_syntax { /* X -> Y Converter */ typedef int slap_mr_convert_func LDAP_P(( struct berval * in, - struct berval ** out )); + struct berval * out )); /* Normalizer */ typedef int slap_mr_normalize_func LDAP_P(( @@ -293,7 +293,7 @@ typedef int slap_mr_normalize_func LDAP_P(( struct slap_syntax *syntax, /* NULL if in is asserted value */ struct slap_matching_rule *mr, struct berval * in, - struct berval ** out )); + struct berval * out )); /* Match (compare) function */ typedef int slap_mr_match_func LDAP_P(( @@ -312,7 +312,7 @@ typedef int slap_mr_indexer_func LDAP_P(( struct slap_matching_rule *mr, struct berval *prefix, struct berval **values, - struct berval ***keys )); + struct berval **keys )); /* Filter index function */ typedef int slap_mr_filter_func LDAP_P(( @@ -322,7 +322,7 @@ typedef int slap_mr_filter_func LDAP_P(( struct slap_matching_rule *mr, struct berval *prefix, void * assertValue, - struct berval ***keys )); + struct berval **keys )); typedef struct slap_matching_rule { LDAPMatchingRule smr_mrule; @@ -532,22 +532,22 @@ struct slap_internal_schema { typedef struct slap_attr_assertion { AttributeDescription *aa_desc; - struct berval *aa_value; + struct berval aa_value; } AttributeAssertion; typedef struct slap_ss_assertion { AttributeDescription *sa_desc; - struct berval *sa_initial; - struct berval **sa_any; - struct berval *sa_final; + struct berval sa_initial; + struct berval *sa_any; + struct berval sa_final; } SubstringsAssertion; typedef struct slap_mr_assertion { - MatchingRule *ma_rule; /* optional */ - struct berval ma_rule_text; /* optional */ + MatchingRule *ma_rule; /* optional */ + struct berval ma_rule_text; /* optional */ AttributeDescription *ma_desc; /* optional */ int ma_dnattrs; /* boolean */ - struct berval *ma_value; /* required */ + struct berval ma_value; /* required */ } MatchingRuleAssertion; /* diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index e0907a2534..d0cd38f1e9 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -273,7 +273,7 @@ str2simple( const char *str ) tmp = ch_strdup( value ); ldap_pvt_filter_value_unescape( tmp ); - f->f_av_value = ber_bvstr( tmp ); + ber_str2bv( tmp, 0, 0, &f->f_av_value ); } *s = savechar; @@ -308,10 +308,10 @@ str2subvals( const char *in, Filter *f ) ldap_pvt_filter_value_unescape( val ); if ( gotstar == 0 ) { - f->f_sub_initial = ber_bvstrdup( val ); + ber_str2bv( val, 0, 1, &f->f_sub_initial ); } else if ( nextstar == NULL ) { - f->f_sub_final = ber_bvstrdup( val ); + ber_str2bv( val, 0, 1, &f->f_sub_final ); } else { charray_add( (char ***) &f->f_sub_any, (char *) ber_bvstrdup( val ) ); diff --git a/servers/slapd/value.c b/servers/slapd/value.c index cb87d5e4e2..bc139e2f8e 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -56,7 +56,7 @@ value_normalize( AttributeDescription *ad, unsigned usage, struct berval *in, - struct berval **out, + struct berval *out, const char **text ) { int rc; @@ -113,7 +113,7 @@ value_normalize( } } else { - *out = ber_bvdup( in ); + ber_dupbv( out, in ); } return LDAP_SUCCESS; @@ -131,8 +131,8 @@ value_match( const char ** text ) { int rc; - struct berval *nv1 = NULL; - struct berval *nv2 = NULL; + struct berval nv1; + struct berval nv2; if( !mr->smr_match ) { return LDAP_INAPPROPRIATE_MATCHING; @@ -162,11 +162,11 @@ value_match( rc = (mr->smr_match)( match, flags, ad->ad_type->sat_syntax, mr, - nv1 != NULL ? nv1 : v1, - nv2 != NULL ? nv2 : v2 ); + nv1.bv_val != NULL ? &nv1 : v1, + nv2.bv_val != NULL ? &nv2 : v2 ); - ber_bvfree( nv1 ); - ber_bvfree( nv2 ); + free( nv1.bv_val ); + free( nv2.bv_val ); return rc; } @@ -179,8 +179,8 @@ int value_find_ex( { int i; int rc; - struct berval *nval = NULL; - struct berval *nval_tmp = NULL; + struct berval nval; + struct berval nval_tmp; MatchingRule *mr = ad->ad_type->sat_equality; if( mr == NULL || !mr->smr_match ) { @@ -202,12 +202,12 @@ int value_find_ex( if( mr->smr_syntax->ssyn_normalize ) { rc = mr->smr_syntax->ssyn_normalize( - mr->smr_syntax, nval == NULL ? val : nval, &nval_tmp ); + mr->smr_syntax, nval.bv_val == NULL ? val : &nval, &nval_tmp ); - ber_bvfree(nval); + free(nval.bv_val); nval = nval_tmp; if( rc != LDAP_SUCCESS ) { - ber_bvfree(nval); + free(nval.bv_val); return LDAP_INAPPROPRIATE_MATCHING; } } @@ -217,14 +217,14 @@ int value_find_ex( const char *text; rc = value_match( &match, ad, mr, flags, - vals[i], nval == NULL ? val : nval, &text ); + vals[i], nval.bv_val == NULL ? val : &nval, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { - ber_bvfree( nval ); + free( nval.bv_val ); return LDAP_SUCCESS; } } - ber_bvfree( nval ); + free( nval.bv_val ); return LDAP_NO_SUCH_ATTRIBUTE; }