]> git.sur5r.net Git - openldap/commitdiff
Explicitly mark attribute/assertion syntax of values to be normalized
authorKurt Zeilenga <kurt@openldap.org>
Sat, 18 Oct 2003 06:18:05 +0000 (06:18 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 18 Oct 2003 06:18:05 +0000 (06:18 +0000)
servers/slapd/attr.c
servers/slapd/back-monitor/log.c
servers/slapd/dn.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/schema_check.c
servers/slapd/schema_init.c
servers/slapd/slap.h
servers/slapd/value.c

index 4bb4e2a53ae22c04a32df45461d8e37b82dd6c91..a552ebad241279b85f2c7827e0ec79ac17caad96 100644 (file)
@@ -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 );
index 6b072071b27ceb62f34dd9c0d6263ef8f5cc6a36..7b2d4c0beefd446dad1d95e529b7cee3b2ba7040 100644 (file)
@@ -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,
index c1c1ba52cfa83330ec3ad4bbdd880318cdf0faff..348336f8a6da866d0bb10f42fb12ee951175ab20 100644 (file)
@@ -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
index dda14a3127b11572f8a322739ca9e1d6ca370d91..d1b72b4aee3da3bee5fcbb90a2fbed5500f2cbd0 100644 (file)
@@ -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 );
index f780dd3aa26ee2f1479ef4b518f27ad2e5d7d150..5ec1418fbbae2e68d76c132f6ab307cca55903a0 100644 (file)
@@ -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],
index c15d78eb37efb94fc8f098b5fb1ede14b465fcf7..1426e890a418fe9da5d43f68217aad2b6be0add7 100644 (file)
@@ -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",
index 8740744507e0ae11c6e3f26fceab760af0747846..ee09d0d515d9962110b5933d7e36b7121d4f7a10 100644 (file)
@@ -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;
index 30465dffdd4ab2e90162ce0559dbcd5d531e6207..98b0ffa002699bda9f9c11495c104536d9595b71 100644 (file)
@@ -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
index cf0129738f7baba6f99c1552391f208ddffaf066..01ee39b08a0ea4ac7306490795575795984a91e8 100644 (file)
@@ -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 );