commit 32e5b11: [Fix] Fix endless loop if broken arc chain has been found

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Sep 29 19:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-09-29 20:48:26 +0100
URL: https://github.com/rspamd/rspamd/commit/32e5b11adfc3550bd4dfe50c3aaa2e96900af102 (HEAD -> master)

[Fix] Fix endless loop if broken arc chain has been found

---
 src/libserver/dkim.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index bd1854d5d..27db77c26 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -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) {


More information about the Commits mailing list