From d74fe520e5422d46e6e8204fd3bbee96de4846a9 Mon Sep 17 00:00:00 2001 From: William Date: Sat, 14 May 2011 11:56:11 -0500 Subject: [PATCH] Experimental support for PCRE-sljit enable via --enable-pcre-sljit --- configure.in | 34 ++++++++++++++++++++++++++++++++++ src/detect-pcre.c | 12 +++++++++++- src/suricata.c | 3 +++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 87461ebf5b..6b6519e839 100644 --- a/configure.in +++ b/configure.in @@ -290,6 +290,39 @@ AC_INIT(configure.in) echo fi + #enable suppot for PCRE-sljit http://sljit.sourceforge.net/pcre.html + AC_ARG_ENABLE(pcre-sljit, + AS_HELP_STRING([--enable-pcre-sljit], [Enable experimental support for PCRE-sljit]),,[enable_pcre_sljit=no]) + AS_IF([test "x$enable_pcre_sljit" = "xyes"], [ + AC_MSG_CHECKING(for PCRE sljit support) + AC_TRY_COMPILE([ #include ], + [ const char* regexstr = "(a|b|c|d)"; + pcre *re; + const char *error; + pcre_extra *extra; + int err_offset; + re = pcre_compile(regexstr,0, &error, &err_offset,NULL); + extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error); + if (!(extra->flags & PCRE_EXTRA_EXECUTABLE_FUNC)) { + printf("\nJIT compiler does not support: %s\n", regexstr); + } + return 0;], + [ pcre_sljit_available=yes ], [:] + ) + if test "$pcre_sljit_available" = "yes"; then + AC_MSG_RESULT(yes) + CFLAGS="${CFLAGS} -D_PCRE_HAVE_SLJIT" + else + AC_MSG_RESULT(no) + echo + echo " Error! --enable-pcre-sljit set but PCRE_STUDY_JIT_COMPILE not found" + echo " Make sure you use pcre found here " + echo " http://sljit.sourceforge.net/pcre.html" + echo + exit 1 + fi + + ]) #libyaml AC_ARG_WITH(libyaml_includes, [ --with-libyaml-includes=DIR libyaml include directory], @@ -897,4 +930,5 @@ Suricata Configuration: GCC Profile enabled: ${enable_gccprofile} Unified native time: ${enable_unified_native_timeval} Non-bundled htp: ${enable_non_bundled_htp} + PCRE sljit: ${enable_pcre_sljit} " diff --git a/src/detect-pcre.c b/src/detect-pcre.c index 4230eb506d..2c88b8538d 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -876,12 +876,22 @@ DetectPcreData *DetectPcreParse (char *regexstr) SCLogError(SC_ERR_PCRE_COMPILE, "pcre compile of \"%s\" failed at offset %" PRId32 ": %s", regexstr, eo, eb); goto error; } - +#ifdef PCRE_HAVE_SLJIT + pd->sd = pcre_study(pd->re, PCRE_STUDY_JIT_COMPILE, &eb); + if(eb != NULL) { + SCLogError(SC_ERR_PCRE_STUDY, "pcre study failed : %s", eb); + goto error; + } + if (!(pd->sd->flags & PCRE_EXTRA_EXECUTABLE_FUNC)) { + SCLogWarning(SC_ERR_PCRE_STUDY, "JIT compiler does not support: %s", regexstr); + } +#else pd->sd = pcre_study(pd->re, 0, &eb); if(eb != NULL) { SCLogError(SC_ERR_PCRE_STUDY, "pcre study failed : %s", eb); goto error; } +#endif /*PCRE_HAVE_SLJIT*/ if(pd->sd == NULL) pd->sd = (pcre_extra *) SCCalloc(1,sizeof(pcre_extra)); diff --git a/src/suricata.c b/src/suricata.c index 8f2916d473..d556c448b4 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -431,6 +431,9 @@ void SCPrintBuildInfo(void) { #endif #ifdef HAVE_HTP_URI_NORMALIZE_HOOK strlcat(features, "HAVE_HTP_URI_NORMALIZE_HOOK ", sizeof(features)); +#endif +#ifdef PCRE_HAVE_SLJIT + strlcat(features, "PCRE_SLJIT ", sizeof(features)); #endif if (strlen(features) == 0) { strlcat(features, "none", sizeof(features));