summaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
commit1e08514471896e3b3069cdc25f457036d257cc68 (patch)
treeb591aa5d3eac5fec70d137d664ccc4b95db63cc4 /src/libserver
parent9068c5040e2737ce70f0cc9498000efa30c14c74 (diff)
downloadrspamd-1e08514471896e3b3069cdc25f457036d257cc68.tar.gz
rspamd-1e08514471896e3b3069cdc25f457036d257cc68.zip
Fix potential issues as found by coverity.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_rcl.c8
-rw-r--r--src/libserver/cfg_utils.c3
-rw-r--r--src/libserver/dynamic_cfg.c6
-rw-r--r--src/libserver/fuzzy_backend.c2
-rw-r--r--src/libserver/symbols_cache.c3
5 files changed, 8 insertions, 14 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 14ee4acca..f35dee92d 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -306,7 +306,7 @@ rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
}
val = ucl_object_find_key (obj, "group");
if (val != NULL) {
- ucl_object_tostring_safe (val, &group);
+ group = ucl_object_tostring (val);
}
val = ucl_object_find_key (obj, "one_shot");
if (val != NULL) {
@@ -2017,7 +2017,6 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
gchar *data;
GError *err = NULL;
struct rspamd_rcl_section *top, *logger;
- gboolean res;
struct ucl_parser *parser;
if (stat (filename, &st) == -1) {
@@ -2050,11 +2049,6 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
munmap (data, st.st_size);
cfg->rcl_obj = ucl_parser_get_object (parser);
ucl_parser_free (parser);
- res = TRUE;
-
- if (!res) {
- return FALSE;
- }
top = rspamd_rcl_config_init ();
err = NULL;
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index fef983758..b34873a2c 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -325,6 +325,7 @@ rspamd_config_calculate_checksum (struct rspamd_config *cfg)
}
if (stat (cfg->cfg_name, &st) == -1) {
msg_err ("cannot stat %s: %s", cfg->cfg_name, strerror (errno));
+ close (fd);
return FALSE;
}
@@ -365,7 +366,7 @@ rspamd_config_post_load (struct rspamd_config *cfg)
clock_getres (CLOCK_REALTIME, &ts);
# endif
- cfg->clock_res = (gint)log10 (1000000 / ts.tv_nsec);
+ cfg->clock_res = log10 (1000000. / ts.tv_nsec);
if (cfg->clock_res < 0) {
cfg->clock_res = 0;
}
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index c9e93a583..42174bcaa 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -289,11 +289,7 @@ dump_dynamic_config (struct rspamd_config *cfg)
dir = g_path_get_dirname (cfg->dynamic_conf);
if (dir == NULL) {
- /* Inaccessible path */
- if (dir != NULL) {
- g_free (dir);
- }
- msg_err ("invalid file: %s", cfg->dynamic_conf);
+ msg_err ("invalid path: %s", cfg->dynamic_conf);
return FALSE;
}
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index df35e0ccf..8de026fd6 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -524,6 +524,8 @@ rspamd_fuzzy_backend_open (const gchar *path, GError **err)
}
}
+ close (fd);
+
/* Open database */
if ((res = rspamd_fuzzy_backend_open_db (path, err)) == NULL) {
GError *tmp = NULL;
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index a50462a0c..5f6a2cd72 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -366,7 +366,7 @@ register_symbol_common (struct symbols_cache **cache,
/* Check whether this item is skipped */
skipped = TRUE;
- if (!item->is_callback &&
+ if (!item->is_callback && pcache->cfg &&
g_hash_table_lookup (pcache->cfg->metrics_symbols, name) == NULL) {
cur = g_list_first (pcache->cfg->metrics_list);
while (cur) {
@@ -595,6 +595,7 @@ init_symbols_cache (rspamd_mempool_t * pool,
if (lseek (fd, -(cklen), SEEK_END) == -1) {
if (errno == EINVAL) {
/* Try to create file */
+ close (fd);
msg_info ("recreate cache file");
if ((fd =
open (filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR |