Change struct berval * to struct berval in various structures

This commit is contained in:
Howard Chu 2001-12-29 15:01:10 +00:00
parent 6d046b1681
commit 185ff129b5
27 changed files with 653 additions and 668 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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],

View file

@ -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;

View file

@ -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 ) {

View file

@ -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 = &af;
}

View file

@ -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 );

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 );

View file

@ -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 );
}
}

View file

@ -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 ) {

View file

@ -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 = &af;
}

View file

@ -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 ) {

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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 );

View file

@ -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;
}
}

View file

@ -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 );

View file

@ -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 ) {

View file

@ -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;
}
}

View file

@ -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 ) {

View file

@ -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,

File diff suppressed because it is too large Load diff

View file

@ -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;
/*

View file

@ -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 ) );

View file

@ -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;
}