]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Do not cache SPF records with macros
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jul 2017 07:52:31 +0000 (08:52 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jul 2017 07:52:31 +0000 (08:52 +0100)
src/libserver/spf.c
src/plugins/spf.c

index e8aa9cbab34bf17c47404280e6482a7efe682772..a3a1b95f82e00df57525dbc21eee84d49a3f8089 100644 (file)
@@ -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;
index 275f937ce12a9f694c276e51bcd9aa0bc2bc4456..097df7329eda2e6504061671881555d19aa5e569 100644 (file)
@@ -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);