[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-sync.c, 1.16, 1.16.2.1

cras at dovecot.org cras at dovecot.org
Sun May 28 22:25:57 EEST 2006


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

Modified Files:
      Tag: branch_1_0
	dbox-sync.c 
Log Message:
Removing and resetting keywords could have operated on wrong file's keyword
list.



Index: dbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync.c,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -d -r1.16 -r1.16.2.1
--- dbox-sync.c	3 May 2006 22:02:55 -0000	1.16
+++ dbox-sync.c	28 May 2006 19:25:55 -0000	1.16.2.1
@@ -251,11 +251,15 @@
 
 static int
 dbox_sync_update_keyword(struct dbox_sync_context *ctx,
+			 const struct dbox_sync_file_entry *entry,
 			 const struct dbox_sync_rec *sync_rec, bool set)
 {
 	unsigned char keyword_array, keyword_mask = 1;
 	unsigned int file_idx, first_flag_offset;
 
+	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0)
+		return -1;
+
 	keyword_array = set ? '1' : '0';
 
 	if (!dbox_file_lookup_keyword(ctx->mbox, ctx->mbox->file,
@@ -276,12 +280,16 @@
 
 static int
 dbox_sync_reset_keyword(struct dbox_sync_context *ctx,
-			 const struct dbox_sync_rec *sync_rec)
+			const struct dbox_sync_file_entry *entry,
+			const struct dbox_sync_rec *sync_rec)
 {
 	unsigned char *keyword_array, *keyword_mask;
 	unsigned int first_flag_offset;
 	int ret;
 
+	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0)
+		return -1;
+
 	if (ctx->mbox->file->keyword_count == 0)
 		return 0;
 
@@ -380,17 +388,18 @@
 								i) < 0)
 					return -1;
 			}
-			if (dbox_sync_update_keyword(ctx, &sync_recs[i],
+			if (dbox_sync_update_keyword(ctx, entry, &sync_recs[i],
 						     TRUE) < 0)
 				return -1;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE:
-			if (dbox_sync_update_keyword(ctx, &sync_recs[i],
+			if (dbox_sync_update_keyword(ctx, entry, &sync_recs[i],
 						     FALSE) < 0)
 				return -1;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_RESET:
-			if (dbox_sync_reset_keyword(ctx, &sync_recs[i]) < 0)
+			if (dbox_sync_reset_keyword(ctx, entry,
+						    &sync_recs[i]) < 0)
 				return -1;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_APPEND:



More information about the dovecot-cvs mailing list