]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Distinguish socketpairs between different fuzzy workers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 10 Jun 2020 12:54:35 +0000 (13:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 10 Jun 2020 12:54:35 +0000 (13:54 +0100)
src/fuzzy_storage.c

index 99e79e098b8a6af3a7144110c6b481545d68f91c..256241a95cef79ce0ce24499bf4899d3ff71a1fa 100644 (file)
@@ -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);