From 8cfdf6c666c409629d096345a3682c11373f075b Mon Sep 17 00:00:00 2001 From: Gurvinder Singh Date: Wed, 30 Dec 2009 20:21:25 +0530 Subject: [PATCH] bug 18 patch update --- src/detect.c | 23 +++++++---------------- src/util-error.c | 1 + src/util-error.h | 1 + src/util-rule-vars.c | 5 ++++- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/detect.c b/src/detect.c index e499cabf77..8fd0d87cb3 100644 --- a/src/detect.c +++ b/src/detect.c @@ -267,41 +267,32 @@ int SigLoadSignatures (DetectEngineCtx *de_ctx, char *sig_file) /* http_uri -- for uricontent */ sig = SigInit(de_ctx, "alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP GET URI cap\"; flow:to_server,established; content:\"GET \"; depth:4; pcre:\"/^GET (?P.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; noalert; sid:1;)"); - if (sig == NULL) { - SCLogError(SC_ERR_NO_RULES, "Is HTTP_PORTS variable defined in " - "configuration file"); + if (sig == NULL) return -1; - } prevsig = sig; de_ctx->sig_list = sig; sig = SigInit(de_ctx, "alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP POST URI cap\"; flow:to_server,established; content:\"POST \"; depth:5; pcre:\"/^POST (?P.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; noalert; sid:2;)"); - if (sig == NULL) { - SCLogError(SC_ERR_NO_RULES, "Is HTTP_PORTS variable defined in " - "configuration file"); + if (sig == NULL) return -1; - } + prevsig->next = sig; prevsig = sig; /* http_host -- for the log-httplog module */ sig = SigInit(de_ctx, "alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP host cap\"; flow:to_server,established; content:\"|0d 0a|Host:\"; pcre:\"/^Host: (?P.*)\\r\\n/m\"; noalert; sid:3;)"); - if (sig == NULL) { - SCLogError(SC_ERR_NO_RULES, "Is HTTP_PORTS variable defined in " - "configuration file"); + if (sig == NULL) return -1; - } + prevsig->next = sig; prevsig = sig; /* http_ua -- for the log-httplog module */ sig = SigInit(de_ctx, "alert tcp any any -> any $HTTP_PORTS (msg:\"HTTP UA cap\"; flow:to_server,established; content:\"|0d 0a|User-Agent:\"; pcre:\"/^User-Agent: (?P.*)\\r\\n/m\"; noalert; sid:4;)"); - if (sig == NULL) { - SCLogError(SC_ERR_NO_RULES, "Is HTTP_PORTS variable defined in " - "configuration file"); + if (sig == NULL) return -1; - } + prevsig->next = sig; /* ok, now let's load signature files from the general config */ diff --git a/src/util-error.c b/src/util-error.c index 08051ffb83..e9d43772ce 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -62,6 +62,7 @@ const char * SCErrorToString(SCError err) CASE_CODE (SC_ERR_FWRITE); CASE_CODE (SC_ERR_FOPEN); CASE_CODE (SC_ERR_THRESHOLD_HASH_ADD); + CASE_CODE (SC_ERR_UNDEFINED_VAR); default: return "UNKNOWN_ERROR"; } diff --git a/src/util-error.h b/src/util-error.h index ecf436313f..78753f6f3c 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -74,6 +74,7 @@ typedef enum { SC_ERR_UNIFIED2_ALERT_GENERIC_ERROR, SC_ERR_FWRITE, SC_ERR_THRESHOLD_HASH_ADD, + SC_ERR_UNDEFINED_VAR, } SCError; const char *SCErrorToString(SCError); diff --git a/src/util-rule-vars.c b/src/util-rule-vars.c index a41573ed3f..c3251e432b 100644 --- a/src/util-rule-vars.c +++ b/src/util-rule-vars.c @@ -72,8 +72,11 @@ char *SCRuleVarsGetConfVar(const char *conf_var_name, goto end; } - if (ConfGet(conf_var_full_name, &conf_var_full_name_value) != 1) + if (ConfGet(conf_var_full_name, &conf_var_full_name_value) != 1) { + SCLogError(SC_ERR_UNDEFINED_VAR, "Variable \"%s\" is not defined in " + "configuration file", conf_var_name); goto end; + } SCLogDebug("Value obtained from the yaml conf file, for the var " "\"%s\" is \"%s\"", conf_var_name, conf_var_full_name_value);