commit 7b7813c: [Minor] Init xxhash3 state properly

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jan 5 13:56:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-01-05 13:51:17 +0000
URL: https://github.com/rspamd/rspamd/commit/7b7813c46b74dae41901b74af7f3ca3830d1f285

[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 41f13ed73..3caf364e6 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;


More information about the Commits mailing list