From d8ab03b03566831cb5dfe8caf4a1e1b77106a342 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 8 Apr 2010 14:25:20 +0300 Subject: Bugfix in mu_rfc2047_decode. * mailbox/rfc2047.c (mu_rfc2047_decode): Use temporary buffer for reading from the filter stream, to avoid preliminary breaking from the read loop when end of the buffer is reached. Realloc the buffer as neccessary. --- mailbox/rfc2047.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c index 540f80e68..77d02e557 100644 --- a/mailbox/rfc2047.c +++ b/mailbox/rfc2047.c @@ -117,7 +117,8 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) const char *filter_type = NULL; size_t nbytes = 0, size; const char *sp = fromstr + 2; - + char tmp[128]; + fromcode = getword (&sp, '?'); encoding_type = getword (&sp, '?'); encoded_text = getword (&sp, '?'); @@ -164,11 +165,14 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) if (status != 0) break; - while (mu_stream_sequential_read (filter, buffer + bufpos, - bufsize - bufpos, - &nbytes) == 0 + while (mu_stream_sequential_read (filter, tmp, sizeof (tmp), + &nbytes) == 0 && nbytes) - bufpos += nbytes; + { + CHKBUF (nbytes); + memcpy (buffer + bufpos, tmp, nbytes); + bufpos += nbytes; + } mu_stream_close (filter); mu_stream_destroy (&filter, mu_stream_get_owner (filter)); -- cgit v1.2.1