From: David Levine Date: Thu, 3 Jan 2013 02:07:43 +0000 (-0600) Subject: Fixed decoding of header fields when they contain a character that X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/3af3288f3acdfe29d3c17aefd9e0453ac3204541?hp=--cc Fixed decoding of header fields when they contain a character that can't be converted. Added test case to test-scan. valgrind also noticed that things went amiss. --- 3af3288f3acdfe29d3c17aefd9e0453ac3204541 diff --git a/docs/pending-release-notes b/docs/pending-release-notes index 6fe7f47c..1467018b 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -88,3 +88,5 @@ BUG FIXES - Fixed pick(1) to properly unfold multiple-line header fields by removing newlines instead of replacing them with spaces [Bug #15215]. - Removed the artificial limit of 1000 messages at a time for rmmproc. +- Fixed decoding of header fields when they contain a character that + can't be converted. diff --git a/sbr/fmt_rfc2047.c b/sbr/fmt_rfc2047.c index 4d3fc296..25c98c3d 100644 --- a/sbr/fmt_rfc2047.c +++ b/sbr/fmt_rfc2047.c @@ -303,8 +303,10 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) break; /* skip to next input character */ if (fromutf8) { - for (start++;(start < q) && ((*start & 192) == 128);start++) - inbytes--; + for (++start, --inbytes; + start < q && (*start & 192) == 128; + ++start, --inbytes) + continue; } else start++, inbytes--; if (start >= q) diff --git a/test/scan/test-scan b/test/scan/test-scan index 79ac85d5..7fd4b7bb 100755 --- a/test/scan/test-scan +++ b/test/scan/test-scan @@ -14,10 +14,10 @@ fi setup_test -expected=$MH_TEST_DIR/$$.expected -actual=$MH_TEST_DIR/$$.actual +expected="$MH_TEST_DIR/$$.expected" +actual="$MH_TEST_DIR/$$.actual" -cat > $expected <"$expected" <> 2 09/29 Test2 Testing message 2<> 3 09/29 Test3 Testing message 3<> @@ -30,12 +30,11 @@ cat > $expected <> EOF -scan +inbox -width 80 > $actual || exit 1 - +scan +inbox -width 80 >"$actual" || exit 1 check "$expected" "$actual" # check highlighting -cat > $expected <"$expected" <> 2 09/29 Test2 Testing message 2<> 3 09/29 Test3 Testing message 3<> @@ -51,8 +50,26 @@ EOF printf 'Unseen-Sequence: unseen\n' >> $MH mark -sequence cur 5 mark -sequence unseen 10 -scan -form scan.highlighted -width 80 > $actual || exit 1 +scan -form scan.highlighted -width 80 >"$actual" || exit 1 +check "$expected" "$actual" + +# check decoding with an invalid multibyte sequence. +cat >"$expected" <`mhpath new` < +To: Some User +Date: Mon, 31 Dec 2012 00:00:00 +Message-Id: 11@test.nmh +Subject: =?UTF-8?B?MjAxMyBOZXcgWWVhcuKAmXMgRGVhbHMhIFN0YXJ0IHRoZSB5ZWFy?= + =?UTF-8?B?IHJpZ2h0IHdpdGggYmlnIHNhdmluZ3M=?= +This message has an encoded Subject with an invalid character for the +ISO-8859-1 character set. +EOF +LC_CTYPE=ISO-8859-1 MM_CHARSET=ISO-8859-1 scan -width 75 last >"$actual" check "$expected" "$actual"