Commit 6eab68a8 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

regex thread safety fix from head

parent d587111c
...@@ -33,7 +33,6 @@ typedef struct sasl_regexp { ...@@ -33,7 +33,6 @@ typedef struct sasl_regexp {
char *sr_match; /* regexp match pattern */ char *sr_match; /* regexp match pattern */
char *sr_replace; /* regexp replace pattern */ char *sr_replace; /* regexp replace pattern */
regex_t sr_workspace; /* workspace for regexp engine */ regex_t sr_workspace; /* workspace for regexp engine */
regmatch_t sr_strings[SASLREGEX_REPLACE]; /* strings matching $1,$2 ... */
int sr_offset[SASLREGEX_REPLACE+2]; /* offsets of $1,$2... in *replace */ int sr_offset[SASLREGEX_REPLACE+2]; /* offsets of $1,$2... in *replace */
} SaslRegexp_t; } SaslRegexp_t;
...@@ -281,6 +280,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out ) ...@@ -281,6 +280,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out )
{ {
char *saslname = in->bv_val; char *saslname = in->bv_val;
SaslRegexp_t *reg; SaslRegexp_t *reg;
regmatch_t sr_strings[SASLREGEX_REPLACE]; /* strings matching $1,$2 ... */
int i; int i;
memset( out, 0, sizeof( *out ) ); memset( out, 0, sizeof( *out ) );
...@@ -300,7 +300,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out ) ...@@ -300,7 +300,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out )
/* Match the normalized SASL name to the saslregexp patterns */ /* Match the normalized SASL name to the saslregexp patterns */
for( reg = SaslRegexp,i=0; i<nSaslRegexp; i++,reg++ ) { for( reg = SaslRegexp,i=0; i<nSaslRegexp; i++,reg++ ) {
if ( regexec( &reg->sr_workspace, saslname, SASLREGEX_REPLACE, if ( regexec( &reg->sr_workspace, saslname, SASLREGEX_REPLACE,
reg->sr_strings, 0) == 0 ) sr_strings, 0) == 0 )
break; break;
} }
...@@ -312,7 +312,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out ) ...@@ -312,7 +312,7 @@ static int slap_sasl_regexp( struct berval *in, struct berval *out )
* to replace the $1,$2 with the strings that matched (b.*) and (d.*) * to replace the $1,$2 with the strings that matched (b.*) and (d.*)
*/ */
slap_sasl_rx_exp( reg->sr_replace, reg->sr_offset, slap_sasl_rx_exp( reg->sr_replace, reg->sr_offset,
reg->sr_strings, saslname, out ); sr_strings, saslname, out );
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( TRANSPORT, ENTRY, LDAP_LOG( TRANSPORT, ENTRY,
......
Supports Markdown
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