From 6a2fcfc30cb8b0051c10f6e5794565e3176dbe61 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 3 Jul 2017 08:52:31 +0100 Subject: [PATCH] [Fix] Do not cache SPF records with macros --- src/libserver/spf.c | 6 ++++++ src/plugins/spf.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libserver/spf.c b/src/libserver/spf.c index e8aa9cbab..a3a1b95f8 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -1580,6 +1580,12 @@ expand_spf_macro (struct spf_record *rec, struct spf_resolved_element *resolved, new = rspamd_mempool_alloc (task->task_pool, len + 1); + /* Reduce TTL to avoid caching of records with macros */ + if (rec->ttl != 0) { + rec->ttl = 0; + msg_debug_spf ("disable SPF caching as there is macro expansion"); + } + c = new; p = begin; state = 0; diff --git a/src/plugins/spf.c b/src/plugins/spf.c index 275f937ce..097df7329 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -529,7 +529,10 @@ spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task, l = spf_record_ref (record); - if (!record->temp_failed && !record->perm_failed && !record->na) { + if (record->ttl > 0 && + !record->temp_failed && + !record->perm_failed && + !record->na) { rspamd_lru_hash_insert (spf_module_ctx->spf_hash, record->domain, l, task->tv.tv_sec, record->ttl); -- 2.39.5