From: Vsevolod Stakhov Date: Wed, 10 Jun 2020 12:54:35 +0000 (+0100) Subject: [CritFix] Distinguish socketpairs between different fuzzy workers X-Git-Tag: 2.6~334 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc7afbd65040bb286b369adb0e8510209accf4d2;p=thirdparty%2Frspamd.git [CritFix] Distinguish socketpairs between different fuzzy workers --- diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 99e79e098b..256241a95c 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);