From: Alexander Gozman Date: Mon, 29 Jun 2015 17:46:15 +0000 (+0300) Subject: Fix issues #1493 and #1494 X-Git-Tag: suricata-3.0RC1~285 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d36eba4e5e378e5ea8dc3f1a760781f00502f6bb;p=thirdparty%2Fsuricata.git Fix issues #1493 and #1494 --- diff --git a/src/detect.c b/src/detect.c index 94e25a7d02..04fb11f17d 100644 --- a/src/detect.c +++ b/src/detect.c @@ -398,6 +398,7 @@ static int ProcessSigFiles(DetectEngineCtx *de_ctx, char *pattern, if (r == GLOB_NOMATCH) { SCLogWarning(SC_ERR_NO_RULES, "No rule files match the pattern %s", pattern); ++(st->bad_files); + ++(st->total_files); return -1; } else if (r != 0) { SCLogError(SC_ERR_OPENING_RULE_FILE, "error expanding template %s: %s", @@ -473,8 +474,14 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl TAILQ_FOREACH(file, &rule_files->head, next) { sfile = DetectLoadCompleteSigPath(de_ctx, file->val); good_sigs = bad_sigs = 0; - ProcessSigFiles(de_ctx, sfile, &sig_stat, &good_sigs, &bad_sigs); + ret = ProcessSigFiles(de_ctx, sfile, &sig_stat, &good_sigs, &bad_sigs); SCFree(sfile); + + if (ret != 0 || good_sigs == 0) { + if (de_ctx->failure_fatal == 1) { + exit(EXIT_FAILURE); + } + } } } } @@ -482,19 +489,21 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl /* If a Signature file is specified from commandline, parse it too */ if (sig_file != NULL) { - SCLogInfo("Loading rule file: %s", sig_file); - ++sig_stat.total_files; + ret = ProcessSigFiles(de_ctx, sig_file, &sig_stat, &good_sigs, &bad_sigs); - if (ProcessSigFiles(de_ctx, sig_file, &sig_stat, &good_sigs, &bad_sigs) != 0) { - ++sig_stat.bad_files; + if (ret != 0) { + if (de_ctx->failure_fatal == 1) { + exit(EXIT_FAILURE); + } } if (good_sigs == 0) { - SCLogWarning(SC_ERR_NO_RULES, "No rules loaded from %s", sig_file); - } + SCLogError(SC_ERR_NO_RULES, "No rules loaded from %s", sig_file); - sig_stat.good_sigs_total += good_sigs; - sig_stat.bad_sigs_total += bad_sigs; + if (de_ctx->failure_fatal == 1) { + exit(EXIT_FAILURE); + } + } } /* now we should have signatures to work with */