aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-25 12:45:29 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-25 12:45:29 +0100
commitcf071c74aa8e7d2975b08a1271902401890c41f7 (patch)
treec9380a7702d1f1fc4db5012d3a413e30d11aabd6
parent0d0e9a7046cff4c7681d791a1275f906d4569d40 (diff)
downloadrspamd-cf071c74aa8e7d2975b08a1271902401890c41f7.tar.gz
rspamd-cf071c74aa8e7d2975b08a1271902401890c41f7.zip
[Minor] Fix some more issues
Found by: coverity scan
-rw-r--r--src/controller.c2
-rw-r--r--src/libserver/maps/map.c8
-rw-r--r--src/libserver/re_cache.c7
-rw-r--r--src/libutil/addr.c34
-rw-r--r--src/libutil/sqlite_utils.c2
5 files changed, 46 insertions, 7 deletions
diff --git a/src/controller.c b/src/controller.c
index 34685b92e..26fd1c9de 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -340,6 +340,8 @@ check_uncached:
/* We have some unknown salt here */
msg_info_ctx ("incorrect salt: %z, while %z expected",
salt_len, pbkdf->salt_len);
+ g_free (salt_decoded);
+
return FALSE;
}
diff --git a/src/libserver/maps/map.c b/src/libserver/maps/map.c
index eaf7958f8..d30b2b40d 100644
--- a/src/libserver/maps/map.c
+++ b/src/libserver/maps/map.c
@@ -2661,6 +2661,14 @@ err:
g_free (hdata);
}
+ if (fdata) {
+ g_free (fdata);
+ }
+
+ if (sdata) {
+ g_free (sdata);
+ }
+
return NULL;
}
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 4d631da01..82bbcee1c 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -1889,7 +1889,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
guint *hs_flags = NULL;
const hs_expr_ext_t **hs_exts = NULL;
gchar **hs_pats = NULL;
- gchar *hs_serialized;
+ gchar *hs_serialized = NULL;
gsize serialized_len;
struct iovec iov[7];
struct rspamd_re_cache *cache;
@@ -1918,7 +1918,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
/* Read number of regexps */
g_assert (fd != -1);
- lseek (fd, RSPAMD_HS_MAGIC_LEN + sizeof (cache->plt), SEEK_SET);
+ g_assert (lseek (fd, RSPAMD_HS_MAGIC_LEN + sizeof (cache->plt), SEEK_SET) != -1);
g_assert (read (fd, &n, sizeof (n)) == sizeof (n));
close (fd);
@@ -2212,6 +2212,9 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
(gint)g_hash_table_size (re_class->re),
path);
+ g_free (hs_serialized);
+ g_free (hs_ids);
+ g_free (hs_flags);
unlink (path);
close (fd);
rspamd_re_cache_compile_err (EV_A_ w, err, cbdata);
diff --git a/src/libutil/addr.c b/src/libutil/addr.c
index fd628aaca..b19182514 100644
--- a/src/libutil/addr.c
+++ b/src/libutil/addr.c
@@ -336,6 +336,12 @@ rspamd_parse_unix_path (rspamd_inet_addr_t **target,
tokens = rspamd_string_len_split (src, len, " ,", -1, pool);
if (tokens[0] == NULL) {
+
+ if (!pool) {
+ rspamd_inet_address_free(addr);
+ g_strfreev (tokens);
+ }
+
return FALSE;
}
@@ -351,6 +357,17 @@ rspamd_parse_unix_path (rspamd_inet_addr_t **target,
#if defined(FREEBSD) || defined(__APPLE__)
addr->u.un->addr.sun_len = SUN_LEN (&addr->u.un->addr);
#endif
+
+ if (target) {
+ rspamd_ip_validate_af (addr);
+ *target = addr;
+ }
+ else {
+ if (!pool) {
+ rspamd_inet_address_free(addr);
+ }
+ }
+
return TRUE;
}
@@ -415,24 +432,29 @@ rspamd_parse_unix_path (rspamd_inet_addr_t **target,
}
g_free (pwbuf);
- g_strfreev (tokens);
+
+ if (!pool) {
+ g_strfreev(tokens);
+ }
if (target) {
rspamd_ip_validate_af (addr);
*target = addr;
}
else {
- rspamd_inet_address_free (addr);
+ if (!pool) {
+ rspamd_inet_address_free(addr);
+ }
}
return TRUE;
err:
- g_strfreev (tokens);
g_free (pwbuf);
if (!pool) {
+ g_strfreev(tokens);
rspamd_inet_address_free (addr);
}
@@ -1302,7 +1324,7 @@ rspamd_resolve_addrs (const char *begin, size_t len, GPtrArray **addrs,
rspamd_ip_check_ipv6 ();
if (rspamd_parse_inet_address (&cur_addr,
- begin, len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) {
+ begin, len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT) && cur_addr != NULL) {
if (*addrs == NULL) {
*addrs = g_ptr_array_new_full (1,
(GDestroyNotify) rspamd_inet_address_free);
@@ -1391,6 +1413,10 @@ rspamd_resolve_addrs (const char *begin, size_t len, GPtrArray **addrs,
}
}
+ if (pool == NULL) {
+ g_free (addr_cpy);
+ }
+
return ret;
}
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index f9e47032c..9bb0b9c1f 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -356,7 +356,7 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
else {
pid_t myself = getpid ();
msg_debug_pool_check ("locking %s to block other processes", lock_path);
- (void) !write (lock_fd, &myself, sizeof (myself));
+ (void)write (lock_fd, &myself, sizeof (myself));
g_assert (rspamd_file_lock (lock_fd, FALSE));
has_lock = TRUE;