From: Pierangelo Masarati Date: Fri, 25 Nov 2005 12:16:27 +0000 (+0000) Subject: cleanup filter escaping X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~700 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f86543c7709c74e2311ab4b302a595155a9f90b3;p=openldap cleanup filter escaping --- diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 0d4fe706b1..623c2fb317 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -366,10 +366,10 @@ ldap_search_s( } static char escape[128] = { - 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, @@ -384,7 +384,7 @@ static char escape[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 1 }; #define NEEDFLTESCAPE(c) ((c) & 0x80 || escape[ (unsigned)(c) ]) diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 7c001fbb2f..58e506d3e5 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -1912,7 +1912,7 @@ backsql_search( Operation *op, SlapReply *rs ) Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): " "base=\"%s\", filter=\"%s\", scope=%d,", op->o_req_ndn.bv_val, - op->ors_filterstr.bv_val ? op->ors_filterstr.bv_val : "(no filter)", + op->ors_filterstr.bv_val, op->ors_scope ); Debug( LDAP_DEBUG_TRACE, " deref=%d, attrsonly=%d, " "attributes to load: %s\n", diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index eea855a4ae..4f7b151664 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -45,11 +45,6 @@ static int get_ssa( SubstringsAssertion **s, const char **text ); -static int filter_escape_value_x( - struct berval *in, - struct berval *out, - void *ctx ); - static void simple_vrFilter2bv( Operation *op, ValuesReturnFilter *f, @@ -782,42 +777,6 @@ filter2bv( Filter *f, struct berval *fstr ) filter2bv_x( &op, f, fstr ); } -static int -filter_escape_value_x( - struct berval *in, - struct berval *out, - void *ctx ) -{ - ber_len_t i; - assert( in != NULL ); - assert( out != NULL ); - - i = in->bv_len * 3 + 1; - out->bv_val = ctx ? slap_sl_malloc( i, ctx ) : ch_malloc( i ); - out->bv_len = 0; - - for( i=0; i < in->bv_len ; i++ ) { - if( FILTER_ESCAPE(in->bv_val[i]) ) { - out->bv_val[out->bv_len++] = SLAP_ESCAPE_CHAR; - out->bv_val[out->bv_len++] = SLAP_ESCAPE_HI( in->bv_val[i] ); - out->bv_val[out->bv_len++] = SLAP_ESCAPE_LO( in->bv_val[i] ); - } else { - out->bv_val[out->bv_len++] = in->bv_val[i]; - } - } - - out->bv_val[out->bv_len] = '\0'; - return LDAP_SUCCESS; -} - -int -filter_escape_value( - struct berval *in, - struct berval *out ) -{ - return filter_escape_value_x( in, out, NULL ); -} - static int get_simple_vrFilter( Operation *op, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 14a7b8ea77..6727669d99 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -913,8 +913,8 @@ LDAP_SLAPD_F (void) vrFilter_free LDAP_P(( Operation *op, ValuesReturnFilter *f LDAP_SLAPD_F (void) vrFilter2bv LDAP_P(( Operation *op, ValuesReturnFilter *f, struct berval *fstr )); LDAP_SLAPD_F (int) filter_has_subordinates LDAP_P(( Filter *filter )); -LDAP_SLAPD_F (int) filter_escape_value LDAP_P(( struct berval *in, - struct berval *out )); +#define filter_escape_value( in, out ) ldap_bv2escaped_filter_value_x( (in), (out), 0, NULL ) +#define filter_escape_value_x( in, out, ctx ) ldap_bv2escaped_filter_value_x( (in), (out), 0, ctx ) /* * filterentry.c