]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix endless loop if broken arc chain has been found
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Sep 2020 19:48:26 +0000 (20:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Sep 2020 19:48:53 +0000 (20:48 +0100)
src/libserver/dkim.c

index bd1854d5ddc9ee111f831d20673a7fffddda39e9..27db77c266db3b06918e5458c3495e8eddf3b8f1 100644 (file)
@@ -2342,13 +2342,18 @@ rspamd_dkim_canonize_header (struct rspamd_dkim_common_ctx *ctx,
                                id_len = rspamd_snprintf (idx_buf, sizeof (idx_buf), "i=%d;",
                                                count);
 
-                               for (cur = rh->prev;; cur = cur->prev) {
+                               for (cur = rh->prev; ; cur = cur->prev) {
                                        if (cur->decoded &&
                                                rspamd_substring_search (cur->decoded, strlen (cur->decoded),
                                                                idx_buf, id_len) != -1) {
                                                sel = cur;
                                                break;
                                        }
+
+                                       if (cur == rh) {
+                                               /* Cycle */
+                                               break;
+                                       }
                                }
 
                                if (sel == NULL) {