summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-04-30 18:26:49 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-04-30 18:37:06 +0200
commitf53e8dc6721d55704fd7d6bd4bd238e42551deff (patch)
treeafd1597d6fb311de18d7ca38cf585b3cbc53ba96
parentb57c2d9b096321f3bd17e5a8fad7f919318dc2b1 (diff)
downloadmblaze-f53e8dc6721d55704fd7d6bd4bd238e42551deff.tar.gz
mblaze-f53e8dc6721d55704fd7d6bd4bd238e42551deff.tar.xz
mblaze-f53e8dc6721d55704fd7d6bd4bd238e42551deff.zip
mmime: check: allow up to 998 chars in header lines
-rw-r--r--mmime.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/mmime.c b/mmime.c
index 9a359a3..1112a51 100644
--- a/mmime.c
+++ b/mmime.c
@@ -371,15 +371,33 @@ check()
 	off_t bithigh = 0;
 	off_t bitlow = 0;
 	off_t linelen = 0;
-	off_t maxlinelen = 0;
+	off_t maxheadlinelen = 0;
+	off_t maxbodylinelen = 0;
 
 	int c;
 	int l = -1;
 
 	while ((c = getchar()) != EOF) {
 		if (c == '\n') {
-			if (maxlinelen < linelen)
-				maxlinelen = linelen;
+			if (maxheadlinelen < linelen)
+				maxheadlinelen = linelen;
+			linelen = 0;
+			if (l == '\n')
+				break;
+		} else {
+			linelen++;
+		}
+		if (c != '\t' && c != '\n' && c < 32)
+			bitlow++;
+		if (c > 127)
+			bithigh++;
+		l = c;
+	}
+
+	while ((c = getchar()) != EOF) {
+		if (c == '\n') {
+			if (maxbodylinelen < linelen)
+				maxbodylinelen = linelen;
 			linelen = 0;
 		} else {
 			linelen++;
@@ -391,7 +409,9 @@ check()
 		l = c;
 	}
 
-	if (bitlow == 0 && bithigh == 0 && maxlinelen <= 78 && l == '\n')
+	if (bitlow == 0 && bithigh == 0 &&
+	    maxheadlinelen < 998 && maxbodylinelen <= 78 &&
+	    l == '\n')
 		return 0;
 	else
 		return 1;