From 2d2719123dc05d1b5327f03acdd6f39e9465d294 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 24 Aug 1999 01:13:30 +0000 Subject: [PATCH] Rename filter entry's strcpy_special() to strcpy_regex() to better reflect its purpose. Modify switch to support REG_EXTENDED expressions. Use REG_EXTENDED instead of REG_BASIC everywhere. Modify to support for testing purposes. Requires: env CPPFLAGS="-DHAVE_GNUREGEX_H=1" LIBS=-lgnuregex ./configure --- include/ac/regex.h | 4 ++++ libraries/libldap/getfilter.c | 2 +- servers/slapd/filterentry.c | 24 +++++++++++++++--------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/ac/regex.h b/include/ac/regex.h index 99afaec3d8..30a3482359 100644 --- a/include/ac/regex.h +++ b/include/ac/regex.h @@ -25,6 +25,10 @@ For NT: http://people.delphi.com/gjc/hs_regex.html */ #error "No POSIX REGEX available." + +#elif HAVE_GNUREGEX_H + /* system has GNU gnuregex.h */ +# include #else /* have regex.h, assume it's POSIX compliant */ # include diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index b0a181a8ef..2c06810ab6 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -253,7 +253,7 @@ ldap_getfirstfilter( continue; /* compile flp->ifl_pattern, continue if we fail */ - if (regcomp(&re, flp->lfl_pattern, 0) != 0) + if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED) != 0) continue; /* match ifl_pattern and lfd_curval, continue if we fail */ diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index dd6da92f64..f65c8472a8 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -283,18 +283,24 @@ test_filter_list( } static void -strcpy_special( char *d, char *s ) +strcpy_regex( char *d, char *s ) { for ( ; *s; s++ ) { switch ( *s ) { + case '^': case '.': - case '\\': case '[': - case ']': + case ']': /* ? */ + case '$': + case '(': + case ')': /* ? */ + case '|': case '*': case '+': - case '^': - case '$': + case '?': + case '{': + case '}': /* ? */ + case '\\': *d++ = '\\'; /* FALL */ default: @@ -356,7 +362,7 @@ test_substring_filter( 0, 0, 0 ); return( -1 ); } - strcpy_special( p, f->f_sub_initial ); + strcpy_regex( p, f->f_sub_initial ); p = strchr( p, '\0' ); } if ( f->f_sub_any != NULL ) { @@ -369,7 +375,7 @@ test_substring_filter( } strcpy( p, ".*" ); p = strchr( p, '\0' ); - strcpy_special( p, f->f_sub_any[i] ); + strcpy_regex( p, f->f_sub_any[i] ); p = strchr( p, '\0' ); } } @@ -382,7 +388,7 @@ test_substring_filter( } strcpy( p, ".*" ); p = strchr( p, '\0' ); - strcpy_special( p, f->f_sub_final ); + strcpy_regex( p, f->f_sub_final ); p = strchr( p, '\0' ); strcpy( p, "$" ); } @@ -390,7 +396,7 @@ test_substring_filter( /* compile the regex */ Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n", pat, 0, 0 ); - if ((rc = regcomp(&re, pat, 0))) { + if ((rc = regcomp(&re, pat, REG_EXTENDED))) { char error[512]; regerror(rc, &re, error, sizeof(error)); -- 2.39.5