Blame SOURCES/patch.r7016

117356
Index: bogofilter/AUTHORS
117356
===================================================================
117356
--- bogofilter/AUTHORS	(revision 7015)
117356
+++ bogofilter/AUTHORS	(revision 7016)
117356
@@ -55,3 +55,4 @@
117356
 Marco Bozzolan
117356
 Paul Mangan
117356
 Roman Trunov
117356
+Julius Plenz
117356
Index: bogofilter/src/tests/inputs/t.passthrough-truncation-in.gz
117356
===================================================================
117356
Cannot display: file marked as a binary type.
117356
svn:mime-type = application/octet-stream
117356
Index: bogofilter/src/tests/inputs/t.passthrough-truncation-in.gz
117356
===================================================================
117356
--- bogofilter/src/tests/inputs/t.passthrough-truncation-in.gz	(nonexistent)
117356
+++ bogofilter/src/tests/inputs/t.passthrough-truncation-in.gz	(revision 7016)
117356
117356
Property changes on: bogofilter/src/tests/inputs/t.passthrough-truncation-in.gz
117356
___________________________________________________________________
117356
Added: svn:mime-type
117356
## -0,0 +1 ##
117356
+application/octet-stream
117356
\ No newline at end of property
117356
Index: bogofilter/src/tests/t.passthrough-truncation
117356
===================================================================
117356
--- bogofilter/src/tests/t.passthrough-truncation	(nonexistent)
117356
+++ bogofilter/src/tests/t.passthrough-truncation	(revision 7016)
117356
@@ -0,0 +1,19 @@
117356
+#! /bin/sh
117356
+
117356
+. ${srcdir:=.}/t.frame
117356
+
117356
+# t.passthrough-hb
117356
+#
117356
+#	test for correct passthrough of misdeclared MIME parts
117356
+#	test case provided by Julius Plenz, July 2014.
117356
+
117356
+gzip -c -d <"$srcdir/inputs/t.passthrough-truncation-in.gz" >"$TMPDIR/input"
117356
+$BOGOFILTER -e -p -C < "$TMPDIR/input" \
117356
+| $GREP -v "^X-Bogosity: Unsure," > "$TMPDIR/output"
117356
+
117356
+if  [ $verbose -eq 0 ]; then
117356
+    cmp "$TMPDIR/input" "$TMPDIR/output"
117356
+else
117356
+    set +e
117356
+    diff $DIFF_BRIEF "$TMPDIR/input" "$TMPDIR/output"
117356
+fi
117356
117356
Property changes on: bogofilter/src/tests/t.passthrough-truncation
117356
___________________________________________________________________
117356
Added: svn:executable
117356
## -0,0 +1 ##
117356
+*
117356
\ No newline at end of property
117356
Index: bogofilter/src/tests/Makefile.am
117356
===================================================================
117356
--- bogofilter/src/tests/Makefile.am	(revision 7015)
117356
+++ bogofilter/src/tests/Makefile.am	(revision 7016)
117356
@@ -35,7 +35,7 @@
117356
 	t.ignore_spam_header \
117356
 	t.nullstatsprefix \
117356
 	t.integrity t.integrity2 t.integrity3 \
117356
-	t.passthrough-hb \
117356
+	t.passthrough-hb t.passthrough-truncation \
117356
 	t.escaped.html t.escaped.url \
117356
 	t.base64 t.split t.parsing \
117356
 	t.lexer t.lexer.mbx t.lexer.qpcr t.lexer.eoh \
117356
@@ -97,6 +97,7 @@
117356
 	inputs/msg.split.dr.0118.base64 \
117356
 	inputs/msg.split.gs.0119.text \
117356
 	inputs/spam.mbx \
117356
+	inputs/t.passthrough-truncation-in.gz \
117356
 	outputs/MH.out \
117356
 	outputs/bogolex.out \
117356
 	outputs/bulkmode.out \
117356
Index: bogofilter/src/lexer.c
117356
===================================================================
117356
--- bogofilter/src/lexer.c	(revision 7015)
117356
+++ bogofilter/src/lexer.c	(revision 7016)
117356
@@ -220,15 +220,25 @@
117356
 
117356
 #ifndef	DISABLE_UNICODE
117356
     if (encoding == E_UNICODE &&
117356
-	!msg_state->mime_dont_decode)
117356
+	!msg_state->mime_dont_decode &&
117356
+        count > 0)
117356
     {
117356
 	iconvert(linebuff, buff);
117356
+
117356
+	/* If we return count = 0 here, the caller will think we have
117356
+	 * no more bytes left to read, even though before the iconvert
117356
+	 * call we had a positive number of bytes. This *will* lead to
117356
+	 * a message truncation which we try to avoid by simply
117356
+	 * returning the original input buffer (which has positive
117356
+	 * length) instead. */
117356
+	if(buff->t.leng == 0)
117356
+	    memcpy(buff, linebuff, sizeof(*buff));
117356
+
117356
 	/*
117356
 	 * iconvert, treating multi-byte sequences, can shrink or enlarge
117356
 	 * the output compared to its input.  Correct count.
117356
 	 */
117356
-	if (count > 0)
117356
-	    count = buff->t.leng;
117356
+	count = buff->t.leng;
117356
     }
117356
 #endif
117356
 
117356
Index: bogofilter/NEWS
117356
===================================================================
117356
--- bogofilter/NEWS	(revision 7015)
117356
+++ bogofilter/NEWS	(revision 7016)
117356
@@ -15,6 +15,13 @@
117356
 
117356
 -------------------------------------------------------------------------------
117356
 
117356
+	2014-07-10
117356
+
117356
+	* Take patch from Julius Plenz to fix a bug in the charset converter
117356
+	  that causes truncation of messages in pass-through mode in rare
117356
+	  circumstances, for instance, if binary data is misdeclared as
117356
+	  text/html.  Also add his test case, t.passthrough-truncation.
117356
+
117356
 	2013-11-30
117356
 
117356
 	* Updated autoconf/automake stuff so that tests work properly with