ldap/servers/slapd/entry.c | 67 +++++++++++++++++++---------------------
ldap/servers/slapd/str2filter.c | 2 -
2 files changed, 34 insertions(+), 35 deletions(-)
New commits:
commit 24e80bf035353cdd3fe943bb3f742305d696e25d
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu Feb 28 12:49:18 2013 -0800
Ticket #603 - A logic error in str2simple
Fix description: str2simple sets the strdup'ed type this way:
if ( f->f_choice == LDAP_FILTER_PRESENT ) {
f->f_type = slapi_ch_strdup( str );
} else if ( unescape_filter ) {
f->f_avtype = slapi_ch_strdup( str );
} if ( !unescape_filter ) {
f->f_avtype = slapi_ch_strdup( str );
}
If f_choice is LDAP_FILTER_PRESENT and !unescape_filter is
true, the first strdup'ed string is leaked since f_type
and f_avtype share the same memory. But currently, str2simple
is not called with (unescape_filter == 0). Thus there is no
chance to satisfy the condition. This patch fixes the flaw.
https://fedorahosted.org/389/ticket/603
Reviewed by Rich (Thank you!!)
diff --git a/ldap/servers/slapd/str2filter.c b/ldap/servers/slapd/str2filter.c
index e6a9996..d5bcc1a 100644
--- a/ldap/servers/slapd/str2filter.c
+++ b/ldap/servers/slapd/str2filter.c
@@ -340,7 +340,7 @@ str2simple( char *str , int unescape_filter)
f->f_flags |= SLAPI_FILTER_RUV;
}
- } if ( !unescape_filter ) {
+ } else if ( !unescape_filter ) {
f->f_avtype = slapi_ch_strdup( str );
f->f_avvalue.bv_val = slapi_ch_strdup ( value );
f->f_avvalue.bv_len = strlen ( f->f_avvalue.bv_val );
commit ae7e811d0072cc2e1c6e99b000c2b1038434010c
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu Feb 28 12:43:57 2013 -0800
Ticket #490 - Slow role performance when using a lot of roles
Bug description: Role uses the virtual attribute framework.
When the search with a filter including nsrole or a return
attribute list containing nsrole is being processed, the
virtual attribute code checks the entry if the vattr values
are valid or not by examining the watermark. If it is valid,
the values are used as if they are static. If it is not
valid, the entry is evaluated against the role definitions
and dynamically generated virtual attributes are set to the
list (e_virtual_attrs) with the proper watermark.
The current code additionally checks e_virtual_attrs to determine
the entry is already evaluated or not. If it is NULL, it
considers the entry is not yet evaluated and it returns SLAPI_
ENTRY_VATTR_NOT_RESOLVED even if the watermark is valid. That
is, all the entries which do not have virtual attributes are
unnecessarily evaluated every time search with nsrole is executed.
Fix description: This patch does not return SLAPI_ENTRY_VATTR_NOT_
RESOLVED but does SLAPI_ENTRY_VATTR_RESOLVED_ABSENT if e_virtual_
attrs is NULL AND the watermark is valid. By skipping the not-
needed nsrole evaluation, it speeds up the virtual search once
virutual attribute values are placed in the entries in memory.
https://fedorahosted.org/389/ticket/490
Reviewed by Rich (Thank you!!)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index cdc8f6c..1fde838 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -2429,9 +2429,9 @@ void slapi_entrycache_vattrcache_watermark_invalidate()
int
slapi_entry_vattrcache_findAndTest( const Slapi_Entry *e, const char *type,
- Slapi_Filter *f,
- filter_type_t filter_type,
- int *rc )
+ Slapi_Filter *f,
+ filter_type_t filter_type,
+ int *rc )
{
Slapi_Attr *tmp_attr = NULL;
@@ -2439,44 +2439,43 @@ slapi_entry_vattrcache_findAndTest( const Slapi_Entry *e, const
char *type,
*rc = -1;
if( slapi_vattrcache_iscacheable(type) &&
- slapi_entry_vattrcache_watermark_isvalid(e) && e->e_virtual_attrs)
- {
+ slapi_entry_vattrcache_watermark_isvalid(e) ) {
if(e->e_virtual_lock == NULL) {
- return r;
+ return r;
}
vattrcache_entry_READ_LOCK(e);
- tmp_attr = attrlist_find( e->e_virtual_attrs, type );
- if (tmp_attr != NULL)
- {
- if(valueset_isempty(&(tmp_attr->a_present_values)))
- {
- /*
- * this is a vattr that has been
- * cached already but does not exist
- */
- r= SLAPI_ENTRY_VATTR_RESOLVED_ABSENT; /* hard coded for prototype */
- }
- else
- {
- /*
- * this is a cached vattr--test the filter on it.
- *
- */
- r= SLAPI_ENTRY_VATTR_RESOLVED_EXISTS;
- if ( filter_type == FILTER_TYPE_AVA ) {
- *rc = plugin_call_syntax_filter_ava( tmp_attr,
- f->f_choice,
- &f->f_ava );
- } else if ( filter_type == FILTER_TYPE_SUBSTRING) {
- *rc = plugin_call_syntax_filter_sub( NULL, tmp_attr,
- &f->f_sub);
- } else if ( filter_type == FILTER_TYPE_PRES ) {
- /* type is there, that's all we need to know. */
- *rc = 0;
+ if (e->e_virtual_attrs) {
+ tmp_attr = attrlist_find( e->e_virtual_attrs, type );
+ if (tmp_attr != NULL) {
+ if(valueset_isempty(&(tmp_attr->a_present_values))) {
+ /*
+ * this is a vattr that has been
+ * cached already but does not exist
+ */
+ /* hard coded for prototype */
+ r= SLAPI_ENTRY_VATTR_RESOLVED_ABSENT;
+ } else {
+ /*
+ * this is a cached vattr--test the filter on it.
+ */
+ r= SLAPI_ENTRY_VATTR_RESOLVED_EXISTS;
+ if ( filter_type == FILTER_TYPE_AVA ) {
+ *rc = plugin_call_syntax_filter_ava(tmp_attr,
+ f->f_choice,
+ &f->f_ava);
+ } else if ( filter_type == FILTER_TYPE_SUBSTRING) {
+ *rc = plugin_call_syntax_filter_sub(NULL, tmp_attr,
+ &f->f_sub);
+ } else if ( filter_type == FILTER_TYPE_PRES ) {
+ /* type is there, that's all we need to know. */
+ *rc = 0;
+ }
}
}
+ } else {
+ r= SLAPI_ENTRY_VATTR_RESOLVED_ABSENT;
}
vattrcache_entry_READ_UNLOCK(e);
}