dovecot-2.2: lib-mail: quoted-printable decoder istream shouldn'...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Dec 4 11:40:48 EET 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/4d382ee358fb
changeset: 15450:4d382ee358fb
user: Timo Sirainen <tss at iki.fi>
date: Tue Dec 04 11:40:35 2012 +0200
description:
lib-mail: quoted-printable decoder istream shouldn't treat trailing "=" as error.
diffstat:
src/lib-mail/istream-qp-decoder.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diffs (42 lines):
diff -r b3f14d2d2019 -r 4d382ee358fb src/lib-mail/istream-qp-decoder.c
--- a/src/lib-mail/istream-qp-decoder.c Tue Dec 04 11:33:16 2012 +0200
+++ b/src/lib-mail/istream-qp-decoder.c Tue Dec 04 11:40:35 2012 +0200
@@ -70,6 +70,8 @@
{
struct qp_decoder_istream *bstream =
(struct qp_decoder_istream *)stream;
+ const unsigned char *data;
+ size_t size;
size_t pre_count, post_count;
int ret;
size_t prev_size = 0;
@@ -77,12 +79,24 @@
do {
ret = i_stream_read_parent(stream, &prev_size);
if (ret <= 0) {
- if (ret < 0 && stream->istream.stream_errno == 0 &&
- i_stream_get_data_size(stream->parent) > 0) {
- /* qp input with a partial block */
- stream->istream.stream_errno = EINVAL;
+ if (ret != -1 || stream->istream.stream_errno != 0)
+ return 0;
+
+ data = i_stream_get_data(stream->parent, &size);
+ if (size == 0)
+ return -1;
+
+ if (size == 1 && data[0] == '=') {
+ /* ends with "=". normally this would be
+ followed by LF, but it's not really an
+ error even without. */
+ i_stream_skip(stream->parent, 1);
+ stream->istream.eof = TRUE;
+ return -1;
}
- return ret;
+ /* qp input with a partial block */
+ stream->istream.stream_errno = EINVAL;
+ return -1;
}
/* encode as many blocks as fits into destination buffer */
More information about the dovecot-cvs
mailing list