From: Vsevolod Stakhov Date: Sat, 5 Nov 2016 22:17:55 +0000 (+0100) Subject: [Fix] Fix extraction of shingles from redis fuzzy storage X-Git-Tag: 1.4.0~107 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=05500cf6d5c100607f079759fadd1ccfe23a6fa7;p=rspamd.git [Fix] Fix extraction of shingles from redis fuzzy storage --- diff --git a/src/libserver/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend_redis.c index 74d368cb4..f585fa341 100644 --- a/src/libserver/fuzzy_backend_redis.c +++ b/src/libserver/fuzzy_backend_redis.c @@ -464,18 +464,19 @@ rspamd_fuzzy_backend_check_shingles (struct rspamd_fuzzy_redis_session *session) rspamd_fuzzy_redis_session_free_args (session); /* First of all check digest */ - session->nargs = 2 * session->cmd->shingles_count; + session->nargs = session->cmd->shingles_count + 1; session->argv = g_malloc (sizeof (gchar *) * session->nargs); session->argv_lens = g_malloc (sizeof (gsize) * session->nargs); shcmd = (const struct rspamd_fuzzy_shingle_cmd *)session->cmd; + session->argv[0] = g_strdup ("MGET"); + session->argv_lens[0] = 4; + for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) { key = g_string_new (session->backend->redis_object); rspamd_printf_gstring (key, "_%d_%uL", i, shcmd->sgl.hashes[i]); - session->argv[i * 2] = g_strdup ("GET"); - session->argv_lens[i * 2] = 3; - session->argv[i * 2 + 1] = key->str; - session->argv_lens[i * 2 + 1] = key->len; + session->argv[i] = key->str; + session->argv_lens[i] = key->len; g_string_free (key, FALSE); /* Do not free underlying array */ }