diff options
-rw-r--r-- | src/libserver/url.c | 2 | ||||
-rw-r--r-- | src/libutil/sqlite_utils.c | 10 | ||||
-rw-r--r-- | src/libutil/util.c | 15 | ||||
-rw-r--r-- | src/rspamadm/configdump.c | 1 | ||||
-rw-r--r-- | src/rspamadm/signtool.c | 6 | ||||
-rw-r--r-- | src/rspamd.c | 4 | ||||
-rw-r--r-- | src/smtp_proxy.c | 2 | ||||
-rw-r--r-- | utils/rspamd_http_bench.c | 6 | ||||
-rw-r--r-- | utils/rspamd_http_server.c | 4 |
9 files changed, 35 insertions, 15 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) { diff --git a/utils/rspamd_http_bench.c b/utils/rspamd_http_bench.c index 8007d891b..c9a752243 100644 --- a/utils/rspamd_http_bench.c +++ b/utils/rspamd_http_bench.c @@ -141,10 +141,10 @@ rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency, struct client_cbdata *cb; gint fd, flags; - g_assert ( - (fd = rspamd_inet_address_connect (addr, SOCK_STREAM, TRUE)) != -1); + fd = rspamd_inet_address_connect (addr, SOCK_STREAM, TRUE); + g_assert (fd != -1); flags = 1; - setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof (flags)); + (void)setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof (flags)); conn = rspamd_http_connection_new (rspamd_client_body, rspamd_client_err, rspamd_client_finish, RSPAMD_HTTP_CLIENT_SIMPLE, RSPAMD_HTTP_CLIENT, c); diff --git a/utils/rspamd_http_server.c b/utils/rspamd_http_server.c index f861b8a1f..ad01085df 100644 --- a/utils/rspamd_http_server.c +++ b/utils/rspamd_http_server.c @@ -191,8 +191,8 @@ rspamd_http_start_servers (pid_t *sfd, rspamd_inet_addr_t *addr) guint i; gint fd; - g_assert ( - (fd = rspamd_inet_address_listen (addr, SOCK_STREAM, TRUE)) != -1); + fd = rspamd_inet_address_listen (addr, SOCK_STREAM, TRUE); + g_assert (fd != -1); for (i = 0; i < nworkers; i++) { sfd[i] = fork (); |