[dovecot-cvs] dovecot: If there's no message body, the final read() should ret...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 24 11:34:54 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/6533e11eda80
changeset: 5660:6533e11eda80
user:      Timo Sirainen <tss at iki.fi>
date:      Thu May 24 11:34:47 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 b118198fbfa3 -r 6533e11eda80 src/lib-mail/istream-header-filter.c
--- a/src/lib-mail/istream-header-filter.c	Wed May 23 23:15:17 2007 +0300
+++ b/src/lib-mail/istream-header-filter.c	Thu May 24 11:34:47 2007 +0300
@@ -72,6 +72,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;
@@ -182,11 +192,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