[dovecot-cvs] dovecot-1.0: If there's no message body, the final read() should...
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 24 11:34:50 EEST 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/89aa4c7f40b7
changeset: 5287:89aa4c7f40b7
user: Timo Sirainen <tss at iki.fi>
date: Thu May 24 11:34:46 2007 +0300
description:
If there's no message body, the final read() should return -1, not -2
diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
src/lib-mail/istream-header-filter.c | 14 +++++++++++++-
diffs (35 lines):
diff -r 325438d789fb -r 89aa4c7f40b7 src/lib-mail/istream-header-filter.c
--- a/src/lib-mail/istream-header-filter.c Wed May 23 23:15:16 2007 +0300
+++ b/src/lib-mail/istream-header-filter.c Thu May 24 11:34:46 2007 +0300
@@ -70,6 +70,16 @@ static ssize_t read_header(struct header
mstream->istream.istream.v_offset +
(mstream->istream.pos - mstream->istream.skip) ==
mstream->header_size.virtual_size) {
+ /* if there's no body at all, return EOF */
+ (void)i_stream_get_data(mstream->input, &pos);
+ if (pos == 0) {
+ ret = i_stream_read(mstream->input);
+ if (ret == -1) {
+ /* EOF */
+ mstream->istream.istream.eof = TRUE;
+ return -1;
+ }
+ }
/* we don't support mixing headers and body.
it shouldn't be needed. */
return -2;
@@ -180,11 +190,13 @@ static ssize_t read_header(struct header
}
if (ret == 0) {
+ /* we're at the end of headers. */
i_assert(hdr == NULL);
i_assert(mstream->istream.istream.v_offset +
mstream->istream.pos ==
mstream->header_size.virtual_size);
- return -2;
+
+ return read_header(mstream);
}
return ret;
More information about the dovecot-cvs
mailing list