From: Victor Julien Date: Fri, 19 Apr 2013 08:02:36 +0000 (+0200) Subject: Coverity 1005133: fix unlikely case where malformed pcre statement in rule would... X-Git-Tag: suricata-2.0beta1~172 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e45f683c19df0713b8be80d68aad575c8d86f8b3;p=thirdparty%2Fsuricata.git Coverity 1005133: fix unlikely case where malformed pcre statement in rule would lead to null-deref. --- diff --git a/src/detect-pcre.c b/src/detect-pcre.c index 6f6049fe85..65bf959706 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -288,12 +288,10 @@ DetectPcreData *DetectPcreParse (DetectEngineCtx *de_ctx, char *regexstr) ret = pcre_exec(parse_regex, parse_regex_study, regexstr + pos, slen-pos, 0, 0, ov, MAX_SUBSTRINGS); - if (ret < 0) { - SCLogError(SC_ERR_PCRE_MATCH, "parse error"); + if (ret <= 0) { + SCLogError(SC_ERR_PCRE_MATCH, "pcre parse error: %s", regexstr); goto error; - } - - if (ret > 1) { + } else { const char *str_ptr; res = pcre_get_substring((char *)regexstr + pos, ov, MAX_SUBSTRINGS, 1, &str_ptr);