[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-mail.c, 1.25, 1.26 maildir-sync.c, 1.78, 1.79 maildir-util.c, 1.15, 1.16

cras at dovecot.org cras at dovecot.org
Wed Jun 28 01:51:57 EEST 2006


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

Modified Files:
	maildir-mail.c maildir-sync.c maildir-util.c 
Log Message:
Don't break if mailbox path contains ':' characters.



Index: maildir-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-mail.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- maildir-mail.c	17 Jun 2006 22:44:57 -0000	1.25
+++ maildir-mail.c	27 Jun 2006 22:51:47 -0000	1.26
@@ -121,7 +121,7 @@
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	struct index_mail_data *data = &mail->data;
-	const char *fname;
+	const char *path, *fname;
 	uoff_t virtual_size;
         enum maildir_uidlist_rec_flag flags;
 
@@ -142,8 +142,10 @@
 			return (uoff_t)-1;
 		}
 	} else {
-		fname = maildir_save_file_get_path(_mail->transaction,
-						   _mail->seq);
+		path = maildir_save_file_get_path(_mail->transaction,
+						  _mail->seq);
+		fname = strrchr(path, '/');
+		fname = fname != NULL ? fname + 1 : path;
 	}
 
 	/* size can be included in filename */
@@ -163,7 +165,7 @@
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	enum maildir_uidlist_rec_flag flags;
-	const char *fname, *end;
+	const char *path, *fname, *end;
 
 	if (field == MAIL_FETCH_UIDL_FILE_NAME) {
 		if (_mail->uid != 0) {
@@ -174,8 +176,10 @@
 				return NULL;
 			}
 		} else {
-			fname = maildir_save_file_get_path(_mail->transaction,
-							   _mail->seq);
+			path = maildir_save_file_get_path(_mail->transaction,
+							  _mail->seq);
+			fname = strrchr(path, '/');
+			fname = fname != NULL ? fname + 1 : path;
 		}
 		end = strchr(fname, MAILDIR_INFO_SEP);
 		return end == NULL ? fname : t_strdup_until(fname, end);
@@ -190,7 +194,7 @@
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	struct index_mail_data *data = &mail->data;
 	struct stat st;
-	const char *fname;
+	const char *path, *fname;
 	uoff_t size;
 	enum maildir_uidlist_rec_flag flags;
 
@@ -206,8 +210,10 @@
 			return (uoff_t)-1;
 		}
 	} else {
-		fname = maildir_save_file_get_path(_mail->transaction,
-						   _mail->seq);
+		path = maildir_save_file_get_path(_mail->transaction,
+						  _mail->seq);
+		fname = strrchr(path, '/');
+		fname = fname != NULL ? fname + 1 : path;
 	}
 
 	/* size can be included in filename */

Index: maildir-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- maildir-sync.c	17 Jun 2006 13:55:30 -0000	1.78
+++ maildir-sync.c	27 Jun 2006 22:51:47 -0000	1.79
@@ -400,7 +400,7 @@
 {
         struct maildir_index_sync_context *ctx = context;
 	const struct mail_index_sync_rec *recs;
-	const char *newpath;
+	const char *dir, *fname, *newfname, *newpath;
 	enum mail_flags flags;
 	array_t ARRAY_DEFINE(keywords, unsigned int);
 	unsigned int i, count;
@@ -408,9 +408,14 @@
 
 	ctx->dirty_state = 0;
 
+	fname = strrchr(path, '/');
+	i_assert(fname != NULL);
+	fname++;
+	dir = t_strdup_until(path, fname);
+
 	ARRAY_CREATE(&keywords, pool_datastack_create(), unsigned int, 16);
 	(void)maildir_filename_get_flags(ctx->keywords_sync_ctx,
-					 path, &flags, &keywords);
+					 fname, &flags, &keywords);
 	flags8 = flags;
 
 	recs = array_get_modifyable(&ctx->sync_recs, &count);
@@ -434,8 +439,10 @@
 		}
 	}
 
-	newpath = maildir_filename_set_flags(ctx->keywords_sync_ctx,
-					     path, flags8, &keywords);
+
+	newfname = maildir_filename_set_flags(ctx->keywords_sync_ctx,
+					      fname, flags8, &keywords);
+	newpath = t_strconcat(dir, newfname, NULL);
 	if (rename(path, newpath) == 0) {
 		if ((flags8 & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0)
 			ctx->dirty_state = -1;

Index: maildir-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-util.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- maildir-util.c	16 Jun 2006 09:40:40 -0000	1.15
+++ maildir-util.c	27 Jun 2006 22:51:47 -0000	1.16
@@ -139,6 +139,7 @@
 	uoff_t size = 0;
 
 	for (; *fname != '\0'; fname++) {
+		i_assert(*fname != '/');
 		if (*fname == ',' && fname[1] == type && fname[2] == '=') {
 			fname += 3;
 			break;
@@ -169,6 +170,7 @@
 	unsigned int g, h = 0;
 
 	while (*s != MAILDIR_INFO_SEP && *s != '\0') {
+		i_assert(*s != '/');
 		h = (h << 4) + *s;
 		if ((g = h & 0xf0000000UL)) {
 			h = h ^ (g >> 24);
@@ -186,6 +188,7 @@
 	const char *s1 = p1, *s2 = p2;
 
 	while (*s1 == *s2 && *s1 != MAILDIR_INFO_SEP && *s1 != '\0') {
+		i_assert(*s1 != '/');
 		s1++; s2++;
 	}
 	if ((*s1 == '\0' || *s1 == MAILDIR_INFO_SEP) &&



More information about the dovecot-cvs mailing list