aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libutil/shingles.c13
-rw-r--r--src/libutil/shingles.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c
index 653fa5356..3775b9e16 100644
--- a/src/libutil/shingles.c
+++ b/src/libutil/shingles.c
@@ -25,7 +25,7 @@
#include "fstring.h"
#include "siphash.h"
-#define SHINGLES_WINDOW 10
+#define SHINGLES_WINDOW 3
static void
rspamd_shingles_update_row (rspamd_fstring_t *in, struct siphash *h)
@@ -84,6 +84,7 @@ rspamd_shingles_generate (GArray *input,
g_checksum_reset (cksum);
cur_key = out_key;
out_key += 16;
+ memset (&h[i], 0, sizeof (h[0]));
sip24_init (&h[i], &keys[i]);
}
@@ -96,15 +97,17 @@ rspamd_shingles_generate (GArray *input,
rspamd_shingles_update_row (&g_array_index (input,
rspamd_fstring_t, j), h);
}
+ beg++;
/* Now we need to create a new row here */
for (j = 0; j < RSPAMD_SHINGLE_SIZE; j ++) {
guint64 val;
- val = sip24_final (&h[i]);
+ val = sip24_final (&h[j]);
/* Reinit siphash state */
- sip24_init (&h[i], &keys[i]);
- g_array_append_val (hashes[i], val);
+ memset (&h[j], 0, sizeof (h[0]));
+ sip24_init (&h[j], &keys[j]);
+ g_array_append_val (hashes[j], val);
}
}
}
@@ -148,5 +151,5 @@ gdouble rspamd_shingles_compare (const struct rspamd_shingle *a,
}
}
- return (gdouble)common / 84.0;
+ return (gdouble)common / (gdouble)RSPAMD_SHINGLE_SIZE;
}
diff --git a/src/libutil/shingles.h b/src/libutil/shingles.h
index 39e9cf38d..61b3b24c3 100644
--- a/src/libutil/shingles.h
+++ b/src/libutil/shingles.h
@@ -26,7 +26,7 @@
#include "config.h"
#include "mem_pool.h"
-#define RSPAMD_SHINGLE_SIZE 84
+#define RSPAMD_SHINGLE_SIZE 23
struct rspamd_shingle {
guint64 hashes[RSPAMD_SHINGLE_SIZE];