dovecot-2.2: maildir: Fixed potential crash when maildir suddenl...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 20:45:54 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/755b03fb6fce
changeset: 15349:755b03fb6fce
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 20:45:41 2012 +0200
description:
maildir: Fixed potential crash when maildir suddenly loses some directories.

diffstat:

 src/lib-storage/index/maildir/maildir-util.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r 9050920ce827 -r 755b03fb6fce src/lib-storage/index/maildir/maildir-util.c
--- a/src/lib-storage/index/maildir/maildir-util.c	Mon Oct 29 20:42:00 2012 +0200
+++ b/src/lib-storage/index/maildir/maildir-util.c	Mon Oct 29 20:45:41 2012 +0200
@@ -206,7 +206,7 @@
 	enum mailbox_list_path_type types[N_ELEMENTS(subdirs) + 2];
 	struct stat st;
 	const char *path;
-	unsigned int i;
+	unsigned int i, count;
 
 	/* @UNSAFE: get a list of directories we want to create */
 	for (i = 0; i < N_ELEMENTS(subdirs); i++) {
@@ -222,11 +222,12 @@
 		types[i] = MAILBOX_LIST_PATH_TYPE_INDEX;
 		dirs[i++] = path;
 	}
-	i_assert(i <= N_ELEMENTS(dirs));
+	count = i;
+	i_assert(count <= N_ELEMENTS(dirs));
 
-	for (i = 0; i < N_ELEMENTS(dirs); i++) {
+	for (i = 0; i < count; i++) {
 		path = dirs[i];
-		if (path == NULL || stat(path, &st) == 0)
+		if (stat(path, &st) == 0)
 			continue;
 		if (errno != ENOENT) {
 			mail_storage_set_critical(box->storage,


More information about the dovecot-cvs mailing list