[tin-dev] [PATCH] base64 and CRLF spread over two lines

Dennis Preiser dennis at d--p.de
Sun Aug 23 10:33:06 CEST 2015


Hello,

in rfc2045.c:put_rest() we skip over CRLF only if they occur in the same
physical base64 encoded line (~270). If it is spread over two lines
(first line ends with '\r' and second line starts with '\n') the current
code leave it as it is.

The following article shows this issue:

| Newsgroups: de.alt.test,de.test
| Subject: Ignore - X-Prost🍻 und Fluppe²🚬...
| Followup-To: de.test
| Date: Sat, 22 Aug 2015 17:26:34 +0200
| Message-ID: <20150822172634.00001997 at peter.faust-solingen.dialin.t-online.de>
| Mime-Version: 1.0
| Content-Type: text/plain; charset=UTF-8
| Content-Transfer-Encoding: base64

Here is the point where CRLF was spread over two lines:

| lDNcm3b2aX/op+nSmz9Z8pxbBsIDRcW/9Ir+FBNO02CFam4ED2PstijMJ6YSb8yS
| EOHbdOnyuYF6F8Pcf3in2CdHOSq34RFgDlrE8Ie9w6qXlEY4TfCBBQ5Fx461RAtS^M
| 8nId41i21S1pqHy6vtEesguhPGwYU+IFDcSZKWxoRPyZQZosZwGW1fF3u93CygC3

                                                                  ^^

Attached a possible fix for this issue.

Dennis
-------------- next part --------------
diff -urp tin-2.3.1_r6/src/rfc2045.c tin-2.3.1_r7/src/rfc2045.c
--- tin-2.3.1_r6/src/rfc2045.c	2014-12-24 09:41:24.000000000 +0100
+++ tin-2.3.1_r7/src/rfc2045.c	2015-08-23 10:10:17.000000000 +0200
@@ -283,6 +283,11 @@ put_rest(
 	}
 	if (c == '\n') {
 		/*
+		 * Look for CRLF spread over two lines.
+		 */
+		if (put_chars && (*line)[put_chars -1] == '\r')
+			--put_chars;
+		/*
 		 * FIXME: Adding a newline may be not correct. At least it may
 		 * be not what the author of that article intended.
 		 * Unfortunately, a newline is expected at the end of a line by


More information about the tin-dev mailing list