summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-24 08:43:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-24 08:43:42 +0100
commit2f0c6e0f26c6d96442c24e54331c2939ca50127c (patch)
treed13f136708fc0513bb4e7cc224894ccdc635a950 /src
parente853ac873adbf4730f5c6593a410da310df35cac (diff)
downloadrspamd-2f0c6e0f26c6d96442c24e54331c2939ca50127c.tar.gz
rspamd-2f0c6e0f26c6d96442c24e54331c2939ca50127c.zip
[Minor] Prevent data corruption when dealing with signals
Diffstat (limited to 'src')
-rw-r--r--src/fuzzy_storage.c1
-rw-r--r--src/hs_helper.c1
-rw-r--r--src/libserver/rspamd_control.c1
-rw-r--r--src/libserver/worker_util.c7
-rw-r--r--src/log_helper.c1
-rw-r--r--src/lua/lua_common.c2
6 files changed, 11 insertions, 2 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 47b76fb9b..ad77c2848 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -2869,7 +2869,6 @@ start_fuzzy (struct rspamd_worker *worker)
/* Get peer pipe */
memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_SOCKETPAIR;
- srv_cmd.id = ottery_rand_uint64 ();
srv_cmd.cmd.spair.af = SOCK_DGRAM;
srv_cmd.cmd.spair.pair_num = worker->index;
memset (srv_cmd.cmd.spair.pair_id, 0, sizeof (srv_cmd.cmd.spair.pair_id));
diff --git a/src/hs_helper.c b/src/hs_helper.c
index 8e63469b1..390c5e25f 100644
--- a/src/hs_helper.c
+++ b/src/hs_helper.c
@@ -220,6 +220,7 @@ rspamd_rs_compile (struct hs_helper_ctx *ctx, struct rspamd_worker *worker,
ctx->loaded = TRUE;
}
+ memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_HYPERSCAN_LOADED;
rspamd_strlcpy (srv_cmd.cmd.hs_loaded.cache_dir, ctx->hs_dir,
sizeof (srv_cmd.cmd.hs_loaded.cache_dir));
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 279d47d6b..14a258828 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -1079,6 +1079,7 @@ rspamd_srv_send_command (struct rspamd_worker *worker,
g_assert (worker != NULL);
rd = g_slice_alloc0 (sizeof (*rd));
+ cmd->id = ottery_rand_uint64 ();
memcpy (&rd->cmd, cmd, sizeof (rd->cmd));
rd->handler = handler;
rd->ud = ud;
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 7753fa1b3..9791c1989 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -338,19 +338,23 @@ rspamd_worker_stop_accept (struct rspamd_worker *worker)
if (worker->accept_events != NULL) {
g_list_free (worker->accept_events);
}
-
+ /* XXX: we need to do it much later */
+#if 0
g_hash_table_iter_init (&it, worker->signal_events);
while (g_hash_table_iter_next (&it, &k, &v)) {
sigh = (struct rspamd_worker_signal_handler *)v;
g_hash_table_iter_steal (&it);
+
if (sigh->enabled) {
event_del (&sigh->ev);
}
+
g_free (sigh);
}
g_hash_table_unref (worker->signal_events);
+#endif
/* Cleanup maps */
for (cur = worker->srv->cfg->maps; cur != NULL; cur = g_list_next (cur)) {
@@ -820,6 +824,7 @@ rspamd_worker_monitored_on_change (struct rspamd_monitored_ctx *ctx,
rspamd_monitored_get_tag (m, tag);
ev_base = rspamd_monitored_ctx_get_ev_base (ctx);
+ memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_MONITORED_CHANGE;
rspamd_strlcpy (srv_cmd.cmd.monitored_change.tag, tag,
sizeof (srv_cmd.cmd.monitored_change.tag));
diff --git a/src/log_helper.c b/src/log_helper.c
index 9800ab9d3..0f98a5579 100644
--- a/src/log_helper.c
+++ b/src/log_helper.c
@@ -212,6 +212,7 @@ start_log_helper (struct rspamd_worker *worker)
exit (EXIT_SUCCESS);
}
+ memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_LOG_PIPE;
srv_cmd.cmd.log_pipe.type = RSPAMD_LOG_PIPE_SYMBOLS;
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 22d1f2446..e94cbe281 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1478,6 +1478,7 @@ rspamd_lua_cld_handler (struct rspamd_worker_signal_handler *sigh, void *ud)
g_free (cbdata);
/* Notify main */
+ memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_ON_FORK;
srv_cmd.cmd.on_fork.state = child_dead;
srv_cmd.cmd.on_fork.cpid = cbdata->cpid;
@@ -1679,6 +1680,7 @@ lua_worker_spawn_process (lua_State *L)
cbdata->cpid = pid;
cbdata->io_buf = g_string_sized_new (8);
/* Notify main */
+ memset (&srv_cmd, 0, sizeof (srv_cmd));
srv_cmd.type = RSPAMD_SRV_ON_FORK;
srv_cmd.cmd.on_fork.state = child_create;
srv_cmd.cmd.on_fork.cpid = pid;