aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-12 13:56:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-12 13:56:06 +0100
commit7373423937593c5781bef430e4a17856ea3f75bc (patch)
tree50b358fa555d930f248a5280f064b6bbbbce8df8
parent274efffcbb21ea6fb32ee509b2449f69bcf98992 (diff)
downloadrspamd-7373423937593c5781bef430e4a17856ea3f75bc.tar.gz
rspamd-7373423937593c5781bef430e4a17856ea3f75bc.zip
[Fix] Include fuzzy key to distinguish storages with different keys
-rw-r--r--src/plugins/fuzzy_check.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 2596a1801..bf4cd3a0a 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -1072,8 +1072,12 @@ fuzzy_cmd_get_cached (struct fuzzy_rule *rule,
struct mime_text_part *part)
{
gchar key[32];
+ gint key_part;
+
+ memcpy (&key_part, rule->shingles_key->str, sizeof (key_part));
+ rspamd_snprintf (key, sizeof (key), "%p%s%d", part, rule->algorithm_str,
+ key_part);
- rspamd_snprintf (key, sizeof (key), "%p%s", part, rule->algorithm_str);
return rspamd_mempool_get_variable (pool, key);
}
@@ -1084,8 +1088,11 @@ fuzzy_cmd_set_cached (struct fuzzy_rule *rule,
struct rspamd_fuzzy_encrypted_shingle_cmd *data)
{
gchar key[32];
+ gint key_part;
- rspamd_snprintf (key, sizeof (key), "%p%s", part, rule->algorithm_str);
+ memcpy (&key_part, rule->shingles_key->str, sizeof (key_part));
+ rspamd_snprintf (key, sizeof (key), "%p%s%d", part, rule->algorithm_str,
+ key_part);
/* Key is copied */
rspamd_mempool_set_variable (pool, key, data, NULL);
}
@@ -1145,6 +1152,15 @@ fuzzy_cmd_from_text_part (struct fuzzy_rule *rule,
memcpy (&shcmd->sgl, sh, sizeof (shcmd->sgl));
shcmd->basic.shingles_count = RSPAMD_SHINGLE_SIZE;
}
+
+ /*
+ * We always save encrypted command as it can handle both
+ * encrypted and unencrypted requests.
+ *
+ * Since it is copied when obtained from the cache, it is safe to use
+ * it this way.
+ */
+ fuzzy_cmd_set_cached (rule, pool, part, encshcmd);
}
shcmd->basic.tag = ottery_rand_uint32 ();