From 11236eae56b3e0464c1fe897a09bc8b4d70c7404 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 27 Aug 2002 01:55:09 +0000 Subject: [PATCH] Clean up some structuralObject checks to improve readability. Functionality not changed (excepting one error message). --- servers/slapd/modify.c | 23 +++++++++++------------ servers/slapd/schema_check.c | 11 ++++++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index f9d6181747..d0b81b15c7 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -589,18 +589,17 @@ int slap_mods_opattrs( if( rc != LDAP_SUCCESS ) { return rc; } - if ( tmpval.bv_len ) { - mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); - mod->sml_op = mop; - mod->sml_type.bv_val = NULL; - mod->sml_desc = slap_schema.si_ad_structuralObjectClass; - mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); - ber_dupbv( &mod->sml_bvalues[0], &tmpval ); - mod->sml_bvalues[1].bv_val = NULL; - assert( mod->sml_bvalues[0].bv_val ); - *modtail = mod; - modtail = &mod->sml_next; - } + + mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); + mod->sml_op = mop; + mod->sml_type.bv_val = NULL; + mod->sml_desc = slap_schema.si_ad_structuralObjectClass; + mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_bvalues[0], &tmpval ); + mod->sml_bvalues[1].bv_val = NULL; + assert( mod->sml_bvalues[0].bv_val ); + *modtail = mod; + modtail = &mod->sml_next; } if( SLAP_LASTMOD(be) ) { diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 67d8437eca..a6b6b98acc 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -177,8 +177,6 @@ entry_schema_check( rc = structural_class( aoc->a_vals, &nsc, &oc, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) { return rc; - } else if ( nsc.bv_len == 0 ) { - return LDAP_OBJECT_CLASS_VIOLATION; } *text = textbuf; @@ -541,8 +539,9 @@ int structural_class( } } - if( scp ) + if( scp ) { *scp = sc; + } if( sc == NULL ) { *text = "no structural object classes provided"; @@ -550,6 +549,12 @@ int structural_class( } *scbv = ocs[scn]; + + if( scbv->bv_len ) { + *text = "invalid structural object class"; + return LDAP_OBJECT_CLASS_VIOLATION; + } + return LDAP_SUCCESS; } -- 2.39.5