Use PCRE posix-compatability library for regex handling We let users generate sieve scripts with regular expressions in them, and occasionally these combine in ugly ways with incoming messages (i.e. a message with hundreds of recipients and an inefficient regex match on recipient addresses caused an lmtp process to grow to over 2Gb in size before it died) This patch tests for the presence of the PCRE library and uses it by preference if available. NOTE: you will need to run autoconf again on your source tree after applying this patch, because it changes configure.in. Index: cyrus-imapd-2.3.9/configure.in =================================================================== --- cyrus-imapd-2.3.9.orig/configure.in 2006-12-01 04:11:16.000000000 +1100 +++ cyrus-imapd-2.3.9/configure.in 2007-09-11 17:16:54.000000000 +1000 @@ -243,10 +243,13 @@ AC_PROG_LEX AC_CHECK_LIB(fl,main) + AC_SEARCH_LIBS(regcomp, pcreposix, [LIBS="${LIBS} -lpcre -lpcreposix" + AC_DEFINE(ENABLE_REGEX,[],[Do we have a decent regex library?]) + AC_CHECK_HEADER(pcreposix.h, AC_DEFINE(HAVE_PCREPOSIX,[],[Do we have pcreposix.h?]))]) + AC_SEARCH_LIBS(regcomp, rx regex, [ AC_DEFINE(ENABLE_REGEX,[],[Do we have a decent regex library?]) AC_CHECK_HEADER(rxposix.h, AC_DEFINE(HAVE_RX,[],[Do we have rxposix.h?]))]) - SIEVE_SUBDIRS="${SIEVE_SUBDIRS} $sievedir" EXTRA_OUTPUT="${EXTRA_OUTPUT} $sievedir/Makefile" Index: cyrus-imapd-2.3.9/sieve/comparator.h =================================================================== --- cyrus-imapd-2.3.9.orig/sieve/comparator.h 2006-12-01 04:11:24.000000000 +1100 +++ cyrus-imapd-2.3.9/sieve/comparator.h 2007-09-11 17:04:34.000000000 +1000 @@ -29,6 +29,9 @@ #define COMPARATOR_H #ifdef ENABLE_REGEX +#ifdef HAVE_PCREPOSIX +#include +#else #ifdef HAVE_RX #include #else @@ -36,6 +39,7 @@ #include #endif #endif +#endif /* compares pat to text; returns 1 if it's true, 0 otherwise first arg is text, second arg is pat, third arg is rock */