diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-12-05 18:15:36 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-12-05 18:15:36 +0000 |
commit | 7ad02fc1f7e786a0db9f1e25f34d2771997a1c57 (patch) | |
tree | 470f0c331e79aaed299cd14ab9fb4c3951a082bd /src/lua/lua_cryptobox.c | |
parent | 23889da9ae115fbc23b43b856c06e94c12e3bb82 (diff) | |
download | rspamd-7ad02fc1f7e786a0db9f1e25f34d2771997a1c57.tar.gz rspamd-7ad02fc1f7e786a0db9f1e25f34d2771997a1c57.zip |
[Rework] Use xxh3 as a default hash and fix memory/alignment issues
Diffstat (limited to 'src/lua/lua_cryptobox.c')
-rw-r--r-- | src/lua/lua_cryptobox.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index f16fd8b67..7d1b8e4a9 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -1011,7 +1011,7 @@ lua_cryptobox_hash_dtor (struct rspamd_lua_cryptobox_hash *h) free (h->content.h); /* Allocated by posix_memalign */ } else { - g_free (h->content.fh); + rspamd_cryptobox_fast_hash_free (h->content.fh); } g_free (h); @@ -1023,7 +1023,7 @@ rspamd_lua_hash_init_default (struct rspamd_lua_cryptobox_hash *h, { h->type = LUA_CRYPTOBOX_HASH_BLAKE2; if (posix_memalign ((void **)&h->content.h, - _Alignof (rspamd_cryptobox_hash_state_t), + RSPAMD_ALIGNOF(rspamd_cryptobox_hash_state_t), sizeof (*h->content.h)) != 0) { g_assert_not_reached (); } @@ -1128,28 +1128,28 @@ rspamd_lua_hash_create (const gchar *type, const gchar *key, gsize keylen) } else if (g_ascii_strcasecmp (type, "xxh64") == 0) { h->type = LUA_CRYPTOBOX_HASH_XXHASH64; - h->content.fh = g_malloc0 (sizeof (*h->content.fh)); + h->content.fh = rspamd_cryptobox_fast_hash_new (); rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_XXHASH64, 0); h->out_len = sizeof (guint64); } else if (g_ascii_strcasecmp (type, "xxh32") == 0) { h->type = LUA_CRYPTOBOX_HASH_XXHASH32; - h->content.fh = g_malloc0 (sizeof (*h->content.fh)); + h->content.fh = rspamd_cryptobox_fast_hash_new (); rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_XXHASH32, 0); h->out_len = sizeof (guint32); } else if (g_ascii_strcasecmp (type, "mum") == 0) { h->type = LUA_CRYPTOBOX_HASH_MUM; - h->content.fh = g_malloc0 (sizeof (*h->content.fh)); + h->content.fh = rspamd_cryptobox_fast_hash_new (); rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_MUMHASH, 0); h->out_len = sizeof (guint64); } else if (g_ascii_strcasecmp (type, "t1ha") == 0) { h->type = LUA_CRYPTOBOX_HASH_T1HA; - h->content.fh = g_malloc0 (sizeof (*h->content.fh)); + h->content.fh = rspamd_cryptobox_fast_hash_new (); rspamd_cryptobox_fast_hash_init_specific (h->content.fh, RSPAMD_CRYPTOBOX_T1HA, 0); h->out_len = sizeof (guint64); |