commit 7166429: [Minor] Zero terminate id string
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Mar 11 18:00:18 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-03-11 17:56:34 +0000
URL: https://github.com/rspamd/rspamd/commit/716642909eb6cb263d9559f1f744192ac3b94af9 (HEAD -> master)
[Minor] Zero terminate id string
---
src/libstat/learn_cache/redis_cache.c | 11 ++++++++---
1 file 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);
}
More information about the Commits
mailing list