changeset 3035:6f1ea1c7212f HEAD

Don't break if line begins with NUL. Don't return -2 as long as underlying stream is returning more data (don't just retry once).
author Timo Sirainen <tss@iki.fi>
date Mon, 03 Jan 2005 22:45:29 +0200
parents de1b904c4df2
children fcecff14e470
files src/lib-storage/index/mbox/istream-raw-mbox.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c	Wed Dec 29 21:24:00 2004 +0200
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c	Mon Jan 03 22:45:29 2005 +0200
@@ -119,11 +119,11 @@
 	struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream;
 	const unsigned char *buf;
 	const char *fromp;
-	char *sender, eoh_char;
+	char *sender;
 	time_t received_time;
 	size_t i, pos, new_pos, from_start_pos;
 	ssize_t ret = 0;
-	int tried_read = FALSE;
+	int eoh_char;
 
 	i_assert(stream->istream.v_offset >= rstream->from_offset);
 
@@ -143,7 +143,6 @@
 		    stream->istream.v_offset + pos > rstream->input_peak_offset)
 			break;
 		ret = i_stream_read(rstream->input);
-		tried_read = TRUE;
 	} while (ret > 0);
 
 	if (ret < 0) {
@@ -192,13 +191,13 @@
 	/* See if we have From-line here - note that it works right only
 	   because all characters are different in mbox_from. */
         fromp = mbox_from; from_start_pos = (size_t)-1;
-	eoh_char = rstream->body_offset == (uoff_t)-1 ? '\n' : '\0';
+	eoh_char = rstream->body_offset == (uoff_t)-1 ? '\n' : -1;
 	for (i = stream->pos; i < pos; i++) {
 		if (buf[i] == eoh_char &&
 		    ((i > 0 && buf[i-1] == '\n') ||
 		     stream->istream.v_offset + i == rstream->hdr_offset)) {
 			rstream->body_offset = stream->istream.v_offset + i + 1;
-			eoh_char = '\0';
+			eoh_char = -1;
 		}
 		if (buf[i] == *fromp) {
 			if (*++fromp == '\0') {
@@ -249,7 +248,7 @@
 
 	stream->buffer = buf;
 	if (new_pos == stream->pos) {
-		if (stream->istream.eof || !tried_read)
+		if (stream->istream.eof || ret > 0)
 			return _read(stream);
 		ret = -2;
 	} else {