]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/filter.c
cleanup bind
[openldap] / servers / slapd / filter.c
index 45a8d190e9b343bb9488670d3cb149dd4ab92356..cbb0389cc62ecfea4a6296911cd978c5d06a3039 100644 (file)
@@ -26,10 +26,6 @@ static int   get_substring_filter(
        Filter *f,
        const char **text );
 
-static int filter_escape_value(
-       struct berval *in,
-       struct berval *out );
-
 static void simple_vrFilter2bv(
        ValuesReturnFilter *f,
        struct berval *fstr );
@@ -414,6 +410,15 @@ get_substring_filter(
                        goto return_error;
                }
 
+#ifdef SLAP_NVALUES
+               /* validate/normalize using equality matching rule validator! */
+               rc = asserted_value_validate_normalize(
+                       f->f_sub_desc, f->f_sub_desc->ad_type->sat_equality,
+                       usage, &value, &bv, text );
+               if( rc != LDAP_SUCCESS ) {
+                       goto return_error;
+               }
+#else
                /* validate using equality matching rule validator! */
                rc = value_validate( f->f_sub_desc->ad_type->sat_equality,
                        &value, text );
@@ -426,6 +431,7 @@ get_substring_filter(
                if( rc != LDAP_SUCCESS ) {
                        goto return_error;
                }
+#endif
 
                value = bv;
 
@@ -602,7 +608,7 @@ filter2bv( Filter *f, struct berval *fstr )
 
                fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)",
                        f->f_av_desc->ad_cname.bv_val,
@@ -616,7 +622,7 @@ filter2bv( Filter *f, struct berval *fstr )
 
                fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(>=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)",
                        f->f_av_desc->ad_cname.bv_val,
@@ -630,7 +636,7 @@ filter2bv( Filter *f, struct berval *fstr )
 
                fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(<=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)",
                        f->f_av_desc->ad_cname.bv_val,
@@ -644,7 +650,7 @@ filter2bv( Filter *f, struct berval *fstr )
 
                fstr->bv_len = f->f_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(~=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)",
                        f->f_av_desc->ad_cname.bv_val,
@@ -655,7 +661,7 @@ filter2bv( Filter *f, struct berval *fstr )
        case LDAP_FILTER_SUBSTRINGS:
                fstr->bv_len = f->f_sub_desc->ad_cname.bv_len +
                        ( sizeof("(=*)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 128 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 128 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        f->f_sub_desc->ad_cname.bv_val );
@@ -710,7 +716,7 @@ filter2bv( Filter *f, struct berval *fstr )
        case LDAP_FILTER_PRESENT:
                fstr->bv_len = f->f_desc->ad_cname.bv_len +
                        ( sizeof("(=*)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        f->f_desc->ad_cname.bv_val );
@@ -720,7 +726,7 @@ filter2bv( Filter *f, struct berval *fstr )
        case LDAP_FILTER_OR:
        case LDAP_FILTER_NOT:
                fstr->bv_len = sizeof("(%)") - 1;
-               fstr->bv_val = malloc( fstr->bv_len + 128 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 128 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
                        f->f_choice == LDAP_FILTER_AND ? '&' :
@@ -757,7 +763,7 @@ filter2bv( Filter *f, struct berval *fstr )
                        ( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) +
                        ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) +
                        tmp.bv_len + ( sizeof("(:=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
                        ad.bv_val,
@@ -787,7 +793,8 @@ filter2bv( Filter *f, struct berval *fstr )
        }
 }
 
-static int filter_escape_value(
+int
+filter_escape_value(
        struct berval *in,
        struct berval *out )
 {
@@ -1141,7 +1148,7 @@ vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
        }
 
        fstr->bv_len = sizeof("()") - 1;
-       fstr->bv_val = malloc( fstr->bv_len + 128 );
+       fstr->bv_val = ch_malloc( fstr->bv_len + 128 );
 
        snprintf( fstr->bv_val, fstr->bv_len + 1, "()");
 
@@ -1177,7 +1184,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
 
                fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)",
                        vrf->vrf_av_desc->ad_cname.bv_val,
@@ -1191,7 +1198,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
 
                fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(>=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)",
                        vrf->vrf_av_desc->ad_cname.bv_val,
@@ -1205,7 +1212,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
 
                fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(<=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)",
                        vrf->vrf_av_desc->ad_cname.bv_val,
@@ -1219,7 +1226,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
 
                fstr->bv_len = vrf->vrf_av_desc->ad_cname.bv_len +
                        tmp.bv_len + ( sizeof("(~=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)",
                        vrf->vrf_av_desc->ad_cname.bv_val,
@@ -1230,7 +1237,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
        case LDAP_FILTER_SUBSTRINGS:
                fstr->bv_len = vrf->vrf_sub_desc->ad_cname.bv_len +
                        ( sizeof("(=*)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 128 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 128 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        vrf->vrf_sub_desc->ad_cname.bv_val );
@@ -1286,7 +1293,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
        case LDAP_FILTER_PRESENT:
                fstr->bv_len = vrf->vrf_desc->ad_cname.bv_len +
                        ( sizeof("(=*)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        vrf->vrf_desc->ad_cname.bv_val );
@@ -1307,7 +1314,7 @@ simple_vrFilter2bv( ValuesReturnFilter *vrf, struct berval *fstr )
                        ( vrf->vrf_mr_dnattrs ? sizeof(":dn")-1 : 0 ) +
                        ( vrf->vrf_mr_rule_text.bv_len ? vrf->vrf_mr_rule_text.bv_len+1 : 0 ) +
                        tmp.bv_len + ( sizeof("(:=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
                        ad.bv_val,
@@ -1423,6 +1430,15 @@ get_substring_vrFilter(
                        goto return_error;
                }
 
+#ifdef SLAP_NVALUES
+               /* validate/normalize using equality matching rule validator! */
+               rc = asserted_value_validate_normalize(
+                       vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_equality,
+                       usage, &value, &bv, text );
+               if( rc != LDAP_SUCCESS ) {
+                       goto return_error;
+               }
+#else
                /* valiate using equality matching rule validator! */
                rc = value_validate( vrf->vrf_sub_desc->ad_type->sat_equality,
                        &value, text );
@@ -1435,6 +1451,7 @@ get_substring_vrFilter(
                if( rc != LDAP_SUCCESS ) {
                        goto return_error;
                }
+#endif
 
                value = bv;