From acb1ab08a2b401c4bbea0f235064bfb53d8a3e84 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 13 Apr 2021 14:01:49 +0200 Subject: [PATCH] pcre2: introduce as a new depdendency --- .github/workflows/builds.yml | 18 +++- .github/workflows/commits.yml | 1 + .github/workflows/formatting.yml | 1 + configure.ac | 140 +++++++------------------------ 4 files changed, 47 insertions(+), 113 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 0bce31e435..377bfdfba0 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -209,6 +209,7 @@ jobs: make \ nss-devel \ pcre-devel \ + pcre2-devel \ pkgconfig \ python3-devel \ python3-sphinx \ @@ -284,6 +285,7 @@ jobs: make \ nss-devel \ pcre-devel \ + pcre2-devel \ pkgconfig \ python36-PyYAML \ rust \ @@ -360,6 +362,7 @@ jobs: make \ nss-softokn-devel \ pcre-devel \ + pcre2-devel \ pkgconfig \ python3-yaml \ sudo \ @@ -446,6 +449,7 @@ jobs: make \ nss-softokn-devel \ pcre-devel \ + pcre2-devel \ pkgconfig \ python3-yaml \ sudo \ @@ -518,6 +522,7 @@ jobs: make \ nss-softokn-devel \ pcre-devel \ + pcre2-devel \ pkgconfig \ python3-yaml \ sudo \ @@ -556,6 +561,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -633,6 +639,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -706,6 +713,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -807,6 +815,7 @@ jobs: libpython2.7 \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ make \ parallel \ python3-yaml \ @@ -882,6 +891,7 @@ jobs: libpython2.7 \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ make \ python3-yaml \ software-properties-common \ @@ -922,6 +932,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -994,6 +1005,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -1091,6 +1103,7 @@ jobs: afl-clang \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ @@ -1160,6 +1173,7 @@ jobs: libnfnetlink0 \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ libpcap-dev \ libyaml-0-2 \ libyaml-dev \ @@ -1213,6 +1227,7 @@ jobs: libpcre3 \ libpcre3-dbg \ libpcre3-dev \ + libpcre2-dev \ libpcap-dev \ libnet1-dev \ libyaml-0-2 \ @@ -1279,6 +1294,7 @@ jobs: libpcre3 \ libpcre3-dbg \ libpcre3-dev \ + libpcre2-dev \ libpcap-dev \ libnet1-dev \ libyaml-0-2 \ @@ -1383,7 +1399,7 @@ jobs: with: msystem: MINGW64 update: true - install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool libyaml-devel pcre-devel jansson-devel make mingw-w64-x86_64-libyaml mingw-w64-x86_64-pcre mingw-w64-x86_64-rust mingw-w64-x86_64-jansson unzip p7zip python-setuptools mingw-w64-x86_64-python-yaml mingw-w64-x86_64-jq mingw-w64-x86_64-libxml2 + install: git mingw-w64-x86_64-toolchain automake1.16 automake-wrapper autoconf libtool libyaml-devel pcre-devel pcre2-devel jansson-devel make mingw-w64-x86_64-libyaml mingw-w64-x86_64-pcre mingw-w64-x86_64-pcre2 mingw-w64-x86_64-rust mingw-w64-x86_64-jansson unzip p7zip python-setuptools mingw-w64-x86_64-python-yaml mingw-w64-x86_64-jq mingw-w64-x86_64-libxml2 # hack: install our own cbindgen system wide as we can't get the # preinstalled one to be picked up by configure - name: cbindgen diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml index 17d80f6315..6386e45344 100644 --- a/.github/workflows/commits.yml +++ b/.github/workflows/commits.yml @@ -21,6 +21,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index fbf29f665a..94d633a013 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -31,6 +31,7 @@ jobs: apt -y install \ libpcre3 \ libpcre3-dev \ + libpcre2-dev \ build-essential \ autoconf \ automake \ diff --git a/configure.ac b/configure.ac index 5c5781feec..ef3dc0917c 100644 --- a/configure.ac +++ b/configure.ac @@ -637,6 +637,34 @@ exit 1 fi + PCRE2="" + AC_CHECK_LIB(pcre2-8, pcre2_compile_8,,PCRE2="no") + if test "$PCRE2" = "no"; then + echo + echo " ERROR! pcre2 library not found, go get it" + echo " from www.pcre.org. Or from packages:" + echo " Debian/Ubuntu: apt install libpcre2-dev" + echo " Fedora: dnf install pcre2-devel" + echo " CentOS/RHEL: yum install pcre2-devel" + echo + exit 1 + fi + + AC_DEFINE([PCRE2_CODE_UNIT_WIDTH], [8], [Pcre code unit width is 8 bits]) + AC_MSG_CHECKING(for PCRE2 JIT support) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], + [[ + int jit = 0; + pcre2_config(PCRE2_CONFIG_JIT, &jit); + ]])],[ pcre2_jit_available=yes ],[ pcre2_jit_available=no ] + ) + if test "x$pcre2_jit_available" = "xyes"; then + AC_MSG_RESULT(yes) + AC_DEFINE([PCRE2_HAVE_JIT], [1], [Pcre2 with JIT compiler support enabled]) + else + AC_MSG_RESULT(no) + fi + # libpcre 8.35 (especially on debian) has a known issue that results in segfaults # see https://redmine.openinfosecfoundation.org/issues/1693 if test "$with_libpcre_libraries" = "no"; then @@ -668,20 +696,6 @@ fi LIBS="${TMPLIBS}" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], - [[ int eo = 0; eo |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; ]])], - [ pcre_match_limit_recursion_available=yes ],[:] - ) - if test "$pcre_match_limit_recursion_available" != "yes"; then - echo - echo " Warning! pcre extra opt PCRE_EXTRA_MATCH_LIMIT_RECURSION not found" - echo " This could lead to potential DoS please upgrade to pcre >= 6.5" - echo " from www.pcre.org." - echo " Continuing for now...." - echo - AC_DEFINE([NO_PCRE_MATCH_RLIMIT],[1],[Pcre PCRE_EXTRA_MATCH_LIMIT_RECURSION not available]) - fi - TMPCFLAGS="${CFLAGS}" CFLAGS="-O0 -g -Werror -Wall" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], @@ -690,104 +704,6 @@ ) CFLAGS="${TMPCFLAGS}" - #enable support for PCRE-jit available since pcre-8.20 - AC_MSG_CHECKING(for PCRE JIT support) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], - [[ - int jit = 0; - pcre_config(PCRE_CONFIG_JIT, &jit); - ]])],[ pcre_jit_available=yes ],[ pcre_jit_available=no ] - ) - - case $host in - *powerpc64*) - PKG_CHECK_MODULES(LIBPCREVERSION, [libpcre = 8.39],[libpcre_ppc64_buggy_found1="yes"],[libprce_ppc64_buggy_found1="no"]) - PKG_CHECK_MODULES(LIBPCREVERSION, [libpcre = 8.40],[libpcre_ppc64_buggy_found2="yes"],[libprce_ppc64_buggy_found2="no"]) - - if test "$libprce_ppc64_buggy_found1" = "yes" || test "$libprce_ppc64_buggy_found2"; then - # on powerpc64, both gcc and clang lead to SIGILL in - # unittests when jit is enabled. - pcre_jit_available="no, pcre 8.39/8.40 jit disabled for powerpc64" - fi - # hack: use libatomic - LIBS="${LIBS} -latomic" - ;; - *) - # bug 1693, libpcre 8.35 is broken and debian jessie is still using that - if test "$libpcre_buggy_found" = "yes"; then - pcre_jit_available="no, libpcre 8.35 blacklisted" - fi - ;; - esac - - if test "x$pcre_jit_available" = "xyes"; then - AC_MSG_RESULT(yes) - AC_DEFINE([PCRE_HAVE_JIT], [1], [Pcre with JIT compiler support enabled]) - - AC_MSG_CHECKING(for PCRE JIT support usability) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], - [[ - const char *error; - int err_offset; - pcre *re = pcre_compile("(a|b|c|d)",0, &error, &err_offset,NULL); - pcre_extra *extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error); - if (extra == NULL) - exit(EXIT_FAILURE); - int jit = 0; - int ret = pcre_fullinfo(re, extra, PCRE_INFO_JIT, &jit); - if (ret != 0 || jit != 1) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); - ]])],[ pcre_jit_works=yes ],[:] - ) - if test "x$pcre_jit_works" != "xyes"; then - AC_MSG_RESULT(no) - echo - echo " PCRE JIT support detection worked but testing it failed" - echo " something odd is going on, please file a bug report." - echo - exit 1 - else - AC_MSG_RESULT(yes) - fi - else - AC_MSG_RESULT(no) - fi - - if test "x$pcre_jit_works" = "xyes"; then - - AC_MSG_CHECKING(for PCRE JIT exec availability) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [ - #include - #include - ], - [ - const char *error; - int err_offset; - pcre *re = pcre_compile("(a|b|c|d)", 0, &error, &err_offset,NULL); - pcre_extra *study = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error); - if (study == NULL) - exit(EXIT_FAILURE); - pcre_jit_stack *stack = pcre_jit_stack_alloc(32*1024,40*1024); - if (stack == 0) - exit(EXIT_FAILURE); - int ret = pcre_jit_exec(re, study, "apple", 5, 0, 0, NULL, 0, stack); - exit(ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE); - ])], - [pcre_jit_exec_available="yes" ], - [pcre_jit_exec_available="no" ]) - if test "x$pcre_jit_exec_available" != "xyes"; then - AC_MSG_RESULT(no) - else - AC_MSG_RESULT(yes) - AC_DEFINE([PCRE_HAVE_JIT_EXEC], [1], [PCRE with JIT compiler support enabled supporting pcre_jit_exec]) - fi - else - AC_MSG_RESULT(no) - fi - # libhs enable_hyperscan="no"