From 5bde121754b0cb575ae588dc4fbc56152555d917 Mon Sep 17 00:00:00 2001 From: William Metcalf Date: Wed, 13 Jan 2010 07:59:34 -0600 Subject: [PATCH] --enable-gccprofile sets -pg flag detect presence of pcre recursion --- configure.in | 25 +++++++++++++++++++++++++ src/detect-pcre.c | 8 ++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 4c612fd46f..564160014f 100644 --- a/configure.in +++ b/configure.in @@ -158,6 +158,17 @@ AC_INIT(configure.in) CFLAGS="${CFLAGS} ${SECCFLAGS}" LDFLAGS="${LDFLAGS} ${SECLDFLAGS}" fi + +#enable profile generation + AC_ARG_ENABLE(gccprofile, + [ --enable-gccprofile Enable gcc profile info i.e -pg flag is set], + [ enable_gccprofile=yes + ]) + + if test "$enable_gccprofile" = "yes"; then + CFLAGS="${CFLAGS} -pg" + fi + #libpcre AC_ARG_WITH(libpcre_includes, [ --with-libpcre-includes=DIR libpcre include directory], @@ -187,6 +198,20 @@ AC_INIT(configure.in) exit 1 fi + AC_TRY_COMPILE([ #include ], + [ int eo; eo |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; ], + [ pcre_match_limit_recursion_available=yes ], [:] + ) + if test "$pcre_match_limit_recursion_available" != "yes"; then + CFLAGS="${CFLAGS} -DMISSING_PCRE_MATCH_RLIMIT" + 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 " Continuing for now...." + echo " from www.pcre.org." + echo + fi + #libyaml AC_ARG_WITH(libyaml_includes, [ --with-libyaml-includes=DIR libyaml include directory], diff --git a/src/detect-pcre.c b/src/detect-pcre.c index bb3ff17cb9..5724902d2b 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -358,21 +358,21 @@ DetectPcreData *DetectPcreParse (char *regexstr) pd->sd->match_limit = pcre_match_limit; pd->sd->flags |= PCRE_EXTRA_MATCH_LIMIT; } - +#ifndef MISSING_PCRE_MATCH_RLIMIT if(pcre_match_limit_recursion >= -1) { pd->sd->match_limit_recursion = pcre_match_limit_recursion; pd->sd->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; } - +#endif /* MISSING_PCRE_MATCH_RLIMIT */ } else { pd->sd->match_limit = MATCH_LIMIT_DEFAULT; pd->sd->flags |= PCRE_EXTRA_MATCH_LIMIT; - +#ifndef MISSING_PCRE_MATCH_RLIMIT pd->sd->match_limit_recursion = MATCH_LIMIT_DEFAULT; pd->sd->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; - +#endif /* MISSING_PCRE_MATCH_RLIMIT */ } }