Commit Diff


commit - a883a4eb6e3dabb9f721fdec649f4c8adeef51c5
commit + 1308710c42eefed9bb96098baf7016fbba862c7b
blob - 23586550f7df8b4304d89dc3753ea5fb8bfd1380
blob + f50b3d4247972a5acef89f987ce3e3d2bd7eea4b
--- main.c
+++ main.c
@@ -21,6 +21,7 @@
 
 #include <ctype.h>
 #include <err.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -583,6 +584,22 @@ dkim_parse_body(struct dkim_session *session, char *li
 {
 	size_t r, w;
 	size_t linelen;
+
+	if (canonbody == CANON_RELAXED) {
+		for (r = w = 0; line[r] != '\0'; r++) {
+			if (line[r] == ' ' || line[r] == '\t') {
+				if (r != 0 && line[w - 1] == ' ')
+					continue;
+				else
+					line[w++] = ' ';
+			} else
+				line[w++] = line[r];
+		}
+		linelen = line[w - 1] == ' ' ? w - 1 : w;
+		line[linelen] = '\0';
+	} else
+		linelen = strlen(line);
+
 	if (line[0] == '\0') {
 		session->body_whitelines++;
 		return;
@@ -595,22 +612,7 @@ dkim_parse_body(struct dkim_session *session, char *li
 		}
 	}
 	session->body_whitelines = 0;
-
 	session->has_body = 1;
-	if (canonbody == CANON_RELAXED) {
-		for (r = w = 0; line[r] != '\0'; r++) {
-			if (line[r] == ' ' || line[r] == '\t') {
-				if (r != 0 && line[w - 1] == ' ')
-					continue;
-				else
-					line[w++] = ' ';
-			} else
-				line[w++] = line[r];
-		}
-		linelen = line[w - 1] == ' ' ? w - 1 : w;
-		line[linelen] = '\0';
-	} else
-		linelen = strlen(line);
 
 	if (EVP_DigestUpdate(session->bh, line, linelen) == 0 ||
 	    EVP_DigestUpdate(session->bh, "\r\n", 2) == 0) {