From: Kurt Zeilenga Date: Sat, 18 Oct 2003 06:18:05 +0000 (+0000) Subject: Explicitly mark attribute/assertion syntax of values to be normalized X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~553 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=aa225c2c70577858444e9dadd6be91b79f716905;p=openldap Explicitly mark attribute/assertion syntax of values to be normalized --- diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 4bb4e2a53a..a552ebad24 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -162,7 +162,9 @@ attr_merge_normalize( BerVarray nvals = NULL; int rc; - if ( desc->ad_type->sat_equality && desc->ad_type->sat_equality->smr_normalize ) { + if ( desc->ad_type->sat_equality && + desc->ad_type->sat_equality->smr_normalize ) + { int i; for ( i = 0; vals[i].bv_val; i++ ); @@ -170,7 +172,7 @@ attr_merge_normalize( nvals = sl_calloc( sizeof(struct berval), i + 1, memctx ); for ( i = 0; vals[i].bv_val; i++ ) { rc = (*desc->ad_type->sat_equality->smr_normalize)( - 0, + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, &vals[i], &nvals[i], memctx ); @@ -235,9 +237,11 @@ attr_merge_normalize_one( struct berval *nvalp; int rc; - if ( desc->ad_type->sat_equality && desc->ad_type->sat_equality->smr_normalize ) { + if ( desc->ad_type->sat_equality && + desc->ad_type->sat_equality->smr_normalize ) + { rc = (*desc->ad_type->sat_equality->smr_normalize)( - 0, + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, val, &nval, memctx ); diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 6b072071b2..7b2d4c0bee 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -122,7 +122,7 @@ monitor_subsys_log_init( int rc; rc = (*mi->mi_ad_managedInfo->ad_type->sat_equality->smr_normalize)( - 0, + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, mi->mi_ad_managedInfo->ad_type->sat_syntax, mi->mi_ad_managedInfo->ad_type->sat_equality, &int_2_level[ i ].s, diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index c1c1ba52cf..348336f8a6 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -314,7 +314,7 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) * if value is empty, use empty_bv */ rc = ( *normf )( - 0, + SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, ad->ad_type->sat_syntax, mr, ava->la_value.bv_len diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index dda14a3127..d1b72b4aee 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -734,7 +734,7 @@ int slap_mods_check( for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) { rc = ad->ad_type->sat_equality->smr_normalize( - 0, + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, ad->ad_type->sat_syntax, ad->ad_type->sat_equality, &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index f780dd3aa2..5ec1418fbb 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -495,7 +495,7 @@ slap_modrdn2mods( if( desc->ad_type->sat_equality->smr_normalize) { mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; (void) (*desc->ad_type->sat_equality->smr_normalize)( - SLAP_MR_EQUALITY, + SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, &mod_tmp->sml_values[0], @@ -564,7 +564,7 @@ slap_modrdn2mods( if( desc->ad_type->sat_equality->smr_normalize) { mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; (void) (*desc->ad_type->sat_equality->smr_normalize)( - SLAP_MR_EQUALITY, + SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, &mod_tmp->sml_values[0], diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index c15d78eb37..1426e890a4 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -873,9 +873,9 @@ entry_naming_check( } if ( value_find_ex( desc, - SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, - attr->a_nvals, - &ava->la_value, NULL ) != 0 ) + SLAP_MR_VALUE_OF_ASSERTION_SYNTAX| + SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, + attr->a_nvals, &ava->la_value, NULL ) != 0 ) { snprintf( textbuf, textlen, "value of naming attribute '%s' is not present in entry", diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 8740744507..ee09d0d515 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -861,6 +861,8 @@ uniqueMemberNormalize( struct berval out; int rc; + assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage )); + ber_dupbv( &out, val ); if( out.bv_len != 0 ) { struct berval uid = { 0, NULL }; @@ -1170,6 +1172,8 @@ UTF8StringNormalize( int flags; int i, wasspace; + assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use )); + if( val->bv_val == NULL ) { /* assume we're dealing with a syntax (e.g., UTF8String) * which allows empty strings @@ -1463,6 +1467,8 @@ telephoneNumberNormalize( { char *p, *q; + assert( SLAP_MR_IS_VALUE_OF_SYNTAX( usage )); + /* validator should have refused an empty string */ assert( val->bv_len ); @@ -1712,6 +1718,8 @@ IA5StringNormalize( assert( val->bv_len ); + assert( SLAP_MR_IS_VALUE_OF_SYNTAX( use )); + p = val->bv_val; /* Ignore initial whitespace */ @@ -2119,11 +2127,12 @@ certificateExactNormalize( if( val->bv_len == 0 ) goto done; - if( val->bv_val[0] != LBER_SEQUENCE ) { - /* assume serialNumberAndIssuer */ + if( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX(usage) ) { return serialNumberAndIssuerNormalize(0,NULL,NULL,val,normalized,ctx); } + assert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) ); + p = val->bv_val; xcert = d2i_X509( NULL, &p, val->bv_len); if( xcert == NULL ) goto done; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 30465dffdd..98b0ffa002 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -451,11 +451,18 @@ typedef struct slap_matching_rule { */ #define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX 0x0001U #define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX 0x0002U +#define SLAP_MR_VALUE_OF_SYNTAX 0x0003U #define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \ ((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX ) #define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \ ((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX ) +#ifdef LDAP_DEBUG +#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) \ + ((usage) & SLAP_MR_VALUE_OF_SYNTAX) +#else +#define SLAP_MR_IS_VALUE_OF_SYNTAX( usage ) (1) +#endif /* either or both the asserted value or attribute value * may be provided in normalized form diff --git a/servers/slapd/value.c b/servers/slapd/value.c index cf0129738f..01ee39b08a 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -163,7 +163,8 @@ int asserted_value_validate_normalize( } if( mr->smr_normalize ) { - rc = (mr->smr_normalize)( usage, + rc = (mr->smr_normalize)( + usage|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, ad ? ad->ad_type->sat_syntax : NULL, mr, in, out, ctx ); @@ -238,7 +239,7 @@ int value_find_ex( mr->smr_normalize ) { rc = (mr->smr_normalize)( - flags & (SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK), + flags & (SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK|SLAP_MR_VALUE_OF_SYNTAX), ad ? ad->ad_type->sat_syntax : NULL, mr, val, &nval, ctx );