Changed ma_rule_text to struct berval.

Changed get_filter to struct bervals
This commit is contained in:
Howard Chu 2001-12-26 13:47:10 +00:00
parent 327f253183
commit 15f630545a
6 changed files with 148 additions and 120 deletions

View file

@ -172,16 +172,16 @@ parse_acl(
} }
} else if ( strcasecmp( style, "base" ) == 0 ) { } else if ( strcasecmp( style, "base" ) == 0 ) {
a->acl_dn_style = ACL_STYLE_BASE; a->acl_dn_style = ACL_STYLE_BASE;
ber_str2bv( right, 1, &a->acl_dn_pat ); ber_str2bv( right, 0, 1, &a->acl_dn_pat );
} else if ( strcasecmp( style, "one" ) == 0 ) { } else if ( strcasecmp( style, "one" ) == 0 ) {
a->acl_dn_style = ACL_STYLE_ONE; a->acl_dn_style = ACL_STYLE_ONE;
ber_str2bv( right, 1, &a->acl_dn_pat ); ber_str2bv( right, 0, 1, &a->acl_dn_pat );
} else if ( strcasecmp( style, "subtree" ) == 0 ) { } else if ( strcasecmp( style, "subtree" ) == 0 ) {
a->acl_dn_style = ACL_STYLE_SUBTREE; a->acl_dn_style = ACL_STYLE_SUBTREE;
ber_str2bv( right, 1, &a->acl_dn_pat ); ber_str2bv( right, 0, 1, &a->acl_dn_pat );
} else if ( strcasecmp( style, "children" ) == 0 ) { } else if ( strcasecmp( style, "children" ) == 0 ) {
a->acl_dn_style = ACL_STYLE_CHILDREN; a->acl_dn_style = ACL_STYLE_CHILDREN;
ber_str2bv( right, 1, &a->acl_dn_pat ); ber_str2bv( right, 0, 1, &a->acl_dn_pat );
} else { } else {
fprintf( stderr, fprintf( stderr,
"%s: line %d: unknown dn style \"%s\" in to clause\n", "%s: line %d: unknown dn style \"%s\" in to clause\n",
@ -296,36 +296,39 @@ parse_acl(
bv.bv_len = 1; bv.bv_len = 1;
} else if ( strcasecmp( argv[i], "anonymous" ) == 0 ) { } else if ( strcasecmp( argv[i], "anonymous" ) == 0 ) {
bv.bv_val = ch_strdup( "anonymous" ); ber_str2bv("anonymous",
bv.bv_len = sizeof("anonymous")-1; sizeof("anonymous")-1,
1, &bv);
} else if ( strcasecmp( argv[i], "self" ) == 0 ) { } else if ( strcasecmp( argv[i], "self" ) == 0 ) {
bv.bv_val = ch_strdup( "self" ); ber_str2bv("self",
bv.bv_len = sizeof("self")-1; sizeof("self")-1,
1, &bv);
} else if ( strcasecmp( argv[i], "users" ) == 0 ) { } else if ( strcasecmp( argv[i], "users" ) == 0 ) {
bv.bv_val = ch_strdup( "users" ); ber_str2bv("users",
bv.bv_len = sizeof("users")-1; sizeof("users")-1,
1, &bv);
} else if ( strcasecmp( left, "dn" ) == 0 ) { } else if ( strcasecmp( left, "dn" ) == 0 ) {
if ( sty == ACL_STYLE_REGEX ) { if ( sty == ACL_STYLE_REGEX ) {
b->a_dn_style = ACL_STYLE_REGEX; b->a_dn_style = ACL_STYLE_REGEX;
if( right == NULL ) { if( right == NULL ) {
/* no '=' */ /* no '=' */
bv.bv_val = ch_strdup( "users" ); ber_str2bv("users",
bv.bv_len = sizeof("users")-1; sizeof("users")-1,
1, &bv);
} else if (*right == '\0' ) { } else if (*right == '\0' ) {
/* dn="" */ /* dn="" */
bv.bv_val = ch_strdup( "anonymous" ); ber_str2bv("anonymous",
bv.bv_len = sizeof("anonymous")-1; sizeof("anonymous")-1,
1, &bv);
} else if ( strcmp( right, "*" ) == 0 ) { } else if ( strcmp( right, "*" ) == 0 ) {
/* dn=* */ /* dn=* */
/* any or users? users for now */ /* any or users? users for now */
bv.bv_val = ch_strdup( "users" ); ber_str2bv("users",
bv.bv_len = sizeof("users")-1; sizeof("users")-1,
1, &bv);
} else if ( strcmp( right, ".+" ) == 0 } else if ( strcmp( right, ".+" ) == 0
|| strcmp( right, "^.+" ) == 0 || strcmp( right, "^.+" ) == 0
|| strcmp( right, ".+$" ) == 0 || strcmp( right, ".+$" ) == 0
@ -333,9 +336,9 @@ parse_acl(
|| strcmp( right, ".+$$" ) == 0 || strcmp( right, ".+$$" ) == 0
|| strcmp( right, "^.+$$" ) == 0 ) || strcmp( right, "^.+$$" ) == 0 )
{ {
bv.bv_val = ch_strdup( "users" ); ber_str2bv("users",
bv.bv_len = sizeof("users")-1; sizeof("users")-1,
1, &bv);
} else if ( strcmp( right, ".*" ) == 0 } else if ( strcmp( right, ".*" ) == 0
|| strcmp( right, "^.*" ) == 0 || strcmp( right, "^.*" ) == 0
|| strcmp( right, ".*$" ) == 0 || strcmp( right, ".*$" ) == 0
@ -343,8 +346,9 @@ parse_acl(
|| strcmp( right, ".*$$" ) == 0 || strcmp( right, ".*$$" ) == 0
|| strcmp( right, "^.*$$" ) == 0 ) || strcmp( right, "^.*$$" ) == 0 )
{ {
bv.bv_val = ch_strdup( "*" ); ber_str2bv("*",
bv.bv_len = 1; sizeof("*")-1,
1, &bv);
} else { } else {
bv.bv_val = right; bv.bv_val = right;
@ -358,7 +362,7 @@ parse_acl(
acl_usage(); acl_usage();
} else { } else {
ber_str2bv( right, 1, &bv ); ber_str2bv( right, 0, 1, &bv );
} }
} else { } else {
@ -470,7 +474,7 @@ parse_acl(
b->a_group_pat = bv; b->a_group_pat = bv;
} else { } else {
struct berval *ndn = NULL; struct berval *ndn = NULL;
ber_str2bv( right, 0, &bv ); ber_str2bv( right, 0, 0, &bv );
dnNormalize( NULL, &bv, &ndn ); dnNormalize( NULL, &bv, &ndn );
b->a_group_pat = *ndn; b->a_group_pat = *ndn;
free(ndn); free(ndn);
@ -702,7 +706,7 @@ parse_acl(
} }
b->a_set_style = sty; b->a_set_style = sty;
ber_str2bv( right, 1, &b->a_set_pat ); ber_str2bv( right, 0, 1, &b->a_set_pat );
continue; continue;
} }

View file

@ -18,14 +18,14 @@ static int get_filter_list(
Connection *conn, Connection *conn,
BerElement *ber, BerElement *ber,
Filter **f, Filter **f,
char **fstr, struct berval *fstr,
const char **text ); const char **text );
static int get_substring_filter( static int get_substring_filter(
Connection *conn, Connection *conn,
BerElement *ber, BerElement *ber,
Filter *f, Filter *f,
char **fstr, struct berval *fstr,
const char **text ); const char **text );
static int filter_escape_value( static int filter_escape_value(
@ -37,14 +37,14 @@ get_filter(
Connection *conn, Connection *conn,
BerElement *ber, BerElement *ber,
Filter **filt, Filter **filt,
char **fstr, struct berval *fstr,
const char **text ) const char **text )
{ {
ber_tag_t tag; ber_tag_t tag;
ber_len_t len; ber_len_t len;
int err; int err;
Filter *f; Filter *f;
char *ftmp = NULL; struct berval ftmp = { 0, NULL };
struct berval escaped; struct berval escaped;
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
@ -97,7 +97,7 @@ get_filter(
f->f_next = NULL; f->f_next = NULL;
err = LDAP_SUCCESS; err = LDAP_SUCCESS;
*fstr = NULL; *fstr = ftmp;
f->f_choice = tag; f->f_choice = tag;
switch ( f->f_choice ) { switch ( f->f_choice ) {
@ -117,11 +117,13 @@ get_filter(
filter_escape_value( f->f_av_value, &escaped ); filter_escape_value( f->f_av_value, &escaped );
*fstr = ch_malloc( sizeof("(=)") fstr->bv_len = sizeof("(=)")-1
+ f->f_av_desc->ad_cname.bv_len + f->f_av_desc->ad_cname.bv_len
+ escaped.bv_len ); + escaped.bv_len;
sprintf( *fstr, "(%s=%s)", fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( fstr->bv_val, "(%s=%s)",
f->f_av_desc->ad_cname.bv_val, f->f_av_desc->ad_cname.bv_val,
escaped.bv_val ); escaped.bv_val );
@ -152,11 +154,13 @@ get_filter(
filter_escape_value( f->f_av_value, &escaped ); filter_escape_value( f->f_av_value, &escaped );
*fstr = ch_malloc( sizeof("(>=)") fstr->bv_len = sizeof("(>=)")-1
+ f->f_av_desc->ad_cname.bv_len + f->f_av_desc->ad_cname.bv_len
+ escaped.bv_len ); + escaped.bv_len;
sprintf( *fstr, "(%s>=%s)", fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( fstr->bv_val, "(%s>=%s)",
f->f_av_desc->ad_cname.bv_val, f->f_av_desc->ad_cname.bv_val,
escaped.bv_val ); escaped.bv_val );
@ -178,11 +182,13 @@ get_filter(
filter_escape_value( f->f_av_value, &escaped ); filter_escape_value( f->f_av_value, &escaped );
*fstr = ch_malloc( sizeof("(<=)") fstr->bv_len = sizeof("(<=)")-1
+ f->f_av_desc->ad_cname.bv_len + f->f_av_desc->ad_cname.bv_len
+ escaped.bv_len ); + escaped.bv_len;
sprintf( *fstr, "(%s<=%s)", fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( fstr->bv_val, "(%s<=%s)",
f->f_av_desc->ad_cname.bv_val, f->f_av_desc->ad_cname.bv_val,
escaped.bv_val ); escaped.bv_val );
@ -211,7 +217,8 @@ get_filter(
/* unrecognized attribute description or other error */ /* unrecognized attribute description or other error */
f->f_choice = SLAPD_FILTER_COMPUTED; f->f_choice = SLAPD_FILTER_COMPUTED;
f->f_result = LDAP_COMPARE_FALSE; f->f_result = LDAP_COMPARE_FALSE;
*fstr = ch_strdup( "(unrecogized=*)" ); ber_str2bv("(unrecognized=*)",
sizeof("(unrecognized=*)")-1, 1, fstr);
ch_free( type.bv_val ); ch_free( type.bv_val );
err = LDAP_SUCCESS; err = LDAP_SUCCESS;
break; break;
@ -219,9 +226,10 @@ get_filter(
ch_free( type.bv_val ); ch_free( type.bv_val );
*fstr = ch_malloc( sizeof("(=*)") fstr->bv_len = sizeof("(=*)") - 1
+ f->f_desc->ad_cname.bv_len ); + f->f_desc->ad_cname.bv_len;
sprintf( *fstr, "(%s=*)", fstr->bv_val = ch_malloc( fstr->bv_len + 1);
sprintf( fstr->bv_val, "(%s=*)",
f->f_desc->ad_cname.bv_val ); f->f_desc->ad_cname.bv_val );
} break; } break;
@ -240,11 +248,12 @@ get_filter(
filter_escape_value( f->f_av_value, &escaped ); filter_escape_value( f->f_av_value, &escaped );
*fstr = ch_malloc( sizeof("(~=)") fstr->bv_len = sizeof("(~=)") - 1
+ f->f_av_desc->ad_cname.bv_len + f->f_av_desc->ad_cname.bv_len
+ escaped.bv_len ); + escaped.bv_len;
fstr->bv_val = ch_malloc( fstr->bv_len + 1);
sprintf( *fstr, "(%s~=%s)", sprintf( fstr->bv_val, "(%s~=%s)",
f->f_av_desc->ad_cname.bv_val, f->f_av_desc->ad_cname.bv_val,
escaped.bv_val ); escaped.bv_val );
@ -262,10 +271,10 @@ get_filter(
if ( err != LDAP_SUCCESS ) { if ( err != LDAP_SUCCESS ) {
break; break;
} }
*fstr = ch_malloc( sizeof("(&)") fstr->bv_len = sizeof("(&)") - 1 + ftmp.bv_len;
+ ( ftmp == NULL ? 0 : strlen( ftmp ) ) ); fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( *fstr, "(&%s)", sprintf( fstr->bv_val, "(&%s)",
ftmp == NULL ? "" : ftmp ); ftmp.bv_len ? ftmp.bv_val : "" );
break; break;
case LDAP_FILTER_OR: case LDAP_FILTER_OR:
@ -279,10 +288,10 @@ get_filter(
if ( err != LDAP_SUCCESS ) { if ( err != LDAP_SUCCESS ) {
break; break;
} }
*fstr = ch_malloc( sizeof("(!)") fstr->bv_len = sizeof("(|)") - 1 + ftmp.bv_len;
+ ( ftmp == NULL ? 0 : strlen( ftmp ) ) ); fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( *fstr, "(|%s)", sprintf( fstr->bv_val, "(|%s)",
ftmp == NULL ? "" : ftmp ); ftmp.bv_len ? ftmp.bv_val : "" );
break; break;
case LDAP_FILTER_NOT: case LDAP_FILTER_NOT:
@ -297,10 +306,10 @@ get_filter(
if ( err != LDAP_SUCCESS ) { if ( err != LDAP_SUCCESS ) {
break; break;
} }
*fstr = ch_malloc( sizeof("(!)") fstr->bv_len = sizeof("(!)") - 1 + ftmp.bv_len;
+ ( ftmp == NULL ? 0 : strlen( ftmp ) ) ); fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( *fstr, "(!%s)", sprintf( fstr->bv_val, "(!%s)",
ftmp == NULL ? "" : ftmp ); ftmp.bv_len ? ftmp.bv_val : "" );
break; break;
case LDAP_FILTER_EXT: case LDAP_FILTER_EXT:
@ -320,16 +329,17 @@ get_filter(
filter_escape_value( f->f_mr_value, &escaped ); filter_escape_value( f->f_mr_value, &escaped );
*fstr = ch_malloc( sizeof("(:dn::=)") fstr->bv_len = sizeof("(:dn::=)") - 1
+ (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_len : 0) + (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_len : 0)
+ (f->f_mr_rule_text ? strlen(f->f_mr_rule_text) : 0) + f->f_mr_rule_text.bv_len
+ escaped.bv_len ); + escaped.bv_len;
sprintf( *fstr, "(%s%s%s%s:=%s)", fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( fstr->bv_val, "(%s%s%s%s:=%s)",
(f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_val : ""), (f->f_mr_desc ? f->f_mr_desc->ad_cname.bv_val : ""),
(f->f_mr_dnattrs ? ":dn" : ""), (f->f_mr_dnattrs ? ":dn" : ""),
(f->f_mr_rule_text ? ":" : ""), (f->f_mr_rule_text.bv_len ? ":" : ""),
(f->f_mr_rule_text ? f->f_mr_rule_text : ""), (f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : ""),
escaped.bv_val ); escaped.bv_val );
ber_memfree( escaped.bv_val ); ber_memfree( escaped.bv_val );
@ -347,22 +357,24 @@ get_filter(
#endif #endif
f->f_choice = SLAPD_FILTER_COMPUTED; f->f_choice = SLAPD_FILTER_COMPUTED;
f->f_result = SLAPD_COMPARE_UNDEFINED; f->f_result = SLAPD_COMPARE_UNDEFINED;
*fstr = ch_strdup( "(undefined)" ); ber_str2bv( "(undefined)", sizeof("(undefined)") - 1,
1, fstr );
break; break;
} }
free( ftmp ); free( ftmp.bv_val );
if ( err != LDAP_SUCCESS ) { if ( err != LDAP_SUCCESS ) {
if ( *fstr != NULL ) { if ( fstr->bv_val != NULL ) {
free( *fstr ); free( fstr->bv_val );
} }
if( err != SLAPD_DISCONNECT ) { if( err != SLAPD_DISCONNECT ) {
/* ignore error */ /* ignore error */
f->f_choice = SLAPD_FILTER_COMPUTED; f->f_choice = SLAPD_FILTER_COMPUTED;
f->f_result = SLAPD_COMPARE_UNDEFINED; f->f_result = SLAPD_COMPARE_UNDEFINED;
*fstr = ch_strdup( "(badfilter)" ); ber_str2bv( "(badfilter)", sizeof("(badfilter)") - 1,
1, fstr );
err = LDAP_SUCCESS; err = LDAP_SUCCESS;
*filt = f; *filt = f;
@ -384,14 +396,15 @@ get_filter(
static int static int
get_filter_list( Connection *conn, BerElement *ber, get_filter_list( Connection *conn, BerElement *ber,
Filter **f, char **fstr, Filter **f, struct berval *fstr,
const char **text ) const char **text )
{ {
Filter **new; Filter **new;
int err; int err;
ber_tag_t tag; ber_tag_t tag;
ber_len_t len; ber_len_t len;
char *last, *ftmp; char *last;
struct berval ftmp;
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@ -399,7 +412,6 @@ get_filter_list( Connection *conn, BerElement *ber,
#else #else
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 );
#endif #endif
*fstr = NULL;
new = f; new = f;
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) ) tag = ber_next_element( ber, &len, last ) )
@ -408,13 +420,15 @@ get_filter_list( Connection *conn, BerElement *ber,
if ( err != LDAP_SUCCESS ) if ( err != LDAP_SUCCESS )
return( err ); return( err );
if ( *fstr == NULL ) { if ( !fstr->bv_len ) {
*fstr = ftmp; *fstr = ftmp;
} else { } else {
*fstr = ch_realloc( *fstr, strlen( *fstr ) + int i = fstr->bv_len;
strlen( ftmp ) + 1 ); fstr->bv_len += ftmp.bv_len;
strcat( *fstr, ftmp ); fstr->bv_val = ch_realloc( fstr->bv_val,
free( ftmp ); fstr->bv_len + 1 );
strcpy( fstr->bv_val+i, ftmp.bv_val );
free( ftmp.bv_val );
} }
new = &(*new)->f_next; new = &(*new)->f_next;
} }
@ -434,7 +448,7 @@ get_substring_filter(
Connection *conn, Connection *conn,
BerElement *ber, BerElement *ber,
Filter *f, Filter *f,
char **fstr, struct berval *fstr,
const char **text const char **text
) )
{ {
@ -469,7 +483,7 @@ get_substring_filter(
ch_free( f->f_sub ); ch_free( f->f_sub );
f->f_choice = SLAPD_FILTER_COMPUTED; f->f_choice = SLAPD_FILTER_COMPUTED;
f->f_result = SLAPD_COMPARE_UNDEFINED; f->f_result = SLAPD_COMPARE_UNDEFINED;
*fstr = ch_strdup( "(undefined)" ); ber_str2bv( "(undefined)", sizeof("(undefined)")-1, 1, fstr );
return LDAP_SUCCESS; return LDAP_SUCCESS;
} }
@ -477,11 +491,10 @@ get_substring_filter(
f->f_sub_any = NULL; f->f_sub_any = NULL;
f->f_sub_final = NULL; f->f_sub_final = NULL;
if( fstr ) { fstr->bv_len = sizeof("(=" /*)*/) - 1 +
*fstr = ch_malloc( sizeof("(=" /*)*/) + f->f_sub_desc->ad_cname.bv_len;
f->f_sub_desc->ad_cname.bv_len ); fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
sprintf( *fstr, "(%s=" /*)*/, f->f_sub_desc->ad_cname.bv_val ); sprintf( fstr->bv_val, "(%s=" /*)*/, f->f_sub_desc->ad_cname.bv_val );
}
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) ) tag = ber_next_element( ber, &len, last ) )
@ -560,11 +573,13 @@ get_substring_filter(
f->f_sub_initial = value; f->f_sub_initial = value;
if( fstr ) { if( fstr->bv_val ) {
int i = fstr->bv_len;
filter_escape_value( value, &escaped ); filter_escape_value( value, &escaped );
*fstr = ch_realloc( *fstr, fstr->bv_len += escaped.bv_len;
strlen( *fstr ) + escaped.bv_len + 1 ); fstr->bv_val = ch_realloc( fstr->bv_val,
strcat( *fstr, escaped.bv_val ); fstr->bv_len + 1 );
strcpy( fstr->bv_val+i, escaped.bv_val );
ber_memfree( escaped.bv_val ); ber_memfree( escaped.bv_val );
} }
break; break;
@ -588,12 +603,14 @@ get_substring_filter(
goto return_error; goto return_error;
} }
if( fstr ) { if( fstr->bv_val ) {
int i = fstr->bv_len;
filter_escape_value( value, &escaped ); filter_escape_value( value, &escaped );
*fstr = ch_realloc( *fstr, fstr->bv_len += escaped.bv_len + 2;
strlen( *fstr ) + escaped.bv_len + 2 ); fstr->bv_val = ch_realloc( fstr->bv_val,
strcat( *fstr, "*" ); fstr->bv_len + 1 );
strcat( *fstr, escaped.bv_val ); strcpy( fstr->bv_val+i, "*" );
strcpy( fstr->bv_val+i+1, escaped.bv_val );
ber_memfree( escaped.bv_val ); ber_memfree( escaped.bv_val );
} }
break; break;
@ -614,12 +631,14 @@ get_substring_filter(
f->f_sub_final = value; f->f_sub_final = value;
if( fstr ) { if( fstr->bv_val ) {
int i = fstr->bv_len;
filter_escape_value( value, &escaped ); filter_escape_value( value, &escaped );
*fstr = ch_realloc( *fstr, fstr->bv_len += escaped.bv_len + 2;
strlen( *fstr ) + escaped.bv_len + 2 ); fstr->bv_val = ch_realloc( fstr->bv_val,
strcat( *fstr, "*" ); fstr->bv_len + 1 );
strcat( *fstr, escaped.bv_val ); strcpy( fstr->bv_val+i, "*" );
strcpy( fstr->bv_val+i+1, escaped.bv_val );
ber_memfree( escaped.bv_val ); ber_memfree( escaped.bv_val );
} }
break; break;
@ -646,9 +665,10 @@ return_error:
Debug( LDAP_DEBUG_FILTER, " error=%ld\n", Debug( LDAP_DEBUG_FILTER, " error=%ld\n",
(long) rc, 0, 0 ); (long) rc, 0, 0 );
#endif #endif
if( fstr ) { if( fstr->bv_val ) {
free( *fstr ); free( fstr->bv_val );
*fstr = NULL; fstr->bv_val = NULL;
fstr->bv_len = 0;
} }
ber_bvfree( f->f_sub_initial ); ber_bvfree( f->f_sub_initial );
@ -659,12 +679,15 @@ return_error:
} }
} }
if( fstr ) { if( fstr->bv_val ) {
*fstr = ch_realloc( *fstr, strlen( *fstr ) + 3 ); int i = fstr->bv_len;
fstr->bv_len += 3;
fstr->bv_val = ch_realloc( fstr->bv_val, fstr->bv_len + 3 );
if ( f->f_sub_final == NULL ) { if ( f->f_sub_final == NULL ) {
strcat( *fstr, "*" ); strcpy( fstr->bv_val+i, "*" );
i++;
} }
strcat( *fstr, /*(*/ ")" ); strcpy( fstr->bv_val+i, /*(*/ ")" );
} }
#ifdef NEW_LOGGING #ifdef NEW_LOGGING

View file

@ -21,7 +21,7 @@ mra_free(
int freeit int freeit
) )
{ {
ch_free( mra->ma_rule_text ); ch_free( mra->ma_rule_text.bv_val );
ber_bvfree( mra->ma_value ); ber_bvfree( mra->ma_value );
if ( freeit ) { if ( freeit ) {
ch_free( (char *) mra ); ch_free( (char *) mra );
@ -42,7 +42,8 @@ get_mra(
ma = ch_malloc( sizeof( MatchingRuleAssertion ) ); ma = ch_malloc( sizeof( MatchingRuleAssertion ) );
ma->ma_rule = NULL; ma->ma_rule = NULL;
ma->ma_rule_text = NULL; ma->ma_rule_text.bv_val = NULL;
ma->ma_rule_text.bv_len = 0;
ma->ma_desc = NULL; ma->ma_desc = NULL;
ma->ma_dnattrs = 0; ma->ma_dnattrs = 0;
ma->ma_value = NULL; ma->ma_value = NULL;
@ -63,11 +64,11 @@ get_mra(
} }
if ( tag == LDAP_FILTER_EXT_OID ) { if ( tag == LDAP_FILTER_EXT_OID ) {
rc = ber_scanf( ber, "a", &ma->ma_rule_text ); rc = ber_scanf( ber, "o", &ma->ma_rule_text );
if ( rc == LBER_ERROR ) { if ( rc == LBER_ERROR ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR, LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"get_mra: ber_scanf(\"a\") failure.\n" )); "get_mra: ber_scanf(\"o\") failure.\n" ));
#else #else
Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 ); Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 );
#endif #endif
@ -76,7 +77,7 @@ get_mra(
mra_free( ma, 1 ); mra_free( ma, 1 );
return SLAPD_DISCONNECT; return SLAPD_DISCONNECT;
} }
ma->ma_rule = mr_find( ma->ma_rule_text ); ma->ma_rule = mr_find( ma->ma_rule_text.bv_val );
rc = ber_scanf( ber, "t", &tag ); rc = ber_scanf( ber, "t", &tag );

View file

@ -445,7 +445,7 @@ LDAP_SLAPD_F (int) get_filter LDAP_P((
Connection *conn, Connection *conn,
BerElement *ber, BerElement *ber,
Filter **filt, Filter **filt,
char **fstr, struct berval *fstr,
const char **text )); const char **text ));
LDAP_SLAPD_F (void) filter_free LDAP_P(( Filter *f )); LDAP_SLAPD_F (void) filter_free LDAP_P(( Filter *f ));

View file

@ -36,7 +36,7 @@ do_search(
struct berval base = { 0, NULL }; struct berval base = { 0, NULL };
struct berval *pbase = NULL; struct berval *pbase = NULL;
struct berval *nbase = NULL; struct berval *nbase = NULL;
char *fstr = NULL; struct berval fstr = { 0, NULL };
Filter *filter = NULL; Filter *filter = NULL;
struct berval **attrs = NULL; struct berval **attrs = NULL;
Backend *be; Backend *be;
@ -165,9 +165,9 @@ do_search(
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS, LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
"do_search: conn %d filter: %s\n", conn->c_connid, fstr )); "do_search: conn %d filter: %s\n", conn->c_connid, fstr.bv_val ));
#else #else
Debug( LDAP_DEBUG_ARGS, " filter: %s\n", fstr, 0, 0 ); Debug( LDAP_DEBUG_ARGS, " filter: %s\n", fstr.bv_val, 0, 0 );
#endif #endif
@ -221,7 +221,7 @@ do_search(
Statslog( LDAP_DEBUG_STATS, Statslog( LDAP_DEBUG_STATS,
"conn=%ld op=%d SRCH base=\"%s\" scope=%d filter=\"%s\"\n", "conn=%ld op=%d SRCH base=\"%s\" scope=%d filter=\"%s\"\n",
op->o_connid, op->o_opid, pbase->bv_val, scope, fstr ); op->o_connid, op->o_opid, pbase->bv_val, scope, fstr.bv_val );
manageDSAit = get_manageDSAit( op ); manageDSAit = get_manageDSAit( op );
@ -329,7 +329,7 @@ do_search(
if ( be->be_search ) { if ( be->be_search ) {
(*be->be_search)( be, conn, op, pbase->bv_val, nbase->bv_val, (*be->be_search)( be, conn, op, pbase->bv_val, nbase->bv_val,
scope, deref, sizelimit, scope, deref, sizelimit,
timelimit, filter, fstr, attrs, attrsonly ); timelimit, filter, fstr.bv_val, attrs, attrsonly );
} else { } else {
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
NULL, "operation not supported within namingContext", NULL, NULL ); NULL, "operation not supported within namingContext", NULL, NULL );
@ -340,7 +340,7 @@ return_results:;
if( pbase != NULL) ber_bvfree( pbase ); if( pbase != NULL) ber_bvfree( pbase );
if( nbase != NULL) ber_bvfree( nbase ); if( nbase != NULL) ber_bvfree( nbase );
if( fstr != NULL) free( fstr ); if( fstr.bv_val != NULL) free( fstr.bv_val );
if( filter != NULL) filter_free( filter ); if( filter != NULL) filter_free( filter );
if ( attrs != NULL ) { if ( attrs != NULL ) {
ber_bvecfree( attrs ); ber_bvecfree( attrs );

View file

@ -543,7 +543,7 @@ typedef struct slap_ss_assertion {
typedef struct slap_mr_assertion { typedef struct slap_mr_assertion {
MatchingRule *ma_rule; /* optional */ MatchingRule *ma_rule; /* optional */
char *ma_rule_text; /* optional */ struct berval ma_rule_text; /* optional */
AttributeDescription *ma_desc; /* optional */ AttributeDescription *ma_desc; /* optional */
int ma_dnattrs; /* boolean */ int ma_dnattrs; /* boolean */
struct berval *ma_value; /* required */ struct berval *ma_value; /* required */