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.
Showing
1 changed file
with
6 additions
and
2 deletions
... | @@ -117,6 +117,7 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) | ... | @@ -117,6 +117,7 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) |
117 | const char *filter_type = NULL; | 117 | const char *filter_type = NULL; |
118 | size_t nbytes = 0, size; | 118 | size_t nbytes = 0, size; |
119 | const char *sp = fromstr + 2; | 119 | const char *sp = fromstr + 2; |
120 | char tmp[128]; | ||
120 | 121 | ||
121 | fromcode = getword (&sp, '?'); | 122 | fromcode = getword (&sp, '?'); |
122 | encoding_type = getword (&sp, '?'); | 123 | encoding_type = getword (&sp, '?'); |
... | @@ -164,11 +165,14 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) | ... | @@ -164,11 +165,14 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr) |
164 | if (status != 0) | 165 | if (status != 0) |
165 | break; | 166 | break; |
166 | 167 | ||
167 | while (mu_stream_sequential_read (filter, buffer + bufpos, | 168 | while (mu_stream_sequential_read (filter, tmp, sizeof (tmp), |
168 | bufsize - bufpos, | ||
169 | &nbytes) == 0 | 169 | &nbytes) == 0 |
170 | && nbytes) | 170 | && nbytes) |
171 | { | ||
172 | CHKBUF (nbytes); | ||
173 | memcpy (buffer + bufpos, tmp, nbytes); | ||
171 | bufpos += nbytes; | 174 | bufpos += nbytes; |
175 | } | ||
172 | 176 | ||
173 | mu_stream_close (filter); | 177 | mu_stream_close (filter); |
174 | mu_stream_destroy (&filter, mu_stream_get_owner (filter)); | 178 | mu_stream_destroy (&filter, mu_stream_get_owner (filter)); | ... | ... |
-
Please register or sign in to post a comment