Commit c0a303ba authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Insert filter equality bugfix

parent 3ef57f8a
...@@ -4,22 +4,13 @@ ...@@ -4,22 +4,13 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef sunos5 #include <regex.h>
#include "regexpr.h"
#else
#include "regex.h"
#endif
#include "slap.h" #include "slap.h"
extern Attribute *attr_find(); extern Attribute *attr_find();
extern char *first_word(); extern char *first_word();
extern char *next_word(); extern char *next_word();
extern char *phonetic(); extern char *phonetic();
extern char *re_comp();
#ifndef sunos5
extern pthread_mutex_t regex_mutex;
#endif
static int test_filter_list(); static int test_filter_list();
static int test_substring_filter(); static int test_substring_filter();
...@@ -145,13 +136,13 @@ test_ava_filter( ...@@ -145,13 +136,13 @@ test_ava_filter(
break; break;
case LDAP_FILTER_GE: case LDAP_FILTER_GE:
if ( rc > 0 ) { if ( rc >= 0 ) {
return( 0 ); return( 0 );
} }
break; break;
case LDAP_FILTER_LE: case LDAP_FILTER_LE:
if ( rc < 0 ) { if ( rc <= 0 ) {
return( 0 ); return( 0 );
} }
break; break;
...@@ -223,11 +214,12 @@ test_approx_filter( ...@@ -223,11 +214,12 @@ test_approx_filter(
w2 = next_word( w2 ) ) { w2 = next_word( w2 ) ) {
c2 = phonetic( w2 ); c2 = phonetic( w2 );
if ( strcmp( c1, c2 ) == 0 ) { if ( strcmp( c1, c2 ) == 0 ) {
free( c2 );
break; break;
} }
free( c2 );
} }
free( c1 ); free( c1 );
free( c2 );
/* /*
* if we stopped because we ran out of words * if we stopped because we ran out of words
...@@ -322,6 +314,7 @@ test_substring_filter( ...@@ -322,6 +314,7 @@ test_substring_filter(
char pat[BUFSIZ]; char pat[BUFSIZ];
char buf[BUFSIZ]; char buf[BUFSIZ];
struct berval *val; struct berval *val;
regex_t re;
Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 ); Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 );
...@@ -389,19 +382,16 @@ test_substring_filter( ...@@ -389,19 +382,16 @@ test_substring_filter(
} }
/* compile the regex */ /* compile the regex */
#ifdef sunos5 Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n",
if ( (p = compile( pat, NULL, NULL )) == NULL ) { pat, 0, 0 );
Debug( LDAP_DEBUG_ANY, "compile failed (%s)\n", p, 0, 0 ); if ((rc = regcomp(&re, pat, 0))) {
return( -1 ); char error[512];
}
#else /* sunos5 */ regerror(rc, &re, error, sizeof(error));
pthread_mutex_lock( &regex_mutex ); Debug( LDAP_DEBUG_ANY, "regcomp failed (%s) %s\n",
if ( (p = re_comp( pat )) != 0 ) { p, error, 0 );
Debug( LDAP_DEBUG_ANY, "re_comp failed (%s)\n", p, 0, 0 );
pthread_mutex_unlock( &regex_mutex );
return( -1 ); return( -1 );
} }
#endif /* sunos5 */
/* for each value in the attribute see if regex matches */ /* for each value in the attribute see if regex matches */
for ( i = 0; a->a_vals[i] != NULL; i++ ) { for ( i = 0; a->a_vals[i] != NULL; i++ ) {
...@@ -417,29 +407,18 @@ test_substring_filter( ...@@ -417,29 +407,18 @@ test_substring_filter(
} }
value_normalize( realval, a->a_syntax ); value_normalize( realval, a->a_syntax );
#ifdef sunos5 rc = !regexec(&re, realval, 0, NULL, 0);
rc = step( realval, p );
#else /* sunos5 */
rc = re_exec( realval );
#endif /* sunos5 */
if ( tmp != NULL ) { if ( tmp != NULL ) {
free( tmp ); free( tmp );
} }
if ( rc == 1 ) { if ( rc == 1 ) {
#ifdef sunos5 regfree(&re);
free( p );
#else /* sunos5 */
pthread_mutex_unlock( &regex_mutex );
#endif /* sunos5 */
return( 0 ); return( 0 );
} }
} }
#ifdef sunos5
free( p ); regfree(&re);
#else /* sunos5 */
pthread_mutex_unlock( &regex_mutex );
#endif /* sunos5 */
Debug( LDAP_DEBUG_FILTER, "end test_substring_filter 1\n", 0, 0, 0 ); Debug( LDAP_DEBUG_FILTER, "end test_substring_filter 1\n", 0, 0, 0 );
return( 1 ); return( 1 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment