]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/value.c
Remove lint
[openldap] / servers / slapd / value.c
index 74434b6126b21df36a150844e067272788f1c0a4..0508b3590dd5681d59e3d85daf6cfedcc7384493 100644 (file)
@@ -87,6 +87,7 @@ value_normalize(
        }
 
        /* we only support equality matching of binary attributes */
+       /* This is suspect, flexible certificate matching will hit this */
        if( slap_ad_is_binary( ad ) && usage != SLAP_MR_EQUALITY ) {
                *text = "inappropriate binary matching";
                return LDAP_INAPPROPRIATE_MATCHING;
@@ -125,13 +126,15 @@ value_match(
        int *match,
        AttributeDescription *ad,
        MatchingRule *mr,
+       unsigned flags,
        struct berval *v1, /* stored value */
        void *v2, /* assertion */
        const char ** text )
 {
        int rc;
-       int usage = 0;
        struct berval *nv1 = NULL;
+       struct berval *nv2 = NULL;
+       Syntax *syntax;
 
        if( !mr->smr_match ) {
                return LDAP_INAPPROPRIATE_MATCHING;
@@ -146,36 +149,59 @@ value_match(
                }
        }
 
-       rc = (mr->smr_match)( match, usage,
+       if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) &&
+            mr->smr_convert ) {
+               rc = (mr->smr_convert)(v2,&nv2);
+               if ( rc != LDAP_SUCCESS ) {
+                 return LDAP_INVALID_SYNTAX;
+               }
+       }
+
+       rc = (mr->smr_match)( match, flags,
                ad->ad_type->sat_syntax,
                mr,
                nv1 != NULL ? nv1 : v1,
-               v2 );
+               nv2 != NULL ? nv2 : v2 );
        
        ber_bvfree( nv1 );
+       ber_bvfree( nv2 );
        return rc;
 }
 
 
-int value_find(
+int value_find_ex(
        AttributeDescription *ad,
+       unsigned flags,
        struct berval **vals,
        struct berval *val )
 {
        int     i;
        int rc;
        struct berval *nval = NULL;
+       struct berval *nval_tmp = NULL;
        MatchingRule *mr = ad->ad_type->sat_equality;
 
        if( mr == NULL || !mr->smr_match ) {
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
+       /* Take care of this here or ssyn_normalize later will hurt */
+       if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) &&
+            mr->smr_convert ) {
+               rc = (mr->smr_convert)(val,&nval);
+               if ( rc != LDAP_SUCCESS ) {
+                       return LDAP_INVALID_SYNTAX;
+               }
+       }
+
        if( mr->smr_syntax->ssyn_normalize ) {
                rc = mr->smr_syntax->ssyn_normalize(
-                       mr->smr_syntax, val, &nval );
+                       mr->smr_syntax, nval == NULL ? val : nval, &nval_tmp );
 
+               ber_bvfree(nval);
+               nval = nval_tmp;
                if( rc != LDAP_SUCCESS ) {
+                       ber_bvfree(nval);
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
        }
@@ -184,14 +210,17 @@ int value_find(
                int match;
                const char *text;
 
-               rc = value_match( &match, ad, mr, vals[i],
-                       nval == NULL ? val : nval, &text );
+               /* We did convert, so keep value_match from trying */
+               rc = value_match( &match, ad, mr,
+                       flags & !SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
+                       vals[i], nval == NULL ? val : nval, &text );
 
-               if( rc == LDAP_SUCCESS && match == 0 )
-               {
+               if( rc == LDAP_SUCCESS && match == 0 ) {
+                       ber_bvfree( nval );
                        return LDAP_SUCCESS;
                }
        }
 
+       ber_bvfree( nval );
        return LDAP_NO_SUCH_ATTRIBUTE;
 }