Bugfixes.
* libmailutils/streamcpy.c (mu_stream_copy): Use the number of bytes actually read. * libmailutils/base64.c (_base64_encoder): Return mu_filter_again if not all data has been consumed on mu_filter_lastbuf. * libmailutils/message_stream.c (scan_stream): Fix calculation of body_end. (_body_obj_size): Fix calculation of body size. * libproto/mailer/smtp_data.c (_mu_smtp_data_begin): Set full buffering on the MU_TRANSPORT_OUTPUT stream.
Showing
4 changed files
with
14 additions
and
6 deletions
... | @@ -187,6 +187,7 @@ _base64_encoder (void *xd MU_ARG_UNUSED, | ... | @@ -187,6 +187,7 @@ _base64_encoder (void *xd MU_ARG_UNUSED, |
187 | size_t isize; | 187 | size_t isize; |
188 | char *optr; | 188 | char *optr; |
189 | size_t osize; | 189 | size_t osize; |
190 | enum mu_filter_result res; | ||
190 | 191 | ||
191 | switch (cmd) | 192 | switch (cmd) |
192 | { | 193 | { |
... | @@ -247,9 +248,13 @@ _base64_encoder (void *xd MU_ARG_UNUSED, | ... | @@ -247,9 +248,13 @@ _base64_encoder (void *xd MU_ARG_UNUSED, |
247 | /* Consumed may grow bigger than isize if cmd is mu_filter_lastbuf */ | 248 | /* Consumed may grow bigger than isize if cmd is mu_filter_lastbuf */ |
248 | if (consumed > iobuf->isize) | 249 | if (consumed > iobuf->isize) |
249 | consumed = iobuf->isize; | 250 | consumed = iobuf->isize; |
251 | if (cmd == mu_filter_lastbuf && consumed < iobuf->isize) | ||
252 | res = mu_filter_again; | ||
253 | else | ||
254 | res = mu_filter_ok; | ||
250 | iobuf->isize = consumed; | 255 | iobuf->isize = consumed; |
251 | iobuf->osize = nbytes; | 256 | iobuf->osize = nbytes; |
252 | return mu_filter_ok; | 257 | return res; |
253 | } | 258 | } |
254 | 259 | ||
255 | static struct _mu_filter_record _base64_filter = { | 260 | static struct _mu_filter_record _base64_filter = { | ... | ... |
... | @@ -205,7 +205,9 @@ scan_stream (struct _mu_message_stream *str) | ... | @@ -205,7 +205,9 @@ scan_stream (struct _mu_message_stream *str) |
205 | rc = mu_stream_seek (stream, 0, MU_SEEK_CUR, &body_start); | 205 | rc = mu_stream_seek (stream, 0, MU_SEEK_CUR, &body_start); |
206 | if (rc) | 206 | if (rc) |
207 | return rc; | 207 | return rc; |
208 | mu_stream_size (stream, &body_end); | 208 | rc = mu_stream_size (stream, &body_end); |
209 | if (rc) | ||
210 | return rc; | ||
209 | 211 | ||
210 | if (!env_from) | 212 | if (!env_from) |
211 | { | 213 | { |
... | @@ -240,7 +242,7 @@ scan_stream (struct _mu_message_stream *str) | ... | @@ -240,7 +242,7 @@ scan_stream (struct _mu_message_stream *str) |
240 | str->date = env_date; | 242 | str->date = env_date; |
241 | 243 | ||
242 | str->body_start = body_start; | 244 | str->body_start = body_start; |
243 | str->body_end = body_end; | 245 | str->body_end = body_end - 1; |
244 | 246 | ||
245 | return 0; | 247 | return 0; |
246 | } | 248 | } |
... | @@ -369,7 +371,7 @@ _body_obj_size (mu_body_t body, size_t *size) | ... | @@ -369,7 +371,7 @@ _body_obj_size (mu_body_t body, size_t *size) |
369 | struct _mu_message_stream *str = mu_message_get_owner (msg); | 371 | struct _mu_message_stream *str = mu_message_get_owner (msg); |
370 | 372 | ||
371 | if (size) | 373 | if (size) |
372 | *size = str->body_end - str->body_start; | 374 | *size = str->body_end - str->body_start + 1; |
373 | return 0; | 375 | return 0; |
374 | } | 376 | } |
375 | 377 | ... | ... |
... | @@ -104,8 +104,8 @@ mu_stream_copy (mu_stream_t dst, mu_stream_t src, mu_off_t size, | ... | @@ -104,8 +104,8 @@ mu_stream_copy (mu_stream_t dst, mu_stream_t src, mu_off_t size, |
104 | status = mu_stream_write (dst, buf, n, NULL); | 104 | status = mu_stream_write (dst, buf, n, NULL); |
105 | if (status) | 105 | if (status) |
106 | break; | 106 | break; |
107 | size -= rdsize; | 107 | size -= n; |
108 | total += rdsize; | 108 | total += n; |
109 | } | 109 | } |
110 | else | 110 | else |
111 | while ((status = mu_stream_read (src, buf, bufsize, &n)) == 0 | 111 | while ((status = mu_stream_read (src, buf, bufsize, &n)) == 0 | ... | ... |
... | @@ -46,6 +46,7 @@ _mu_smtp_data_begin (mu_smtp_t smtp) | ... | @@ -46,6 +46,7 @@ _mu_smtp_data_begin (mu_smtp_t smtp) |
46 | if (mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_QRY, MU_XSCRIPT_PAYLOAD)) | 46 | if (mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_QRY, MU_XSCRIPT_PAYLOAD)) |
47 | _mu_smtp_xscript_level (smtp, MU_XSCRIPT_PAYLOAD); | 47 | _mu_smtp_xscript_level (smtp, MU_XSCRIPT_PAYLOAD); |
48 | 48 | ||
49 | smtp->savebuf.type = MU_TRANSPORT_OUTPUT; | ||
49 | if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_GET_TRANSPORT_BUFFER, | 50 | if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_GET_TRANSPORT_BUFFER, |
50 | &smtp->savebuf) == 0) | 51 | &smtp->savebuf) == 0) |
51 | { | 52 | { | ... | ... |
-
Please register or sign in to post a comment