]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix overflow in fuzzy_stats command
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 21 Nov 2023 14:47:19 +0000 (14:47 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 21 Nov 2023 14:47:19 +0000 (14:47 +0000)
src/fuzzy_storage.c

index b8ee95c15de3ad9c87b41298c5ffe000ddfe4f8e..99d2ef1a1d12373619330b84a712ffe86aecd0bd 100644 (file)
@@ -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) {