diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-05 18:56:59 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-05 18:56:59 +0000 |
commit | ae364403ff9e4c9ab0a9a1536c4ae683ee2eccf1 (patch) | |
tree | 9b460dad907a0219539afd7d07285953a9685e1d /src | |
parent | 9f8d613c23448ee723e08d6640640037df3f98b3 (diff) | |
download | rspamd-ae364403ff9e4c9ab0a9a1536c4ae683ee2eccf1.tar.gz rspamd-ae364403ff9e4c9ab0a9a1536c4ae683ee2eccf1.zip |
Fix study invocation.
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/regexp.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 06555f57f..8d023569c 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -28,6 +28,7 @@ #include "blake2.h" #include "ref.h" #include "util.h" +#include "main.h" #include <pcre.h> typedef guchar regexp_id_t[BLAKE2B_OUTBYTES]; @@ -144,6 +145,7 @@ rspamd_regexp_new (const gchar *pattern, const gchar *flags, return NULL; } flags = end + 1; + start ++; } } else { @@ -189,6 +191,7 @@ rspamd_regexp_new (const gchar *pattern, const gchar *flags, *flags_str, pattern); return NULL; } + msg_warn ("invalid flag '%c' in pattern %s", *flags_str, pattern); goto fin; break; } @@ -224,6 +227,11 @@ fin: res->re = r; res->raw_re = pcre_compile (pattern, regexp_flags & ~PCRE_UTF8, &err_str, &err_off, NULL); + + if (res->raw_re == NULL) { + msg_warn ("invalid raw regexp pattern: '%s': %s at position %d", + pattern, err_str, err_off); + } } if (!(rspamd_flags & RSPAMD_REGEXP_FLAG_NOOPT)) { @@ -233,18 +241,30 @@ fin: res->mtx = rspamd_mutex_new (); #endif if (res->re) { - res->extra = pcre_study (res->re, study_flags, NULL); + res->extra = pcre_study (res->re, study_flags, &err_str); + if (res->extra != NULL) { #ifdef HAVE_PCRE_JIT - res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024); - pcre_assign_jit_stack (res->extra, NULL, res->jstack); + res->jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024); + pcre_assign_jit_stack (res->extra, NULL, res->jstack); #endif + } + else { + msg_warn ("cannot optimize regexp pattern: '%s': %s", + pattern, err_str); + } } if (res->raw_re) { - res->raw_extra = pcre_study (res->raw_re, study_flags, NULL); + res->raw_extra = pcre_study (res->raw_re, study_flags, &err_str); + if (res->raw_extra != NULL) { #ifdef HAVE_PCRE_JIT - res->raw_jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024); - pcre_assign_jit_stack (res->raw_extra, NULL, res->raw_jstack); + res->raw_jstack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024); + pcre_assign_jit_stack (res->raw_extra, NULL, res->raw_jstack); #endif + } + else { + msg_warn ("cannot optimize raw regexp pattern: '%s': %s", + pattern, err_str); + } } } |