commit dc7afbd: [CritFix] Distinguish socketpairs between different fuzzy workers
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Jun 10 12:56:13 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-06-10 13:54:35 +0100
URL: https://github.com/rspamd/rspamd/commit/dc7afbd65040bb286b369adb0e8510209accf4d2 (HEAD -> master)
[CritFix] Distinguish socketpairs between different fuzzy workers
---
src/fuzzy_storage.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 99e79e098..256241a95 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -2324,8 +2324,22 @@ start_fuzzy (struct rspamd_worker *worker)
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));
+ /* 6 bytes of id (including \0) and bind_conf id */
+ G_STATIC_ASSERT (sizeof (srv_cmd.cmd.spair.pair_id) >=
+ sizeof ("fuzzy") + sizeof (guint64));
+
memcpy (srv_cmd.cmd.spair.pair_id, "fuzzy", sizeof ("fuzzy"));
+ /* Distinguish workers from each others... */
+ if (worker->cf->bind_conf && worker->cf->bind_conf->bind_line) {
+ guint64 bind_hash = rspamd_cryptobox_fast_hash (worker->cf->bind_conf->bind_line,
+ strlen (worker->cf->bind_conf->bind_line), 0xdeadbabe);
+
+ /* 8 more bytes */
+ memcpy (srv_cmd.cmd.spair.pair_id + sizeof ("fuzzy"), &bind_hash,
+ sizeof (bind_hash));
+ }
+
rspamd_srv_send_command (worker, ctx->event_loop, &srv_cmd, -1,
fuzzy_peer_rep, ctx);
More information about the Commits
mailing list