From: Kurt Zeilenga Date: Tue, 23 May 2000 18:08:19 +0000 (+0000) Subject: SLAPD_SCHEMA_NOT_COMPAT: fix bugs in add/modify logic X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2894 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=62eea3b4529be3c1a5ed9475dbd7e4ca3b69fe32;p=openldap SLAPD_SCHEMA_NOT_COMPAT: fix bugs in add/modify logic --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 97b618ce27..8593bf1e29 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -233,7 +233,15 @@ do_add( Connection *conn, Operation *op ) #endif { #ifdef SLAPD_SCHEMA_NOT_COMPAT - rc = slap_mods_opattrs( op, &mods, &text ); + Modifications **modstail; + for( modstail = &mods; + *modstail != NULL; + modstail = &(*modstail)->sml_next ) + { + assert( (*modstail)->sml_op == LDAP_MOD_ADD ); + assert( (*modstail)->sml_desc != NULL ); + } + rc = slap_mods_opattrs( op, modstail, &text ); #else char *text = "no-user-modification attribute type"; rc = add_created_attrs( op, e ); @@ -307,6 +315,7 @@ static int slap_mods2entry( Attribute *attr; assert( mods->sml_op == LDAP_MOD_ADD ); + assert( mods->sml_desc != NULL ); attr = attr_find( (*e)->e_attrs, mods->sml_desc ); @@ -317,7 +326,12 @@ static int slap_mods2entry( attr = ch_calloc( 1, sizeof(Attribute) ); - /* should check for duplicates */ + /* move ad to attr structure */ + attr->a_desc = mods->sml_desc; + mods->sml_desc = NULL; + + /* move values to attr structure */ + /* should check for duplicates */ attr->a_vals = mods->sml_bvalues; mods->sml_bvalues = NULL; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 38f6038300..0921238ad6 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -235,7 +235,14 @@ do_modify( global_lastmod == ON)) && !update ) { #ifdef SLAPD_SCHEMA_NOT_COMPAT - rc = slap_mods_opattrs( op, &mods, &text ); + Modifications **modstail; + for( modstail = &mods; + *modstail != NULL; + modstail = &(*modstail)->sml_next ) + { + /* empty */ + } + rc = slap_mods_opattrs( op, modstail, &text ); #else char *text = "no-user-modification attribute type"; rc = add_modified_attrs( op, &mods ); @@ -303,16 +310,16 @@ int slap_modlist2mods( mod = (Modifications *) ch_calloc( 1, sizeof(Modifications) ); - ad = mod->sml_desc; - /* convert to attribute description */ - rc = slap_str2ad( ml->ml_type, &ad, text ); + rc = slap_str2ad( ml->ml_type, &mod->sml_desc, text ); if( rc != LDAP_SUCCESS ) { slap_mods_free( mod ); return rc; } + ad = mod->sml_desc; + if( slap_syntax_is_binary( ad->ad_type->sat_syntax ) && !slap_ad_is_binary( ad )) { @@ -405,6 +412,9 @@ int slap_mods_opattrs( int mop = op->o_tag == LDAP_REQ_ADD ? LDAP_MOD_ADD : LDAP_MOD_REPLACE; + assert( modtail != NULL ); + assert( *modtail == NULL ); + ldap_pvt_thread_mutex_lock( &gmtime_mutex ); ltm = gmtime( &now ); strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm ); diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index da8559e535..c10f50e94b 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -52,6 +52,7 @@ entry_schema_check( if ( (aoc = attr_find( e->e_attrs, ad_objectClass )) == NULL ) { Debug( LDAP_DEBUG_ANY, "No object class for entry (%s)\n", e->e_dn, 0, 0 ); + assert(0); *text = "no objectclass attribute"; return oldattrs != NULL