[dovecot-cvs] dovecot/src/lib-index/mbox mbox-append.c,1.44,1.45 mbox-index.c,1.83,1.84 mbox-rewrite.c,1.67,1.68 mbox-sync-full.c,1.20,1.21

cras at procontrol.fi cras at procontrol.fi
Wed Nov 5 10:42:15 EET 2003


Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv9737/lib-index/mbox

Modified Files:
	mbox-append.c mbox-index.c mbox-rewrite.c mbox-sync-full.c 
Log Message:
Added istream->eof. istream->v_size is now set to 0 with files.



Index: mbox-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-append.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- mbox-append.c	2 Sep 2003 22:33:33 -0000	1.44
+++ mbox-append.c	5 Nov 2003 08:42:12 -0000	1.45
@@ -35,6 +35,9 @@
 			break;
 	}
 
+	if (size == 0)
+		return -1;
+
 	if (pos == size || size <= 5 ||
 	    strncmp((const char *) data, "From ", 5) != 0) {
 		/* a) no \n found, or line too long
@@ -164,7 +167,7 @@
 	uoff_t offset;
 	int ret;
 
-	if (input->v_offset == input->v_size) {
+	if (input->eof) {
 		/* no new data */
 		return TRUE;
 	}
@@ -192,14 +195,14 @@
 			}
 		}
 
-		if (input->v_offset == input->v_size) {
-			ret = 1;
-			break;
-		}
-
 		t_push();
 		ret = mbox_index_append_next(index, trans_ctx, input);
 		t_pop();
+
+		if (input->eof) {
+			ret = 1;
+			break;
+		}
 
 		if (ret == 0) {
 			/* we want to rescan this message with exclusive

Index: mbox-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-index.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- mbox-index.c	29 Oct 2003 13:37:33 -0000	1.83
+++ mbox-index.c	5 Nov 2003 08:42:12 -0000	1.84
@@ -649,22 +649,17 @@
 	const unsigned char *data;
 	size_t size;
 
-	if (end_offset > input->v_size) {
-		/* missing data */
-		return FALSE;
-	}
-
 	i_stream_seek(input, end_offset);
 
-	if (input->v_offset == input->v_size) {
+	/* read forward a bit */
+	if (i_stream_read_data(input, &data, &size, 6) < 0)
+		return FALSE;
+
+	if (input->eof) {
 		/* end of file. a bit unexpected though,
 		   since \n is missing. */
 		return TRUE;
 	}
-
-	/* read forward a bit */
-	if (i_stream_read_data(input, &data, &size, 6) < 0)
-		return FALSE;
 
 	/* either there should be the next From-line,
 	   or [\r]\n at end of file */

Index: mbox-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rewrite.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- mbox-rewrite.c	4 Nov 2003 22:26:16 -0000	1.67
+++ mbox-rewrite.c	5 Nov 2003 08:42:13 -0000	1.68
@@ -692,13 +692,6 @@
 				break;
 			}
 
-			if (offset + body_size > input->v_size) {
-				mail_cache_set_corrupted(index->cache,
-					"Invalid message size");
-				failed = TRUE;
-				break;
-			}
-
 			if (!dirty_found) {
 				/* first dirty message */
 				dirty_found = TRUE;

Index: mbox-sync-full.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync-full.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mbox-sync-full.c	4 Nov 2003 22:26:16 -0000	1.20
+++ mbox-sync-full.c	5 Nov 2003 08:42:13 -0000	1.21
@@ -18,8 +18,9 @@
 {
 	const unsigned char *msg;
 	size_t i, size;
+	int ret;
 
-	while (i_stream_read_data(input, &msg, &size, 0) > 0) {
+	while ((ret = i_stream_read_data(input, &msg, &size, 0)) > 0) {
 		for (i = 0; i < size; i++) {
 			if (msg[i] == '\n') {
 				i_stream_skip(input, i+1);
@@ -90,6 +91,8 @@
 
 	/* skip the From-line */
 	skip_line(input);
+	if (input->eof)
+		return -1;
 	header_offset = input->v_offset;
 
 	first_rec = last_rec = NULL;
@@ -248,12 +251,12 @@
 			}
 		}
 
-		if (input->v_offset == input->v_size)
-			break;
-
 		ret = match_next_record(index, rec, &seq, input, &rec, &dirty);
-		if (ret < 0)
+		if (ret < 0) {
+			if (input->eof)
+				break;
 			return FALSE;
+		}
 
 		if (ret == 0) {
 			/* Get back to line before From */
@@ -274,8 +277,7 @@
 		index->header->flags &= ~MAIL_INDEX_HDR_FLAG_DIRTY_MESSAGES;
 	}
 
-	if (input->v_offset == input->v_size ||
-	    (index->set_flags & MAIL_INDEX_HDR_FLAG_REBUILD))
+	if (input->eof || (index->set_flags & MAIL_INDEX_HDR_FLAG_REBUILD))
 		return TRUE;
 	else
 		return mbox_index_append_stream(index, input);
@@ -300,7 +302,7 @@
 		failed = TRUE;
 	} else {
 		failed = !mbox_sync_from_stream(index, input);
-		continue_offset = failed || input->v_offset == input->v_size ||
+		continue_offset = failed || input->eof ||
 			(index->set_flags & MAIL_INDEX_HDR_FLAG_REBUILD) ?
 			(uoff_t)-1 : input->v_offset;
 		i_stream_unref(input);



More information about the dovecot-cvs mailing list