@@ -3563,7 +3563,7 @@ rspamd_controller_accept_socket (EV_P_ ev_io *w, int revents) | |||
struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | |||
struct rspamd_controller_worker_ctx *ctx; | |||
struct rspamd_controller_session *session; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
gint nfd; | |||
ctx = worker->ctx; | |||
@@ -3576,6 +3576,7 @@ rspamd_controller_accept_socket (EV_P_ ev_io *w, int revents) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -3712,22 +3712,25 @@ rspamd_config_parse_ucl (struct rspamd_config *cfg, | |||
struct rspamd_cryptobox_keypair *decrypt_keypair = NULL; | |||
gchar *data; | |||
if (stat (filename, &st) == -1) { | |||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||
"cannot stat %s: %s", filename, strerror (errno)); | |||
return FALSE; | |||
} | |||
if ((fd = open (filename, O_RDONLY)) == -1) { | |||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||
"cannot open %s: %s", filename, strerror (errno)); | |||
return FALSE; | |||
} | |||
if (fstat (fd, &st) == -1) { | |||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||
"cannot stat %s: %s", filename, strerror (errno)); | |||
close (fd); | |||
return FALSE; | |||
} | |||
/* Now mmap this file to simplify reading process */ | |||
if ((data = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { | |||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||
"cannot mmap %s: %s", filename, strerror (errno)); | |||
close (fd); | |||
return FALSE; | |||
} | |||
@@ -3736,8 +3739,7 @@ rspamd_config_parse_ucl (struct rspamd_config *cfg, | |||
/* Try to load keyfile if available */ | |||
rspamd_snprintf (keypair_path, sizeof (keypair_path), "%s.key", | |||
filename); | |||
if (stat (keypair_path, &st) == -1 && | |||
(fd = open (keypair_path, O_RDONLY)) != -1) { | |||
if ((fd = open (keypair_path, O_RDONLY)) != -1) { | |||
struct ucl_parser *kp_parser; | |||
kp_parser = ucl_parser_new (0); | |||
@@ -3769,6 +3771,7 @@ rspamd_config_parse_ucl (struct rspamd_config *cfg, | |||
} | |||
ucl_parser_free (kp_parser); | |||
close (fd); | |||
} | |||
parser = ucl_parser_new (UCL_PARSER_SAVE_COMMENTS); | |||
@@ -4178,6 +4181,8 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg, | |||
cur = found; | |||
} | |||
} | |||
g_strfreev (path_components); | |||
} | |||
return rspamd_rcl_add_doc_obj (ucl_object_ref (cur), |
@@ -596,6 +596,8 @@ read_map_file_chunks (struct rspamd_map *map, struct map_cb_data *cbdata, | |||
if (lseek (fd, off, SEEK_SET) == -1) { | |||
msg_err_map ("can't seek in map to pos %d for buffered reading %s: %s", | |||
(gint)off, fname, strerror (errno)); | |||
close (fd); | |||
return FALSE; | |||
} | |||
@@ -1868,6 +1868,7 @@ rspamd_cdb_list_read (gchar *chunk, | |||
cdb = g_malloc0 (sizeof (struct cdb)); | |||
if (cdb_init (cdb, fd) == -1) { | |||
g_free (cdb); | |||
msg_err_map ("cannot init cdb map from %s: %s", chunk, strerror (errno)); | |||
return NULL; |
@@ -1213,6 +1213,9 @@ rspamd_stat_statistics (struct rspamd_task *task, | |||
if (target) { | |||
*target = res; | |||
} | |||
else { | |||
ucl_object_unref (res); | |||
} | |||
return RSPAMD_STAT_PROCESS_OK; | |||
} |
@@ -978,6 +978,12 @@ lua_http_request (lua_State *L) | |||
} | |||
if (ev_base == NULL) { | |||
g_free (auth); | |||
rspamd_http_message_unref (msg); | |||
if (body) { | |||
rspamd_fstring_free (body); | |||
} | |||
return luaL_error (L, | |||
"Bad params to rspamd_http:request(): ev_base isn't passed"); | |||
} |
@@ -664,6 +664,8 @@ lua_rsa_sign_memory (lua_State *L) | |||
signature->str, (guint *)&signature->len, rsa); | |||
if (ret != 1) { | |||
rspamd_fstring_free (signature); | |||
return luaL_error (L, "cannot sign: %s", | |||
ERR_error_string (ERR_get_error (), NULL)); | |||
} |
@@ -920,6 +920,10 @@ lua_text_split (lua_State *L) | |||
struct rspamd_lua_regexp *re; | |||
gboolean stringify = FALSE, own_re = FALSE; | |||
if (t == NULL) { | |||
return luaL_error (L, "invalid arguments"); | |||
} | |||
if (lua_type (L, 2) == LUA_TUSERDATA) { | |||
re = lua_check_regexp (L, 2); | |||
} | |||
@@ -947,7 +951,7 @@ lua_text_split (lua_State *L) | |||
own_re = TRUE; | |||
} | |||
if (t && re) { | |||
if (re) { | |||
if (lua_isboolean (L, 3)) { | |||
stringify = lua_toboolean (L, 3); | |||
} |
@@ -1169,6 +1169,8 @@ lua_url_cbdata_fill (lua_State *L, | |||
} | |||
else { | |||
msg_info ("bad url protocol: %s", *cvec); | |||
g_strfreev (strvec); | |||
return FALSE; | |||
} | |||
@@ -721,7 +721,7 @@ rspamadm_lua_accept_cb (EV_P_ ev_io *w, int revents) | |||
{ | |||
struct rspamadm_lua_repl_context *ctx = | |||
(struct rspamadm_lua_repl_context *)w->data; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
struct rspamadm_lua_repl_session *session; | |||
gint nfd; | |||
@@ -732,6 +732,7 @@ rspamadm_lua_accept_cb (EV_P_ ev_io *w, int revents) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -1212,7 +1212,7 @@ static void | |||
rspamd_control_handler (EV_P_ ev_io *w, int revents) | |||
{ | |||
struct rspamd_main *rspamd_main = (struct rspamd_main *)w->data; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
gint nfd; | |||
if ((nfd = | |||
@@ -1222,6 +1222,7 @@ rspamd_control_handler (EV_P_ ev_io *w, int revents) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -2185,7 +2185,7 @@ proxy_accept_socket (EV_P_ ev_io *w, int revents) | |||
{ | |||
struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | |||
struct rspamd_proxy_ctx *ctx; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
struct rspamd_proxy_session *session; | |||
gint nfd; | |||
@@ -2199,6 +2199,7 @@ proxy_accept_socket (EV_P_ ev_io *w, int revents) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -342,7 +342,7 @@ accept_socket (EV_P_ ev_io *w, int revents) | |||
struct rspamd_worker *worker = (struct rspamd_worker *) w->data; | |||
struct rspamd_worker_ctx *ctx; | |||
struct rspamd_worker_session *session; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
gint nfd, http_opts = 0; | |||
ctx = worker->ctx; | |||
@@ -362,6 +362,8 @@ accept_socket (EV_P_ ev_io *w, int revents) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -53,7 +53,7 @@ static void | |||
rspamd_server_accept (gint fd, short what, void *arg) | |||
{ | |||
struct rspamd_http_connection_router *rt = arg; | |||
rspamd_inet_addr_t *addr; | |||
rspamd_inet_addr_t *addr = NULL; | |||
gint nfd; | |||
if ((nfd = | |||
@@ -63,6 +63,7 @@ rspamd_server_accept (gint fd, short what, void *arg) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||
@@ -145,6 +145,7 @@ rspamd_server_accept (gint fd, short what, void *arg) | |||
} | |||
/* Check for EAGAIN */ | |||
if (nfd == 0) { | |||
rspamd_inet_address_free (addr); | |||
return; | |||
} | |||