ldap/servers/plugins/syntaxes/bin.c | 52 +++++++++++++++++---------
ldap/servers/plugins/syntaxes/numericstring.c | 2 -
ldap/servers/slapd/match.c | 2 -
ldap/servers/slapd/plugin_mr.c | 11 +++++
4 files changed, 47 insertions(+), 20 deletions(-)
New commits:
commit c0fd0171fed64b026bc80bad872b6641a0c4d86f
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Feb 22 13:59:01 2010 -0700
crash looking up compat syntax; numeric string syntax using integer; make octet string
ordering work correctly
https://bugzilla.redhat.com/show_bug.cgi?id=559315
Resolves: bug 559315
Bug Description: Searching some attributes are now case sensitive when they were
previously case-insensitive
Reviewed by: nhosoi (Thanks!)
Branch: HEAD
Fix Description: slapi_matchingrule_is_compat() was not checking for NULL; the
matching rule syntax plugin was registering with the INTEGER syntax oid; the
bin_filter_ava() function needs to be ordering aware to implement the
octetStringOrderingMatch; in default_mr_filter_create(), make sure the requested matching
rule is provided by the given plugin
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/syntaxes/bin.c b/ldap/servers/plugins/syntaxes/bin.c
index b1b4659..3d2d88a 100644
--- a/ldap/servers/plugins/syntaxes/bin.c
+++ b/ldap/servers/plugins/syntaxes/bin.c
@@ -249,26 +249,44 @@ static int
bin_filter_ava( Slapi_PBlock *pb, struct berval *bvfilter,
Slapi_Value **bvals, int ftype, Slapi_Value **retVal )
{
- int i;
+ int i;
- for ( i = 0; bvals[i] != NULL; i++ ) {
+ for ( i = 0; bvals[i] != NULL; i++ ) {
const struct berval *bv = slapi_value_get_berval(bvals[i]);
-
- if ( ( bv->bv_len == bvfilter->bv_len ) &&
- ( 0 == memcmp( bv->bv_val, bvfilter->bv_val, bvfilter->bv_len ) )
)
- {
- if(retVal!=NULL)
- {
- *retVal= bvals[i];
- }
- return( 0 );
+ int rc = slapi_berval_cmp(bv, bvfilter);
+
+ switch ( ftype ) {
+ case LDAP_FILTER_GE:
+ if ( rc >= 0 ) {
+ if(retVal) {
+ *retVal = bvals[i];
+ }
+ return( 0 );
+ }
+ break;
+ case LDAP_FILTER_LE:
+ if ( rc <= 0 ) {
+ if(retVal) {
+ *retVal = bvals[i];
+ }
+ return( 0 );
+ }
+ break;
+ case LDAP_FILTER_EQUALITY:
+ if ( rc == 0 ) {
+ if(retVal) {
+ *retVal = bvals[i];
+ }
+ return( 0 );
+ }
+ break;
}
- }
- if(retVal!=NULL)
- {
- *retVal= NULL;
- }
- return( -1 );
+ }
+ if(retVal!=NULL)
+ {
+ *retVal= NULL;
+ }
+ return( -1 );
}
static int
diff --git a/ldap/servers/plugins/syntaxes/numericstring.c
b/ldap/servers/plugins/syntaxes/numericstring.c
index d1bf475..0cb4876 100644
--- a/ldap/servers/plugins/syntaxes/numericstring.c
+++ b/ldap/servers/plugins/syntaxes/numericstring.c
@@ -148,7 +148,7 @@ numstr_init( Slapi_PBlock *pb )
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_SYNTAX_NAMES,
(void *) names );
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_SYNTAX_OID,
- (void *) INTEGER_SYNTAX_OID );
+ (void *) NUMERICSTRING_SYNTAX_OID );
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_SYNTAX_COMPARE,
(void *) numstr_compare );
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_SYNTAX_VALIDATE,
diff --git a/ldap/servers/slapd/match.c b/ldap/servers/slapd/match.c
index 241b182..91fa0a8 100644
--- a/ldap/servers/slapd/match.c
+++ b/ldap/servers/slapd/match.c
@@ -322,7 +322,7 @@ int slapi_matchingrule_is_compat(const char *mr_oid_or_name, const
char *syntax_
return 1;
}
for (mr_syntax = mrl->mr_entry->mr_compat_syntax;
- mr_syntax;
+ mr_syntax && *mr_syntax;
mr_syntax++) {
if (!strcmp(*mr_syntax, syntax_oid)) {
return 1;
diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
index 194f8ae..7590f26 100644
--- a/ldap/servers/slapd/plugin_mr.c
+++ b/ldap/servers/slapd/plugin_mr.c
@@ -170,7 +170,7 @@ plugin_mr_bind (char* oid, struct slapdplugin* plugin)
PR_Lock (global_mr_oids_lock);
i->oi_next = global_mr_oids;
global_mr_oids = i;
- PR_Unlock (global_mr_oids_lock);
+ PR_Unlock (global_mr_oids_lock);
LDAPDebug (LDAP_DEBUG_FILTER, "<= plugin_mr_bind\n", 0, 0, 0);
}
@@ -449,6 +449,15 @@ default_mr_filter_create(Slapi_PBlock *pb)
LDAPDebug2Args(LDAP_DEBUG_FILTER, "=> default_mr_filter_create(oid %s; type
%s)\n",
mrOID, mrTYPE);
+ /* check to make sure this create function is supposed to be used with the
+ given oid */
+ if (!charray_inlist(pi->plg_mr_names, mrOID)) {
+ LDAPDebug2Args(LDAP_DEBUG_FILTER,
+ "=> default_mr_filter_create: cannot use matching rule %s with plugin
%s\n",
+ mrOID, pi->plg_name);
+ goto done;
+ }
+
ftype = plugin_mr_get_type(pi);
/* map the ftype to the op type */
if (ftype == LDAP_FILTER_GE) {