[Pcre-svn] [1176] code/trunk: Ensure regexec is thread safe …

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1176] code/trunk: Ensure regexec is thread safe to avoid sanitizer warnings.
Revision: 1176
          http://www.exim.org/viewvc/pcre2?view=rev&revision=1176
Author:   ph10
Date:     2019-10-15 11:46:36 +0100 (Tue, 15 Oct 2019)
Log Message:
-----------
Ensure regexec is thread safe to avoid sanitizer warnings.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2posix.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2019-10-06 03:36:20 UTC (rev 1175)
+++ code/trunk/ChangeLog    2019-10-15 10:46:36 UTC (rev 1176)
@@ -170,7 +170,11 @@
 for non-unique first code unit patterns, but after a unique first code unit, 
 and patterns such as a*a need the former action).


+36. Small patch to pcre2posix.c to set the erroroffset field to -1 immediately
+after a successful compile, instead of at the start of matching to avoid a
+sanitizer complaint (regexec is supposed to be thread safe).

+
Version 10.33 16-April-2019
---------------------------


Modified: code/trunk/src/pcre2posix.c
===================================================================
--- code/trunk/src/pcre2posix.c    2019-10-06 03:36:20 UTC (rev 1175)
+++ code/trunk/src/pcre2posix.c    2019-10-15 10:46:36 UTC (rev 1176)
@@ -323,6 +323,7 @@
   PCRE2_INFO_CAPTURECOUNT, &re_nsub);
 preg->re_nsub = (size_t)re_nsub;
 preg->re_match_data = pcre2_match_data_create(re_nsub + 1, NULL);
+preg->re_erroffset = (size_t)(-1);  /* No meaning after successful compile */


if (preg->re_match_data == NULL)
{
@@ -356,8 +357,6 @@
if ((eflags & REG_NOTEOL) != 0) options |= PCRE2_NOTEOL;
if ((eflags & REG_NOTEMPTY) != 0) options |= PCRE2_NOTEMPTY;

-((regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
-
/* When REG_NOSUB was specified, or if no vector has been passed in which to
put captured strings, ensure that nmatch is zero. This will stop any attempt to
write to pmatch. */