dovecot-1.0: If stat() fails with anything else than ENOENT when...

dovecot at dovecot.org dovecot at dovecot.org
Sun Mar 2 19:52:20 EET 2008


details:   http://hg.dovecot.org/dovecot-1.0/rev/dfa82e24d7bc
changeset: 5524:dfa82e24d7bc
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Mar 02 19:52:16 2008 +0200
description:
If stat() fails with anything else than ENOENT when creating a maildir temp
file, log an error and fail instead of looping infinitely.

diffstat:

1 file changed, 8 insertions(+), 1 deletion(-)
src/lib-storage/index/maildir/maildir-util.c |    9 ++++++++-

diffs (19 lines):

diff -r 5ba746bc9937 -r dfa82e24d7bc src/lib-storage/index/maildir/maildir-util.c
--- a/src/lib-storage/index/maildir/maildir-util.c	Sun Mar 02 07:39:35 2008 +0200
+++ b/src/lib-storage/index/maildir/maildir-util.c	Sun Mar 02 19:52:16 2008 +0200
@@ -121,7 +121,14 @@ int maildir_create_tmp(struct maildir_ma
 		tmp_fname = maildir_generate_tmp_filename(tv);
 
 		path = p_strconcat(pool, dir, "/", tmp_fname, NULL);
-		if (stat(path, &st) < 0 && errno == ENOENT) {
+		if (stat(path, &st) == 0) {
+			/* try another file name */
+		} else if (errno != ENOENT) {
+			mail_storage_set_critical(STORAGE(mbox->storage),
+				"stat(%s) failed: %m", path);
+			pool_unref(pool);
+			return -1;
+		} else {
 			/* doesn't exist */
 			mode_t old_mask = umask(0);
 			fd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode);


More information about the dovecot-cvs mailing list