From 4a190e07a608633dc7c8e58ce6beab717399d677 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 2 Oct 2016 22:49:32 +0200 Subject: [PATCH] pcre: disable JIT if RWX pages not supported --- src/detect-pcre.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/detect-pcre.c b/src/detect-pcre.c index ed66a9f1e6..c9733deb62 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -57,6 +57,7 @@ #include "stream-tcp-reassemble.h" #include "app-layer-protos.h" #include "app-layer-parser.h" +#include "util-pages.h" #define PARSE_CAPTURE_REGEX "\\(\\?P\\<([A-z]+)\\_([A-z0-9_]+)\\>" #define PARSE_REGEX "(?sd = pcre_study(pd->re, PCRE_STUDY_JIT_COMPILE, &eb); + if (pcre_use_jit) + options |= PCRE_STUDY_JIT_COMPILE; +#endif + pd->sd = pcre_study(pd->re, options, &eb); if(eb != NULL) { SCLogError(SC_ERR_PCRE_STUDY, "pcre study failed : %s", eb); goto error; } +#ifdef PCRE_HAVE_JIT int jit = 0; ret = pcre_fullinfo(pd->re, pd->sd, PCRE_INFO_JIT, &jit); if (ret != 0 || jit != 1) { @@ -520,12 +538,6 @@ static DetectPcreData *DetectPcreParse (DetectEngineCtx *de_ctx, char *regexstr, "Falling back to regular PCRE handling (%s:%d)", regexstr, de_ctx->rule_file, de_ctx->rule_line); } -#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_JIT*/ if (pd->sd == NULL)