From 716642909eb6cb263d9559f1f744192ac3b94af9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 11 Mar 2020 17:56:34 +0000 Subject: [Minor] Zero terminate id string --- src/libstat/learn_cache/redis_cache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c index 9b64cb622..bdf83f858 100644 --- a/src/libstat/learn_cache/redis_cache.c +++ b/src/libstat/learn_cache/redis_cache.c @@ -223,10 +223,15 @@ rspamd_stat_cache_redis_generate_id (struct rspamd_task *task) rspamd_cryptobox_hash_final (&st, out); b32out = rspamd_mempool_alloc (task->task_pool, + sizeof (out) * 8 / 5 + 3); + i = rspamd_encode_base32_buf (out, sizeof (out), b32out, sizeof (out) * 8 / 5 + 2); - rspamd_encode_base32_buf (out, sizeof (out), b32out, - sizeof (out) * 8 / 5 + 2); - g_assert (b32out != NULL); + + if (i > 0) { + /* Zero terminate */ + b32out[i] = '\0'; + } + rspamd_mempool_set_variable (task->task_pool, "words_hash", b32out, NULL); } -- cgit v1.2.3