[dovecot-cvs] dovecot/src/lib-storage/index/mbox istream-raw-mbox.c, 1.41, 1.42 mbox-sync-rewrite.c, 1.62, 1.63 mbox-sync-update.c, 1.46, 1.47

cras at dovecot.org cras at dovecot.org
Sat Jun 24 23:53:39 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv24021

Modified Files:
	istream-raw-mbox.c mbox-sync-rewrite.c mbox-sync-update.c 
Log Message:
Fixes to handling CR+LF linefeeds.



Index: istream-raw-mbox.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/istream-raw-mbox.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- istream-raw-mbox.c	8 Jun 2006 19:26:53 -0000	1.41
+++ istream-raw-mbox.c	24 Jun 2006 20:53:37 -0000	1.42
@@ -107,12 +107,15 @@
 	if (rstream->hdr_offset + rstream->mail_size < rstream->body_offset) {
 		/* a) Header didn't have ending \n
 		   b) "headers\n\nFrom ..", the second \n belongs to next
-		   message which we didn't know at the time yet. */
-		i_assert(rstream->body_offset == (uoff_t)-1 ||
-			 rstream->body_offset ==
-			 rstream->hdr_offset + rstream->mail_size + 1);
-		rstream->body_offset =
+		   message which we didn't know at the time yet.
+
+		   The +2 check is for CR+LF linefeeds */
+		uoff_t new_body_offset =
 			rstream->hdr_offset + rstream->mail_size;
+		i_assert(rstream->body_offset == (uoff_t)-1 ||
+			 rstream->body_offset == new_body_offset + 1 ||
+			 rstream->body_offset == new_body_offset + 2);
+		rstream->body_offset = new_body_offset;
 	}
 }
 
@@ -190,6 +193,13 @@
 
 	if (stream->istream.v_offset == rstream->from_offset) {
 		/* beginning of message, we haven't yet read our From-line */
+		if (pos == 2) {
+			/* we're at the end of file with CR+LF linefeeds?
+			   need more data to verify it. */
+			rstream->input_peak_offset =
+				stream->istream.v_offset + pos;
+			return _read(stream);
+		}
 		if (mbox_read_from_line(rstream) < 0) {
 			stream->pos = 0;
 			rstream->eof = TRUE;

Index: mbox-sync-rewrite.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- mbox-sync-rewrite.c	26 Feb 2006 10:05:22 -0000	1.62
+++ mbox-sync-rewrite.c	24 Jun 2006 20:53:37 -0000	1.63
@@ -111,7 +111,7 @@
 			if (pos+1 == data_size || !IS_LWSP(data[pos+1]))
 				break;
 			start_pos = pos+1;
-		} else if (!IS_LWSP(data[pos])) {
+		} else if (!IS_LWSP(data[pos]) && data[pos] != '\r') {
 			start_pos = pos+1;
 		}
 	}
@@ -152,7 +152,7 @@
 				break;
 			}
                         last_line_pos = pos+1;
-		} else if (!IS_LWSP(data[pos])) {
+		} else if (!IS_LWSP(data[pos]) && data[pos] != '\r') {
 			start_pos = last_line_pos = pos+1;
 		}
 	}

Index: mbox-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-update.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mbox-sync-update.c	2 May 2006 13:05:13 -0000	1.46
+++ mbox-sync-update.c	24 Jun 2006 20:53:37 -0000	1.47
@@ -90,7 +90,7 @@
 	/* how many bytes do we have now? */
 	data = buffer_get_modifyable_data(ctx->header, &size);
 	for (have = 0; pos < size; pos++) {
-		if (data[pos] == '\n')
+		if (data[pos] == '\n' || data[pos] == '\r')
 			break;
 
 		/* see if this is unknown flag for us */



More information about the dovecot-cvs mailing list