From 7b7813c46b74dae41901b74af7f3ca3830d1f285 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 5 Jan 2022 13:51:17 +0000 Subject: [PATCH] [Minor] Init xxhash3 state properly --- src/libcryptobox/cryptobox.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index 41f13ed73e..3caf364e65 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -1519,9 +1519,10 @@ void rspamd_cryptobox_fast_hash_init (rspamd_cryptobox_fast_hash_state_t *st, guint64 seed) { - XXH3_state_t *rst = (XXH3_state_t *)st->opaque; + XXH3_state_t *xst = (XXH3_state_t *)st->opaque; st->type = RSPAMD_CRYPTOBOX_XXHASH3; - XXH3_64bits_reset_withSeed (rst, seed); + XXH3_INITSTATE (xst); + XXH3_64bits_reset_withSeed (xst, seed); } void @@ -1540,6 +1541,7 @@ rspamd_cryptobox_fast_hash_init_specific (rspamd_cryptobox_fast_hash_state_t *st } case RSPAMD_CRYPTOBOX_XXHASH64: { XXH64_state_t *xst = (XXH64_state_t *) st->opaque; + memset(xst, 0, sizeof(*xst)); st->type = RSPAMD_CRYPTOBOX_XXHASH64; XXH64_reset (xst, seed); break; @@ -1547,6 +1549,7 @@ rspamd_cryptobox_fast_hash_init_specific (rspamd_cryptobox_fast_hash_state_t *st case RSPAMD_CRYPTOBOX_XXHASH32: { XXH32_state_t *xst = (XXH32_state_t *) st->opaque; + memset(xst, 0, sizeof(*xst)); st->type = RSPAMD_CRYPTOBOX_XXHASH32; XXH32_reset (xst, seed); break; @@ -1554,6 +1557,7 @@ rspamd_cryptobox_fast_hash_init_specific (rspamd_cryptobox_fast_hash_state_t *st case RSPAMD_CRYPTOBOX_XXHASH3: { XXH3_state_t *xst = (XXH3_state_t *) st->opaque; + XXH3_INITSTATE(xst); st->type = RSPAMD_CRYPTOBOX_XXHASH3; XXH3_64bits_reset_withSeed (xst, seed); break; -- 2.47.3