From a16bea0e74b6bd17f54cf296cf1807a1e83ab2da Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 21 Nov 2023 14:47:19 +0000 Subject: [PATCH] [Fix] Fix overflow in fuzzy_stats command --- src/fuzzy_storage.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index b8ee95c15..99d2ef1a1 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -1333,8 +1333,9 @@ rspamd_fuzzy_process_command(struct fuzzy_session *session) } else if (cmd->cmd == FUZZY_STAT) { result.v1.prob = 1.0f; - result.v1.value = 0; - result.v1.flag = session->ctx->stat.fuzzy_hashes; + /* Store high qword in value and low qword in flag */ + result.v1.value = (gint32) ((guint64) session->ctx->stat.fuzzy_hashes >> 32); + result.v1.flag = session->ctx->stat.fuzzy_hashes & G_MAXUINT32; rspamd_fuzzy_make_reply(cmd, &result, session, send_flags); } else if (cmd->cmd == FUZZY_PING) { -- 2.39.5