mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-27 03:20:22 +08:00
Fix slapi_filter_join() behavioural bug.
Fix slapi_filter_dup() crasher. Add slapi_x_filter_append(), as a replacement for slapi_filter_join() that can create compound filters containing multiple filters. Will propose API to Sun DS team; until then it should likely be marked LDAP_DEVEL (if SLAPI is not entirely marked as such already).
This commit is contained in:
parent
a82a6d8403
commit
83cb1037a4
@ -187,6 +187,8 @@ extern int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
|
||||
extern int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
|
||||
char ***any, char **final );
|
||||
extern Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2);
|
||||
extern int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter,
|
||||
Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend );
|
||||
extern int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
|
||||
int verify_access );
|
||||
extern int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code );
|
||||
|
@ -1520,6 +1520,7 @@ slapi_filter_dup( Slapi_Filter *filter )
|
||||
int i;
|
||||
|
||||
f->f_sub = (SubstringsAssertion *)slapi_ch_malloc( sizeof(SubstringsAssertion) );
|
||||
f->f_sub->sa_desc = filter->f_sub->sa_desc;
|
||||
ber_dupbv( &f->f_sub_initial, &filter->f_sub_initial );
|
||||
if ( filter->f_sub_any != NULL ) {
|
||||
for ( i = 0; filter->f_sub_any[i].bv_val != NULL; i++ )
|
||||
@ -1619,7 +1620,7 @@ slapi_filter_list_first( Slapi_Filter *f )
|
||||
if ( ftype == LDAP_FILTER_AND
|
||||
|| ftype == LDAP_FILTER_OR
|
||||
|| ftype == LDAP_FILTER_NOT ) {
|
||||
return (Slapi_Filter *)f->f_and;
|
||||
return (Slapi_Filter *)f->f_list;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@ -1725,7 +1726,7 @@ slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
|
||||
}
|
||||
|
||||
Slapi_Filter *
|
||||
slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2)
|
||||
slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2 )
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
Slapi_Filter *f = NULL;
|
||||
@ -1737,7 +1738,8 @@ slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2)
|
||||
f = (Slapi_Filter *)slapi_ch_malloc( sizeof(*f) );
|
||||
f->f_choice = ftype;
|
||||
f->f_list = f1;
|
||||
f->f_next = f2;
|
||||
f->f_list->f_next = f2;
|
||||
f->f_next = NULL;
|
||||
}
|
||||
|
||||
return f;
|
||||
@ -1746,6 +1748,37 @@ slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2)
|
||||
#endif /* LDAP_SLAPI */
|
||||
}
|
||||
|
||||
int
|
||||
slapi_x_filter_append( int ftype,
|
||||
Slapi_Filter **pContainingFilter, /* NULL on first call */
|
||||
Slapi_Filter **pNextFilter,
|
||||
Slapi_Filter *filterToAppend )
|
||||
{
|
||||
#ifdef LDAP_SLAPI
|
||||
if ( ftype == LDAP_FILTER_AND ||
|
||||
ftype == LDAP_FILTER_OR ||
|
||||
ftype == LDAP_FILTER_NOT )
|
||||
{
|
||||
if ( *pContainingFilter == NULL ) {
|
||||
*pContainingFilter = (Slapi_Filter *)slapi_ch_malloc( sizeof(Slapi_Filter) );
|
||||
(*pContainingFilter)->f_choice = ftype;
|
||||
(*pContainingFilter)->f_list = filterToAppend;
|
||||
(*pContainingFilter)->f_next = NULL;
|
||||
} else {
|
||||
if ( (*pContainingFilter)->f_choice != ftype ) {
|
||||
/* Sanity check */
|
||||
return -1;
|
||||
}
|
||||
(*pNextFilter)->f_next = filterToAppend;
|
||||
}
|
||||
*pNextFilter = filterToAppend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* LDAP_SLAPI */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
|
||||
int verify_access )
|
||||
|
Loading…
Reference in New Issue
Block a user