dovecot: If readdir() or closedir() fails, return failure.

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 9 05:44:40 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/8bb5c7a69405
changeset: 5911:8bb5c7a69405
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 08 22:16:04 2007 +0300
description:
If readdir() or closedir() fails, return failure.

diffstat:

1 file changed, 10 insertions(+), 1 deletion(-)
src/lib-storage/index/maildir/maildir-sync.c |   11 ++++++++++-

diffs (31 lines):

diff -r 289f828591f7 -r 8bb5c7a69405 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c	Sun Jul 08 22:13:53 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Sun Jul 08 22:16:04 2007 +0300
@@ -643,7 +643,9 @@ static int maildir_scan_dir(struct maild
 	ctx->move_count = 0;
 	move_new = new_dir && !mailbox_is_readonly(&ctx->mbox->ibox.box) &&
 		!ctx->mbox->ibox.keep_recent;
-	while ((dp = readdir(dirp)) != NULL) {
+
+	errno = 0;
+	for (; (dp = readdir(dirp)) != NULL; errno = 0) {
 		if (dp->d_name[0] == '.')
 			continue;
 
@@ -715,9 +717,16 @@ static int maildir_scan_dir(struct maild
 		}
 	}
 
+	if (errno != 0) {
+		mail_storage_set_critical(storage,
+					  "readdir(%s) failed: %m", dir);
+		ret = -1;
+	}
+
 	if (closedir(dirp) < 0) {
 		mail_storage_set_critical(storage,
 					  "closedir(%s) failed: %m", dir);
+		ret = -1;
 	}
 
 	t_pop();


More information about the dovecot-cvs mailing list