@@ -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); |
@@ -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; | |||
} | |||
} |
@@ -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); | |||
} |
@@ -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; | |||
} |
@@ -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; | |||
} |
@@ -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); | |||
} | |||
} | |||
@@ -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) { |
@@ -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); |
@@ -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 (); |