aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libutil/shingles.c4
-rw-r--r--test/rspamd_shingles_test.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c
index 6d33c7f26..9421c1529 100644
--- a/src/libutil/shingles.c
+++ b/src/libutil/shingles.c
@@ -69,7 +69,7 @@ rspamd_shingles_generate (GArray *input,
/* Init hashes pipes and keys */
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
hashes[i] = g_array_sized_new (FALSE, FALSE, sizeof (guint64),
- SHINGLES_WINDOW * 2);
+ input->len + SHINGLES_WINDOW);
/*
* To generate a set of hashes we just apply sha256 to the
* initial key as many times as many hashes are required and
@@ -80,7 +80,7 @@ rspamd_shingles_generate (GArray *input,
blake2b_final (&bs, shabuf, shalen);
for (j = 0; j < 16; j ++) {
- out_key[j] = shabuf[j] ^ shabuf[sizeof(shabuf) - j - 1];
+ out_key[j] = shabuf[j];
}
blake2b_init (&bs, BLAKE2B_OUTBYTES);
cur_key = out_key;
diff --git a/test/rspamd_shingles_test.c b/test/rspamd_shingles_test.c
index 44bc1e789..e6cd0abb3 100644
--- a/test/rspamd_shingles_test.c
+++ b/test/rspamd_shingles_test.c
@@ -107,7 +107,7 @@ test_case (gsize cnt, gsize max_len, gdouble perm_factor)
res = rspamd_shingles_compare (sgl, sgl_permuted);
- msg_debug ("percentage of common shingles: %.3f, generate time: %Hd usec",
+ msg_debug ("percentage of common shingles: %.3f, generate time: %hd usec",
res, ts_to_usec (&ts2) - ts_to_usec (&ts1));
g_assert_cmpfloat (fabs ((1.0 - res) - sqrt (perm_factor)), <=, 0.20);