aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-22 23:39:49 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-22 23:39:49 +0000
commit4394fa14de48cf7000cd89d87f1b7829616ee7df (patch)
tree859f59cb1982d0cee6d78df48482872d33504d53 /src
parent2b0e6f4d0e0582006c172867df93121755201e66 (diff)
downloadrspamd-4394fa14de48cf7000cd89d87f1b7829616ee7df.tar.gz
rspamd-4394fa14de48cf7000cd89d87f1b7829616ee7df.zip
Fix some more issues found by coverity
Diffstat (limited to 'src')
-rw-r--r--src/libserver/url.c2
-rw-r--r--src/libutil/sqlite_utils.c10
-rw-r--r--src/libutil/util.c15
-rw-r--r--src/rspamadm/configdump.c1
-rw-r--r--src/rspamadm/signtool.c6
-rw-r--r--src/rspamd.c4
-rw-r--r--src/smtp_proxy.c2
7 files changed, 30 insertions, 10 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c
index b756b1ca4..fcb72a76b 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -1225,7 +1225,7 @@ rspamd_url_is_ip (struct rspamd_url *uri, rspamd_mempool_t *pool)
t = GUINT32_TO_BE (t);
break;
case 3:
- t = (GUINT32_TO_BE (t & 0xFFFFFFU) >> 8);
+ t = (GUINT32_TO_BE (t & 0xFFFFFFU)) >> 8;
break;
case 2:
t = GUINT16_TO_BE (t & 0xFFFFU);
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index 883d26580..452559c76 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -366,7 +366,9 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
sqlite3_close (sqlite);
rspamd_file_unlock (lock_fd, FALSE);
unlink (lock_path);
- close (lock_fd);
+ if (lock_fd != -1) {
+ close (lock_fd);
+ }
return NULL;
}
@@ -391,7 +393,11 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
#endif
rspamd_file_unlock (lock_fd, FALSE);
unlink (lock_path);
- close (lock_fd);
+
+ if (lock_fd != -1) {
+ close (lock_fd);
+ }
+
return NULL;
}
}
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 1d5f49a61..b0376ca1e 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -163,6 +163,7 @@ rspamd_inet_socket_create (gint type, struct addrinfo *addr, gboolean is_server,
{
gint fd = -1, r, optlen, on = 1, s_error;
struct addrinfo *cur;
+ gpointer ptr;
cur = addr;
while (cur) {
@@ -238,7 +239,8 @@ rspamd_inet_socket_create (gint type, struct addrinfo *addr, gboolean is_server,
break;
}
else if (fd != -1) {
- *list = g_list_prepend (*list, GINT_TO_POINTER (fd));
+ ptr = GINT_TO_POINTER (fd);
+ *list = g_list_prepend (*list, ptr);
cur = cur->ai_next;
continue;
}
@@ -249,6 +251,7 @@ out:
fd = -1;
cur = cur->ai_next;
}
+
return (fd);
}
@@ -475,6 +478,7 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
gint r, fd = -1, serrno;
gchar portbuf[8], **strv, **cur;
GList *result = NULL, *rcur;
+ gpointer ptr;
strv = g_strsplit_set (credits, ",", -1);
if (strv == NULL) {
@@ -510,7 +514,8 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
}
}
if (fd != -1) {
- result = g_list_prepend (result, GINT_TO_POINTER (fd));
+ ptr = GINT_TO_POINTER (fd);
+ result = g_list_prepend (result, ptr);
fd = -1;
}
else {
@@ -564,12 +569,16 @@ err:
serrno = errno;
rcur = result;
while (rcur != NULL) {
- fd = GPOINTER_TO_INT (rcur->data);
+ ptr = rcur->data;
+ fd = GPOINTER_TO_INT (ptr);
+
if (fd != -1) {
close (fd);
}
+
rcur = g_list_next (rcur);
}
+
if (result != NULL) {
g_list_free (result);
}
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index b48009466..e7d51b442 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -104,6 +104,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
if (ucl_object_lookup_len (comment_obj, (const char *)&obj,
sizeof (void *))) {
+ rspamd_fstring_free (comment);
/* Do not rewrite the existing comment */
return;
}
diff --git a/src/rspamadm/signtool.c b/src/rspamadm/signtool.c
index 998698622..ca426de6c 100644
--- a/src/rspamadm/signtool.c
+++ b/src/rspamadm/signtool.c
@@ -136,7 +136,9 @@ rspamadm_edit_file (const gchar *fname)
rspamd_snprintf (tmppath, sizeof (tmppath),
"%s/rspamd_sign-XXXXXXXXXX", tmpdir);
+ mode_t cur_umask = umask (S_IRWXO|S_IRWXG);
fd_out = mkstemp (tmppath);
+ (void)umask (cur_umask);
if (fd_out == -1) {
rspamd_fprintf (stderr, "cannot open tempfile %s: %s\n", tmppath,
@@ -213,7 +215,6 @@ rspamadm_edit_file (const gchar *fname)
rspamd_fprintf (stderr, "cannot map %s: %s\n", tmppath,
strerror (errno));
unlink (tmppath);
- close (fd_out);
exit (errno);
}
@@ -225,6 +226,7 @@ rspamadm_edit_file (const gchar *fname)
rspamd_fprintf (stderr, "cannot open new file %s: %s\n", run_cmdline,
strerror (errno));
unlink (tmppath);
+ munmap (map, len);
exit (errno);
}
@@ -234,11 +236,13 @@ rspamadm_edit_file (const gchar *fname)
unlink (tmppath);
unlink (run_cmdline);
close (fd_out);
+ munmap (map, len);
exit (errno);
}
unlink (tmppath);
(void)lseek (fd_out, 0, SEEK_SET);
+ munmap (map, len);
return fd_out;
}
diff --git a/src/rspamd.c b/src/rspamd.c
index a01b9db79..895cc63bf 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -336,13 +336,15 @@ create_listen_socket (GPtrArray *addrs, guint cnt, gint listen_type)
GList *result = NULL;
gint fd;
guint i;
+ gpointer p;
g_ptr_array_sort (addrs, rspamd_inet_address_compare_ptr);
for (i = 0; i < cnt; i ++) {
fd = rspamd_inet_address_listen (g_ptr_array_index (addrs, i),
listen_type, TRUE);
if (fd != -1) {
- result = g_list_prepend (result, GINT_TO_POINTER (fd));
+ p = GINT_TO_POINTER (fd);
+ result = g_list_prepend (result, p);
}
}
diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c
index 1a1e628b8..dca035993 100644
--- a/src/smtp_proxy.c
+++ b/src/smtp_proxy.c
@@ -642,7 +642,6 @@ smtp_dns_cb (struct rdns_reply *reply, void *arg)
struct smtp_proxy_session *session = arg;
gint res = 0;
struct rdns_reply_entry *elt;
- GList *cur;
switch (session->state)
{
@@ -703,7 +702,6 @@ smtp_dns_cb (struct rdns_reply *reply, void *arg)
session->resolved = TRUE;
break;
}
- cur = g_list_next (cur);
}
if (res == 0) {