From dd66e6e9292c1a250a89865d691f836003d08517 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 26 Feb 2003 07:39:30 +0000 Subject: [PATCH] SLAP_NVALUES, round 3 --- servers/slapd/ad.c | 4 +- servers/slapd/at.c | 1 + servers/slapd/attr.c | 23 ++++------ servers/slapd/back-bdb/modify.c | 4 +- servers/slapd/cr.c | 1 + servers/slapd/modify.c | 81 +++++++++++++++++++++++---------- servers/slapd/mods.c | 5 +- servers/slapd/mr.c | 1 + servers/slapd/oc.c | 1 + servers/slapd/oidm.c | 5 +- servers/slapd/proto-slap.h | 4 +- servers/slapd/slap.h | 6 +-- servers/slapd/syntax.c | 1 + servers/slapd/value.c | 1 - 14 files changed, 84 insertions(+), 54 deletions(-) diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index ece6019282..407b091cad 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -191,8 +191,7 @@ int slap_bv2ad( desc.ad_flags |= SLAP_DESC_BINARY; continue; - } else if ( ad_find_option_definition( opt, optlen ) ) - { + } else if ( ad_find_option_definition( opt, optlen ) ) { int i; if( opt[optlen-1] == '-' ) { @@ -325,6 +324,7 @@ done:; } d2 = ch_malloc(sizeof(AttributeDescription) + dlen); + d2->ad_next = NULL; d2->ad_type = desc.ad_type; d2->ad_flags = desc.ad_flags; d2->ad_cname.bv_len = desc.ad_type->sat_cname.bv_len; diff --git a/servers/slapd/at.c b/servers/slapd/at.c index 1b1ff6aae7..5333e376dc 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -261,6 +261,7 @@ at_insert( struct aindexrec *air; char **names; + LDAP_SLIST_NEXT( sat, sat_next ) = NULL; LDAP_SLIST_INSERT_HEAD( &attr_list, sat, sat_next ); if ( sat->sat_oid ) { diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index d72c5ae092..decf58228a 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -65,30 +65,23 @@ Attribute *attr_dup( Attribute *a ) } tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval)); -#ifdef SLAP_NVALUES - if( a->a_nvals != NULL ) { - tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval)); - } -#endif - for( i=0; a->a_vals[i].bv_val != NULL; i++ ) { ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] ); if( tmp->a_vals[i].bv_val == NULL ) break; + } + tmp->a_vals[i].bv_val = NULL; #ifdef SLAP_NVALUES - if( a->a_nvals ) { + if( a->a_nvals != NULL ) { + tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval)); + for( i=0; a->a_nvals[i].bv_val != NULL; i++ ) { ber_dupbv( &tmp->a_nvals[i], &a->a_nvals[i] ); if( tmp->a_nvals[i].bv_val == NULL ) break; - } else { - tmp->a_nvals = NULL; } -#endif - } - - tmp->a_vals[i].bv_val = NULL; -#ifdef SLAP_NVALUES - if( tmp->a_nvals != NULL ) { tmp->a_nvals[i].bv_val = NULL; + + } else { + tmp->a_nvals = NULL; } #endif diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index b2ffc7a178..a3b0846639 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -210,7 +210,7 @@ int bdb_modify_internal( for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) { if ( ap->a_flags & SLAP_ATTR_IXDEL ) { rc = bdb_index_values( be, tid, ap->a_desc, ap->a_vals, - e->e_id, SLAP_INDEX_DELETE_OP ); + e->e_id, SLAP_INDEX_DELETE_OP ); if ( rc != LDAP_SUCCESS ) { attrs_free( e->e_attrs ); e->e_attrs = save_attrs; @@ -233,7 +233,7 @@ int bdb_modify_internal( for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) { if (ap->a_flags & SLAP_ATTR_IXADD) { rc = bdb_index_values( be, tid, ap->a_desc, ap->a_vals, - e->e_id, SLAP_INDEX_ADD_OP ); + e->e_id, SLAP_INDEX_ADD_OP ); if ( rc != LDAP_SUCCESS ) { attrs_free( e->e_attrs ); e->e_attrs = save_attrs; diff --git a/servers/slapd/cr.c b/servers/slapd/cr.c index bbd3b349ee..30384e0376 100644 --- a/servers/slapd/cr.c +++ b/servers/slapd/cr.c @@ -116,6 +116,7 @@ cr_insert( struct cindexrec *cir; char **names; + LDAP_SLIST_NEXT( scr, scr_next ) = NULL; LDAP_SLIST_INSERT_HEAD(&cr_list, scr, scr_next); if ( scr->scr_oid ) { diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index fcde972853..1896fb9011 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -613,7 +613,7 @@ int slap_mods_check( ad->ad_type->sat_syntax->ssyn_normalize ) { ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) ); - for( nvals = 0; ml->sml_nvalues[nvals].bv_val; nvals++ ) { + for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) { rc = ad->ad_type->sat_syntax->ssyn_normalize( ad->ad_type->sat_syntax, &ml->sml_values[nvals], &ml->sml_nvalues[nvals] ); @@ -665,6 +665,9 @@ int slap_mods_opattrs( char *textbuf, size_t textlen ) { struct berval name, timestamp, csn; +#ifdef SLAP_NVALUES + struct berval nname; +#endif char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; Modifications *mod; @@ -693,8 +696,14 @@ int slap_mods_opattrs( if( op->o_dn.bv_len == 0 ) { name.bv_val = SLAPD_ANONYMOUS; name.bv_len = sizeof(SLAPD_ANONYMOUS)-1; +#ifdef SLAP_NVALUES + nname = name; +#endif } else { name = op->o_dn; +#ifdef SLAP_NVALUES + nname = op->o_ndn; +#endif } } @@ -712,13 +721,20 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_structuralObjectClass; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif - mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + mod->sml_values = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &tmpval ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_nvalues[0], &tmpval ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; + assert( mod->sml_nvalues[0].bv_val ); +#endif *modtail = mod; modtail = &mod->sml_next; } @@ -733,13 +749,15 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_entryUUID; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif - mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + mod->sml_values = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &tmpval ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = NULL; +#endif *modtail = mod; modtail = &mod->sml_next; @@ -747,13 +765,19 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_creatorsName; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &name ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_nvalues[0], &nname ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; + assert( mod->sml_nvalues[0].bv_val ); +#endif *modtail = mod; modtail = &mod->sml_next; @@ -761,13 +785,14 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_createTimestamp; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], ×tamp ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = NULL; +#endif *modtail = mod; modtail = &mod->sml_next; } @@ -778,13 +803,14 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_entryCSN; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &csn ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = NULL; +#endif *modtail = mod; modtail = &mod->sml_next; @@ -792,13 +818,19 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_modifiersName; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &name ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_nvalues[0], &nname ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; + assert( mod->sml_nvalues[0].bv_val ); +#endif *modtail = mod; modtail = &mod->sml_next; @@ -806,13 +838,14 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_modifyTimestamp; -#ifdef SLAP_NVALUES - mod->sml_nvalues = NULL; -#endif mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], ×tamp ); + mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; assert( mod->sml_values[0].bv_val ); +#ifdef SLAP_NVALUES + mod->sml_nvalues = NULL; +#endif *modtail = mod; modtail = &mod->sml_next; } diff --git a/servers/slapd/mods.c b/servers/slapd/mods.c index 37392a41b9..72a8e60308 100644 --- a/servers/slapd/mods.c +++ b/servers/slapd/mods.c @@ -675,13 +675,14 @@ slap_mod_free( ) { if ( mod->sm_values != NULL ) ber_bvarray_free( mod->sm_values ); + mod->sm_values = NULL; #ifdef SLAP_NVALUES if ( mod->sm_nvalues != NULL ) ber_bvarray_free( mod->sm_nvalues ); + mod->sm_nvalues = NULL; #endif - if( freeit ) - free( mod ); + if( freeit ) free( mod ); } void diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index b401aa3e9a..129c2455c1 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -97,6 +97,7 @@ mr_insert( struct mindexrec *mir; char **names; + LDAP_SLIST_NEXT( smr, smr_next ) = NULL; LDAP_SLIST_INSERT_HEAD(&mr_list, smr, smr_next); if ( smr->smr_oid ) { diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index aff2f7e8c4..9b901ca475 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -355,6 +355,7 @@ oc_insert( struct oindexrec *oir; char **names; + LDAP_SLIST_NEXT( soc, soc_next ) = NULL; LDAP_SLIST_INSERT_HEAD( &oc_list, soc, soc_next ); if ( soc->soc_oid ) { diff --git a/servers/slapd/oidm.c b/servers/slapd/oidm.c index 89895ad6c3..05d8e1fb07 100644 --- a/servers/slapd/oidm.c +++ b/servers/slapd/oidm.c @@ -90,8 +90,7 @@ parse_oidm( const char *fname, int lineno, int argc, - char **argv -) + char **argv ) { char *oid; OidMacro *om; @@ -122,6 +121,7 @@ usage: fprintf( stderr, "\tObjectIdentifier \n"); return 1; } + LDAP_SLIST_NEXT( om, som_next ) = NULL; om->som_names = NULL; ldap_charray_add( &om->som_names, argv[1] ); om->som_oid.bv_val = oidm_find( argv[2] ); @@ -139,6 +139,5 @@ usage: fprintf( stderr, "\tObjectIdentifier \n"); om->som_oid.bv_len = strlen( om->som_oid.bv_val ); LDAP_SLIST_INSERT_HEAD( &om_list, om, som_next ); - return 0; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index c85866f60c..26c3801540 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1065,11 +1065,11 @@ LDAP_SLAPD_F (void) slap_init_user LDAP_P(( char *username, char *groupname )); /* * value.c */ -LDAP_SLAPD_F (int) value_validate LDAP_P(( +LDAP_SLAPD_F (int) assertion_value_validate LDAP_P(( MatchingRule *mr, struct berval *in, const char ** text )); -LDAP_SLAPD_F (int) value_normalize LDAP_P(( +LDAP_SLAPD_F (int) attribute_value_normalize LDAP_P(( AttributeDescription *ad, unsigned usage, struct berval *in, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 7a5ff020da..5b68bb1efe 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -36,7 +36,7 @@ #include "ldap_queue.h" #ifdef LDAP_DEVEL -/* #define SLAP_NVALUES 1 */ +#define SLAP_NVALUES 1 #define SLAP_EXTENDED_SCHEMA 1 #endif @@ -903,7 +903,7 @@ typedef struct slap_attr { #ifdef SLAP_NVALUES BerVarray a_nvals; /* normalized values */ #endif - struct slap_attr *a_next; + struct slap_attr *a_next; unsigned a_flags; #define SLAP_ATTR_IXADD 0x1U #define SLAP_ATTR_IXDEL 0x2U @@ -975,7 +975,7 @@ typedef struct slap_ldap_modlist { #define ml_op ml_mod.mod_op #define ml_type ml_mod.mod_type #define ml_values ml_mod.mod_values -#define ml_bvalues ml_mod.mod_bvalues +#define ml_bvalues ml_mod.mod_values } LDAPModList; /* diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index 28e0a18731..d808d8126a 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -89,6 +89,7 @@ syn_insert( { struct sindexrec *sir; + LDAP_SLIST_NEXT( ssyn, ssyn_next ) = NULL; LDAP_SLIST_INSERT_HEAD( &syn_list, ssyn, ssyn_next ); if ( ssyn->ssyn_oid ) { diff --git a/servers/slapd/value.c b/servers/slapd/value.c index ab5d175086..cd6c65c93e 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -309,7 +309,6 @@ value_validate_normalize( return LDAP_SUCCESS; } - int value_match( int *match, -- 2.39.5