]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix DKIM: Handle lines with only spaces correctly 5662/head
authorCursor Agent <cursoragent@cursor.com>
Sat, 4 Oct 2025 12:23:40 +0000 (12:23 +0000)
committerCursor Agent <cursoragent@cursor.com>
Sat, 4 Oct 2025 12:23:40 +0000 (12:23 +0000)
Co-authored-by: v <v@rspamd.com>
src/libserver/dkim.c

index e9c86125b7b3091211106316635a9f70376f44c2..062ebeffc4dcc422c2a7380cff2924e93284e08c 100644 (file)
@@ -2178,11 +2178,16 @@ rspamd_dkim_skip_empty_lines(struct rspamd_task *task, struct rspamd_dkim_common
                case test_spaces:
                        t = p - skip;
 
-                       while (t >= start + 2 && (*t == ' ' || *t == '\t')) {
+                       while (t >= start && (*t == ' ' || *t == '\t')) {
                                t--;
                        }
 
-                       if (*t == '\r') {
+                       if (t < start) {
+                               /* The entire line (or body) is only spaces - treat as empty */
+                               p = start - 1;
+                               goto end;
+                       }
+                       else if (*t == '\r') {
                                p = t;
                                state = got_cr;
                        }