From: Aki Tuomi Date: Mon, 1 Sep 2025 12:20:48 +0000 (+0300) Subject: lib-regex: Only use pcre2_substitute_callout_block() if it's available X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a83cdd926d9131ceefbb6ef047e70fcce63eac35;p=thirdparty%2Fdovecot%2Fcore.git lib-regex: Only use pcre2_substitute_callout_block() if it's available --- diff --git a/m4/want_pcre.m4 b/m4/want_pcre.m4 index ccf10ceb71..f013aaad82 100644 --- a/m4/want_pcre.m4 +++ b/m4/want_pcre.m4 @@ -12,6 +12,10 @@ AC_DEFUN([DOVECOT_WANT_PCRE], [ ]) AS_IF([test "$have_pcre" != "no"], [ + old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $LIBPCRE_CFLAGS" + AC_CHECK_FUNCS([pcre2_substitute_callout_block]) + CFLAGS="$old_CFLAGS" AC_DEFINE(HAVE_LIBPCRE,, [Define if you have libpcre2 backed regular expressions]) ]) diff --git a/src/lib-regex/regex.c b/src/lib-regex/regex.c index b8be11afa1..66c5f6238e 100644 --- a/src/lib-regex/regex.c +++ b/src/lib-regex/regex.c @@ -54,11 +54,13 @@ static int dregex_code_callout(pcre2_callout_block *block ATTR_UNUSED, void *ctx return 0; } +#ifdef HAVE_PCRE2_SUBSTITUTE_CALLOUT_BLOCK static int dregex_code_substitute_callout(pcre2_substitute_callout_block *block ATTR_UNUSED, void *ctx) { return dregex_code_callout(NULL, ctx); } +#endif static int dregex_code_guard(uint depth, void *ctx) { @@ -78,7 +80,9 @@ static void dregex_code_init(struct dregex_code *code) pcre2_set_compile_recursion_guard(code->cctx, dregex_code_guard, code); /* these are used to ensure that CPU time isn't exceeded */ pcre2_set_callout(code->mctx, dregex_code_callout, code); +#ifdef HAVE_PCRE2_SUBSTITUTE_CALLOUT_BLOCK pcre2_set_substitute_callout(code->mctx, dregex_code_substitute_callout, code); +#endif /* Set some limits */ pcre2_set_match_limit(code->mctx, code->max_capture_groups);