diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-04 14:56:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-04 15:54:39 +0100 |
commit | 5d3677f48bf7b0493bab5cae6f7928f9a878f320 (patch) | |
tree | d3c028311c7e65079ee819510790bba24d29f45d /src/lua/lua_mimepart.c | |
parent | 2bf955712401df23751afdb5196b42ffa5fd6694 (diff) | |
download | rspamd-5d3677f48bf7b0493bab5cae6f7928f9a878f320.tar.gz rspamd-5d3677f48bf7b0493bab5cae6f7928f9a878f320.zip |
[Minor] Use proper hashing when getting texts fuzzy hash
Diffstat (limited to 'src/lua/lua_mimepart.c')
-rw-r--r-- | src/lua/lua_mimepart.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index 822df2f36..dd4e998a1 100644 --- a/src/lua/lua_mimepart.c +++ b/src/lua/lua_mimepart.c @@ -906,6 +906,8 @@ lua_textpart_get_fuzzy_hashes (lua_State * L) /* TODO: add short text support */ /* Calculate direct hash */ + rspamd_cryptobox_hash_init (&st, key, rspamd_cryptobox_HASHKEYBYTES); + for (i = 0; i < part->normalized_words->len; i ++) { word = &g_array_index (part->normalized_words, rspamd_stat_token_t, i); rspamd_cryptobox_hash_update (&st, word->begin, word->len); @@ -915,7 +917,7 @@ lua_textpart_get_fuzzy_hashes (lua_State * L) rspamd_encode_hex_buf (digest, sizeof (digest), hexdigest, sizeof (hexdigest)); - lua_pushstring (L, hexdigest); + lua_pushlstring (L, hexdigest, sizeof (hexdigest) - 1); sgl = rspamd_shingles_from_text (part->normalized_words, key, pool, lua_shingles_filter, part, RSPAMD_SHINGLES_MUMHASH); |