diff options
author | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2017-09-10 18:03:14 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-09-20 05:48:54 +0000 |
commit | 4458d0b59f41382783820d90b99a5687ca0ccd33 (patch) | |
tree | 791dfa914f4ebea39faf6567281c82cc31813756 /epan/dissectors/snort-config.c | |
parent | a17bbc184170cf2faf4752f63f4dce0bba9e0dd5 (diff) |
Snort: check executable and config files exist before trying to run.
Change-Id: I63986a61b392a74406ccefeaa001c110793c340a
Reviewed-on: https://code.wireshark.org/review/23469
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/snort-config.c')
-rw-r--r-- | epan/dissectors/snort-config.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/epan/dissectors/snort-config.c b/epan/dissectors/snort-config.c index 7b5ea08019..9a05305eee 100644 --- a/epan/dissectors/snort-config.c +++ b/epan/dissectors/snort-config.c @@ -33,12 +33,6 @@ #include "snort-config.h" -/* #define SNORT_CONFIG_DEBUG */ -#ifdef SNORT_CONFIG_DEBUG -#define snort_debug_printf printf -#else -#define snort_debug_printf(...) -#endif #ifndef _WIN32 const char* g_file_separator = "/"; @@ -46,7 +40,6 @@ const char* g_file_separator = "/"; const char* g_file_separator = "\\"; #endif - /* Forward declaration */ static void parse_config_file(SnortConfig_t *snort_config, FILE *config_file_fd, const char *filename, const char *dirname, int recursion_level); @@ -320,12 +313,10 @@ void rule_set_relevant_vars(SnortConfig_t *snort_config, Rule_t *rule) /* Read source address */ field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE); - snort_debug_printf("source address is (%s)\n", field); rule_check_ip_vars(snort_config, rule, field); /* Read source port */ field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE); - snort_debug_printf("source port is (%s)\n", field); rule_check_port_vars(snort_config, rule, field); /* Read direction */ @@ -333,12 +324,10 @@ void rule_set_relevant_vars(SnortConfig_t *snort_config, Rule_t *rule) /* Dest address */ field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE); - snort_debug_printf("dest address is (%s)\n", field); rule_check_ip_vars(snort_config, rule, field); /* Dest port */ field = read_token(rule->rule_string+accumulated_length, ' ', &length, &accumulated_length, FALSE); - snort_debug_printf("dest port is (%s)\n", field); rule_check_port_vars(snort_config, rule, field); /* Set flag so won't do again for this rule */ @@ -557,7 +546,7 @@ static gboolean parse_include_file(SnortConfig_t *snort_config, char *line, cons g_snprintf(substituted_filename, 512, "%s%s%s", snort_config->rule_path, g_file_separator, - include_filename + 10); + include_filename + 11); } else { /* Rule path is relative to config directory, so it goes first */ @@ -566,7 +555,7 @@ static gboolean parse_include_file(SnortConfig_t *snort_config, char *line, cons g_file_separator, snort_config->rule_path, g_file_separator, - include_filename + 10); + include_filename + 11); } is_rule_file = TRUE; } @@ -582,7 +571,6 @@ static gboolean parse_include_file(SnortConfig_t *snort_config, char *line, cons } /* Try to open the file. */ - snort_debug_printf("Trying to open: %s\n", substituted_filename); new_config_fd = ws_fopen(substituted_filename, "r"); if (new_config_fd == NULL) { snort_debug_printf("Failed to open config file %s\n", substituted_filename); @@ -823,6 +811,7 @@ static gboolean parse_rule(SnortConfig_t *snort_config, char *line, const char * /* Add rule to map of rules. */ g_hash_table_insert(snort_config->rules, GUINT_TO_POINTER((guint)rule->sid), rule); + snort_debug_printf("Snort rule with SID=%u added to table\n", rule->sid); return TRUE; } @@ -835,8 +824,6 @@ static gboolean delete_rule(gpointer key _U_, Rule_t *rule = (Rule_t*)value; unsigned int n; - snort_debug_printf("delete_rule(value=%p)\n", value); - /* Delete strings on heap. */ g_free(rule->rule_string); g_free(rule->file); |