From f2b1e66a6a4105c182f3f46f89d0faefa971d653 Mon Sep 17 00:00:00 2001 From: Will Metcalf Date: Wed, 30 Dec 2009 22:09:28 -0600 Subject: [PATCH] fixes for init failure stuff --- src/detect-parse.c | 9 ++++++--- src/suricata.c | 2 +- src/util-error.c | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/detect-parse.c b/src/detect-parse.c index f6dd54e97b..8c4aa1e48a 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -663,13 +663,12 @@ Signature *SigInit(DetectEngineCtx *de_ctx, char *sigstr) { return sig; error: - SigFree(sig); + if ( sig != NULL ) SigFree(sig); if (de_ctx->failure_fatal == 1) { - fprintf(stderr, "ERROR: Signature init failed.\n"); + SCLogError(SC_ERR_INVALID_SIGNATURE,"Signature init failed %s ",sigstr); exit(EXIT_FAILURE); } return NULL; - } /** @@ -846,6 +845,10 @@ Signature *DetectEngineAppendSig(DetectEngineCtx *de_ctx, char *sigstr) { error: if ( sig != NULL ) SigFree(sig); + if (de_ctx->failure_fatal == 1) { + SCLogError(SC_ERR_INVALID_SIGNATURE,"Signature init failed %s ",sigstr); + exit(EXIT_FAILURE); + } return NULL; } diff --git a/src/suricata.c b/src/suricata.c index 71fdb11f95..f14f94431f 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -273,9 +273,9 @@ void usage(const char *progname) printf("\t-u : run the unittests and exit\n"); printf("\t-U, --unittest-filter=REGEX : filter unittests with a regex\n"); printf("\t--list-unittests : list unit tests\n"); - printf("\t--init-errors-fatal : enable fatal failure on signature init error\n"); printf("\t--fatal-unittests : enable fatal failure on unittest error\n"); #endif /* UNITTESTS */ + printf("\t--init-errors-fatal : enable fatal failure on signature init error\n"); printf("\n"); printf("\nTo run the engine with default configuration on " "interface eth0 with signature file \"signatures.rules\", run the " diff --git a/src/util-error.c b/src/util-error.c index a40872b94b..fe6c19ac0f 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -25,6 +25,7 @@ const char * SCErrorToString(SCError err) CASE_CODE (SC_PCRE_PARSE_FAILED); CASE_CODE (SC_LOG_MODULE_NOT_INIT); CASE_CODE (SC_LOG_FG_FILTER_MATCH_FAILED); + CASE_CODE (SC_ERR_INVALID_SIGNATURE); CASE_CODE (SC_ERR_OPENING_FILE); CASE_CODE (SC_ERR_OPENING_RULE_FILE); CASE_CODE (SC_ERR_NO_RULES);