segfaults with cyrus-imapd 3.0.9 on latest arch linux

Andreas Piesk a.piesk at mailbox.org
Wed Mar 20 14:33:30 EDT 2019


Am 20.03.19 um 13:39 schrieb Patrick Goetz:
> 
> It would appear that --disable-pcre is a configuration option you can't actually use.
> 

yes, it seems so. the defines in the header:

#ifdef ENABLE_REGEX
# ifdef HAVE_PCREPOSIX_H
#  include <pcre.h>
#  include <pcreposix.h>
# else /* !HAVE_PCREPOSIX_H */
#  ifdef HAVE_RXPOSIX_H
#   include <rxposix.h>
#  else /* !HAVE_RXPOSIX_H */
#   include <regex.h>
#  endif /* HAVE_RXPOSIX_H */
# endif /* HAVE_PCREPOSIX_H */
#endif /* ENABLE_REGEX */

configure.ac:

if test "$enable_pcre" != "no"; then
         AC_CHECK_HEADER(pcreposix.h)
         if test "$ac_cv_header_pcreposix_h" = "yes"; then
             AC_MSG_CHECKING(for utf8 enabled pcre)
             AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
#ifndef REG_UTF8
#include </nonexistent>
#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no))
             AC_MSG_RESULT($cyrus_cv_pcre_utf8)
         else
             cyrus_cv_pcre_utf8="no"
         fi

         if test "$cyrus_cv_pcre_utf8" = "yes"; then
                 LIBS="$LIBS -lpcre -lpcreposix";
                 AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
                 AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
         else
                 AC_CHECK_HEADERS(rxposix.h)
                 if test "$ac_cv_header_rxposix_h" = "yes"; then
                         LIBS="$LIBS -lrx"
                         AC_DEFINE(ENABLE_REGEX, [],
                                   [Do we have a regex library?])
                 else
                         AC_SEARCH_LIBS(regcomp, regex,
                                         AC_DEFINE(ENABLE_REGEX, [],
                                         [Do we have a regex library?]), [])
                 fi
         fi
fi

the whole block depends on "$enable_pcre", so if I disable pcre, i disable regexp conpletely. I think, it should look like this:

if test "$enable_pcre" != "no"; then
         AC_CHECK_HEADER(pcreposix.h)
         if test "$ac_cv_header_pcreposix_h" = "yes"; then
             AC_MSG_CHECKING(for utf8 enabled pcre)
             AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
#ifndef REG_UTF8
#include </nonexistent>
#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no))
             AC_MSG_RESULT($cyrus_cv_pcre_utf8)
         else
             cyrus_cv_pcre_utf8="no"
         fi

         if test "$cyrus_cv_pcre_utf8" = "yes"; then
                 LIBS="$LIBS -lpcre -lpcreposix";
                 AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
                 AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
         fi
else
         cyrus_cv_pcre_utf8="no"
         AC_CHECK_HEADERS(rxposix.h)
         if test "$ac_cv_header_rxposix_h" = "yes"; then
                 LIBS="$LIBS -lrx"
                 AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
         else
                 AC_SEARCH_LIBS(regcomp, regex, AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex libra
ry?]), [])
         fi
fi

if you don't disable pcre, you must have pcre available, otherwise no regexp because there's no fallback.
if you disable pcre, it checks for rposix.h and fallsback to anything providing regcomp. if nothing is found, no regexp support.

As diff:

--- configure.ac.org	2019-03-15 01:31:20.000000000 +0100
+++ configure.ac	2019-03-20 19:19:05.077550582 +0100
@@ -674,18 +674,16 @@ if test "$enable_pcre" != "no"; then
                  LIBS="$LIBS -lpcre -lpcreposix";
                  AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
                  AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
-        else
-                AC_CHECK_HEADERS(rxposix.h)
-                if test "$ac_cv_header_rxposix_h" = "yes"; then
-                        LIBS="$LIBS -lrx"
-                        AC_DEFINE(ENABLE_REGEX, [],
-                                  [Do we have a regex library?])
-                else
-                        AC_SEARCH_LIBS(regcomp, regex,
-                                        AC_DEFINE(ENABLE_REGEX, [],
-                                        [Do we have a regex library?]), [])
-                fi
          fi
+else
+	cyrus_cv_pcre_utf8="no"
+	AC_CHECK_HEADERS(rxposix.h)
+	if test "$ac_cv_header_rxposix_h" = "yes"; then
+		LIBS="$LIBS -lrx"
+		AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+	else
+		AC_SEARCH_LIBS(regcomp, regex, AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?]), [])
+	fi
  fi
  
  dnl look for an option to disable sign-comparison warnings (needed for

with this change:

./configure --disable-pcre

$ egrep 'REGEX|PCRE' config.h
#define ENABLE_REGEX /**/
/* #undef HAVE_PCREPOSIX_H */

./configure --disable-pcre

$ egrep 'REGEX|PCRE' config.h
#define ENABLE_REGEX /**/
#define HAVE_PCREPOSIX_H /**/


seems to work, but as I said, I'm not a software guy and i don't know autotools, there's probably a better solution.

Regards,
-ap

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2912 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20190320/50554605/attachment.p7s>


More information about the Info-cyrus mailing list