mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Makes JIT support in PCRE to be optional
In particular, this change allows to build libmodsecurity on some old but still supported systems such as RHEL/CentOS 6.
This commit is contained in:
parent
13b6a3ecf6
commit
ae8698d8cf
@ -65,6 +65,31 @@ else
|
|||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -n "${PCRE_VERSION}"; then
|
||||||
|
AC_MSG_CHECKING(for PCRE JIT)
|
||||||
|
save_CFLAGS=$CFLAGS
|
||||||
|
save_LDFLAGS=$LDFLAGS
|
||||||
|
CFLAGS="${PCRE_CFLAGS} ${CFLAGS}"
|
||||||
|
LDFLAGS="${LDFLAGS} ${PCRE_LDADD}"
|
||||||
|
AC_TRY_COMPILE([ #include <stdio.h>
|
||||||
|
#include <pcre.h> ],
|
||||||
|
[ int jit = 0;
|
||||||
|
pcre_free_study(NULL);
|
||||||
|
pcre_config(PCRE_CONFIG_JIT, &jit);
|
||||||
|
if (jit != 1) return 1; ],
|
||||||
|
[ pcre_jit_available=yes ], [:]
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "x$pcre_jit_available" = "xyes"; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
PCRE_CFLAGS="${PCRE_CFLAGS} -DPCRE_HAVE_JIT"
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
CFLAGS=$save_CFLAGS
|
||||||
|
LDFLAGS=$save_$LDFLAGS
|
||||||
|
fi
|
||||||
|
|
||||||
AC_SUBST(PCRE_CONFIG)
|
AC_SUBST(PCRE_CONFIG)
|
||||||
AC_SUBST(PCRE_VERSION)
|
AC_SUBST(PCRE_VERSION)
|
||||||
AC_SUBST(PCRE_CPPFLAGS)
|
AC_SUBST(PCRE_CPPFLAGS)
|
||||||
|
@ -22,6 +22,12 @@
|
|||||||
|
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
|
|
||||||
|
#if PCRE_HAVE_JIT
|
||||||
|
#define pcre_study_opt PCRE_STUDY_JIT_COMPILE
|
||||||
|
#else
|
||||||
|
#define pcre_study_opt 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace operators {
|
namespace operators {
|
||||||
@ -32,7 +38,11 @@ VerifyCC::~VerifyCC() {
|
|||||||
m_pc = NULL;
|
m_pc = NULL;
|
||||||
}
|
}
|
||||||
if (m_pce != NULL) {
|
if (m_pce != NULL) {
|
||||||
|
#if PCRE_HAVE_JIT
|
||||||
pcre_free_study(m_pce);
|
pcre_free_study(m_pce);
|
||||||
|
#else
|
||||||
|
pcre_free(m_pce);
|
||||||
|
#endif
|
||||||
m_pce = NULL;
|
m_pce = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +100,7 @@ bool VerifyCC::init(const std::string ¶m2, std::string *error) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pce = pcre_study(m_pc, PCRE_STUDY_JIT_COMPILE, &errptr);
|
m_pce = pcre_study(m_pc, pcre_study_opt, &errptr);
|
||||||
if (m_pce == NULL) {
|
if (m_pce == NULL) {
|
||||||
if (errptr == NULL) {
|
if (errptr == NULL) {
|
||||||
/*
|
/*
|
||||||
|
@ -27,6 +27,12 @@
|
|||||||
|
|
||||||
#include "utils/geo_lookup.h"
|
#include "utils/geo_lookup.h"
|
||||||
|
|
||||||
|
#if PCRE_HAVE_JIT
|
||||||
|
#define pcre_study_opt PCRE_STUDY_JIT_COMPILE
|
||||||
|
#else
|
||||||
|
#define pcre_study_opt 0
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@ -42,7 +48,7 @@ Regex::Regex(const std::string& pattern_)
|
|||||||
|
|
||||||
m_pc = pcre_compile(pattern.c_str(), PCRE_DOTALL|PCRE_MULTILINE,
|
m_pc = pcre_compile(pattern.c_str(), PCRE_DOTALL|PCRE_MULTILINE,
|
||||||
&errptr, &erroffset, NULL);
|
&errptr, &erroffset, NULL);
|
||||||
m_pce = pcre_study(m_pc, PCRE_STUDY_JIT_COMPILE, &errptr);
|
m_pce = pcre_study(m_pc, pcre_study_opt, &errptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +58,11 @@ Regex::~Regex() {
|
|||||||
m_pc = NULL;
|
m_pc = NULL;
|
||||||
}
|
}
|
||||||
if (m_pce != NULL) {
|
if (m_pce != NULL) {
|
||||||
|
#if PCRE_HAVE_JIT
|
||||||
pcre_free_study(m_pce);
|
pcre_free_study(m_pce);
|
||||||
|
#else
|
||||||
|
pcre_free(m_pce);
|
||||||
|
#endif
|
||||||
m_pce = NULL;
|
m_pce = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user