Commit 98558025 98558025e65058796d86a99eed2498d68600f5dc by Sergey Poznyakoff

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.
1 parent 8672f9f0
......@@ -187,6 +187,7 @@ _base64_encoder (void *xd MU_ARG_UNUSED,
size_t isize;
char *optr;
size_t osize;
enum mu_filter_result res;
switch (cmd)
{
......@@ -247,9 +248,13 @@ _base64_encoder (void *xd MU_ARG_UNUSED,
/* Consumed may grow bigger than isize if cmd is mu_filter_lastbuf */
if (consumed > iobuf->isize)
consumed = iobuf->isize;
if (cmd == mu_filter_lastbuf && consumed < iobuf->isize)
res = mu_filter_again;
else
res = mu_filter_ok;
iobuf->isize = consumed;
iobuf->osize = nbytes;
return mu_filter_ok;
return res;
}
static struct _mu_filter_record _base64_filter = {
......
......@@ -205,7 +205,9 @@ scan_stream (struct _mu_message_stream *str)
rc = mu_stream_seek (stream, 0, MU_SEEK_CUR, &body_start);
if (rc)
return rc;
mu_stream_size (stream, &body_end);
rc = mu_stream_size (stream, &body_end);
if (rc)
return rc;
if (!env_from)
{
......@@ -240,7 +242,7 @@ scan_stream (struct _mu_message_stream *str)
str->date = env_date;
str->body_start = body_start;
str->body_end = body_end;
str->body_end = body_end - 1;
return 0;
}
......@@ -369,7 +371,7 @@ _body_obj_size (mu_body_t body, size_t *size)
struct _mu_message_stream *str = mu_message_get_owner (msg);
if (size)
*size = str->body_end - str->body_start;
*size = str->body_end - str->body_start + 1;
return 0;
}
......
......@@ -104,8 +104,8 @@ mu_stream_copy (mu_stream_t dst, mu_stream_t src, mu_off_t size,
status = mu_stream_write (dst, buf, n, NULL);
if (status)
break;
size -= rdsize;
total += rdsize;
size -= n;
total += n;
}
else
while ((status = mu_stream_read (src, buf, bufsize, &n)) == 0
......
......@@ -46,6 +46,7 @@ _mu_smtp_data_begin (mu_smtp_t smtp)
if (mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_QRY, MU_XSCRIPT_PAYLOAD))
_mu_smtp_xscript_level (smtp, MU_XSCRIPT_PAYLOAD);
smtp->savebuf.type = MU_TRANSPORT_OUTPUT;
if (mu_stream_ioctl (smtp->carrier, MU_IOCTL_GET_TRANSPORT_BUFFER,
&smtp->savebuf) == 0)
{
......