dovecot-2.2: istream-attachment-extractor: Fixed read() returnin...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 25 19:31:15 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/d95ff676d358
changeset: 14715:d95ff676d358
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 25 19:30:55 2012 +0300
description:
istream-attachment-extractor: Fixed read() returning EOF too early.
diffstat:
src/lib-mail/istream-attachment-extractor.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diffs (49 lines):
diff -r cdba6fec5ddf -r d95ff676d358 src/lib-mail/istream-attachment-extractor.c
--- a/src/lib-mail/istream-attachment-extractor.c Tue Jul 17 16:03:43 2012 +0300
+++ b/src/lib-mail/istream-attachment-extractor.c Wed Jul 25 19:30:55 2012 +0300
@@ -535,6 +535,7 @@
if (part->part_buf != NULL) {
stream_add_data(astream, part->part_buf->data,
part->part_buf->used);
+ ret = part->part_buf->used > 0 ? 1 : 0;
}
break;
case MAIL_ATTACHMENT_STATE_YES:
@@ -553,19 +554,27 @@
struct istream_private *stream = &astream->istream;
struct message_block block;
size_t old_size, new_size;
+ int ret;
*retry_r = FALSE;
if (stream->pos - stream->skip >= stream->max_buffer_size)
return -2;
+ old_size = stream->pos - stream->skip;
switch (message_parser_parse_next_block(astream->parser, &block)) {
case -1:
/* done / error */
+ ret = astream_end_of_part(astream);
+ if (ret > 0) {
+ /* final data */
+ new_size = stream->pos - stream->skip;
+ return new_size - old_size;
+ }
stream->istream.eof = TRUE;
stream->istream.stream_errno = stream->parent->stream_errno;
- if (astream_end_of_part(astream) < 0)
+ if (ret < 0)
stream->istream.stream_errno = EIO;
astream->cur_part = NULL;
return -1;
@@ -576,8 +585,6 @@
break;
}
- old_size = stream->pos - stream->skip;
-
if (block.part != astream->cur_part && astream->cur_part != NULL) {
/* end of a MIME part */
if (astream_end_of_part(astream) < 0) {
More information about the dovecot-cvs
mailing list