Commit d8ab03b0 d8ab03b03566831cb5dfe8caf4a1e1b77106a342 by Sergey Poznyakoff

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.
1 parent d1b1cba2
......@@ -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));
......