]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/filter.c
cleanup bind
[openldap] / servers / slapd / filter.c
index 9c07d2d6acf4e102897893f578b185a5c4182c13..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 );
@@ -612,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,
@@ -626,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,
@@ -640,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,
@@ -654,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,
@@ -665,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 );
@@ -720,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 );
@@ -730,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 ? '&' :
@@ -767,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,
@@ -797,7 +793,8 @@ filter2bv( Filter *f, struct berval *fstr )
        }
 }
 
-static int filter_escape_value(
+int
+filter_escape_value(
        struct berval *in,
        struct berval *out )
 {
@@ -1151,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, "()");
 
@@ -1187,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,
@@ -1201,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,
@@ -1215,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,
@@ -1229,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,
@@ -1240,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 );
@@ -1296,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 );
@@ -1317,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,