diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-03-11 17:56:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-03-11 17:56:34 +0000 |
commit | 716642909eb6cb263d9559f1f744192ac3b94af9 (patch) | |
tree | 5a3d504ec73442064030a383a6fe040135b2e1a6 /src/libstat | |
parent | 9200111bff45a2a8bea8c290ef16fe2859aecfea (diff) | |
download | rspamd-716642909eb6cb263d9559f1f744192ac3b94af9.tar.gz rspamd-716642909eb6cb263d9559f1f744192ac3b94af9.zip |
[Minor] Zero terminate id string
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/learn_cache/redis_cache.c | 11 |
1 files changed, 8 insertions, 3 deletions
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); } |