ldap/servers/slapd/back-ldbm/filterindex.c | 22 ++++++++++++---------- ldap/servers/slapd/back-ldbm/idl_common.c | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 11 deletions(-)
New commits: commit a71633d56951dd6c4d0368c790b85628f1598968 Author: Noriko Hosoi nhosoi@redhat.com Date: Fri Dec 13 10:35:08 2013 -0800
Ticket #47313 - Indexed search with filter containing '&' and "!" with attribute subtypes gives wrong result
Description: commit fae006821bd6e524c0f7f8d5f023f4fe5e160ef0 introduced a bug, which occurs when a filter includes NOT and one of the results from the subfilters returns NONE. This patch backoffs the last section of the commit fae006821bd6e524c0f7f8d5f023f4fe5e160ef0 with an improvement -- avoiding unnecessary idl duplication.
Also, adding (NULL == idl) checks to idl_common.c.
https://fedorahosted.org/389/ticket/47313
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c index 971e10b..9ad2ab4 100644 --- a/ldap/servers/slapd/back-ldbm/filterindex.c +++ b/ldap/servers/slapd/back-ldbm/filterindex.c @@ -852,17 +852,19 @@ list_candidates( break; /* We can exit the loop now, since the candidate list is small already */ } } else if ( ftype == LDAP_FILTER_AND ) { - if (isnot && !idl_is_allids(tmp)) { - IDList *new_idl = NULL; - int notin_result = 0; - /* - * If the given tmp is ALLIDs (due to subtype in filter), - * we cannot use idl_notin. + if (isnot) { + /* + * If tmp is NULL or ALLID, idl_notin just duplicates idl. + * We don't have to do it. */ - notin_result = idl_notin( be, idl, tmp, &new_idl ); - if (notin_result) { - idl_free(idl); - idl = new_idl; + if (!tmp && !idl_is_allids(tmp)) { + IDList *new_idl = NULL; + int notin_result = 0; + notin_result = idl_notin( be, idl, tmp, &new_idl ); + if (notin_result) { + idl_free(idl); + idl = new_idl; + } } } else { idl = idl_intersection(be, idl, tmp); diff --git a/ldap/servers/slapd/back-ldbm/idl_common.c b/ldap/servers/slapd/back-ldbm/idl_common.c index 584bba5..e3023d8 100644 --- a/ldap/servers/slapd/back-ldbm/idl_common.c +++ b/ldap/servers/slapd/back-ldbm/idl_common.c @@ -46,16 +46,25 @@
size_t idl_sizeof(IDList *idl) { + if (NULL == idl) { + return 0; + } return (2 + idl->b_nmax) * sizeof(ID); }
NIDS idl_length(IDList *idl) { + if (NULL == idl) { + return 0; + } return (idl->b_nmax == ALLIDSBLOCK) ? UINT_MAX : idl->b_nids; }
int idl_is_allids(IDList *idl) { + if (NULL == idl) { + return 0; + } return (idl->b_nmax == ALLIDSBLOCK); }
@@ -110,6 +119,9 @@ idl_free( IDList *idl ) /* JCM - pass in ** */ int idl_append( IDList *idl, ID id) { + if (NULL == idl) { + return 2; + } if ( ALLIDS( idl ) || ( (idl->b_nids) && (idl->b_ids[idl->b_nids - 1] == id)) ) { return( 1 ); /* already there */ } @@ -321,7 +333,7 @@ idl_notin( backend *be, IDList *a, IDList *b, - IDList **new_result + IDList **new_result ) { NIDS ni, ai, bi; @@ -435,6 +447,9 @@ idl_nextid( IDList *idl, ID id ) { NIDS i;
+ if (NULL == idl) { + return NOID; + } if ( ALLIDS( idl ) ) { return( ++id < idl->b_nids ? id : NOID ); }
389-commits@lists.fedoraproject.org