From: Timo Sirainen Date: Mon, 22 Sep 2003 14:29:11 +0000 (+0300) Subject: Fix for leaking fds with non-writable .customflags files. X-Git-Tag: 1.1.alpha1~4318 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=495bba73d5ac8e24d08d5515332988b751b62152;p=thirdparty%2Fdovecot%2Fcore.git Fix for leaking fds with non-writable .customflags files. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-custom-flags.c b/src/lib-index/mail-custom-flags.c index ae1753d6cc..e0db24db04 100644 --- a/src/lib-index/mail-custom-flags.c +++ b/src/lib-index/mail-custom-flags.c @@ -248,16 +248,14 @@ int mail_custom_flags_open_or_create(struct mail_index *index) CUSTOM_FLAGS_FILE_NAME, NULL); fd = !readonly ? open(path, O_RDWR | O_CREAT, 0660) : open(path, O_RDONLY); - if (fd == -1) { - if (errno == EACCES) { - fd = open(path, O_RDONLY); - readonly = TRUE; - } - if (errno != EACCES && errno != ENOENT && - !ENOSPACE(errno)) { - index_file_set_syscall_error(index, path, "open()"); - return FALSE; - } + if (fd == -1 && errno == EACCES) { + fd = open(path, O_RDONLY); + readonly = TRUE; + } + if (fd == -1 && errno != EACCES && errno != ENOENT && + !ENOSPACE(errno)) { + index_file_set_syscall_error(index, path, "open()"); + return FALSE; } } else { path = NULL;