dovecot-2.2: Fixed file descriptor leaks in rather unimportant p...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 4 22:42:13 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/3091883c672a
changeset: 16710:3091883c672a
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 04 22:41:42 2013 +0300
description:
Fixed file descriptor leaks in rather unimportant places.
Found by Coverity scan.

diffstat:

 src/doveadm/doveadm-dump-log.c              |  1 +
 src/doveadm/doveadm-dump-mailboxlog.c       |  1 +
 src/doveadm/doveadm-dump-thread.c           |  1 +
 src/lib-master/master-service-settings.c    |  2 +-
 src/lib-storage/index/mbox/mbox-lock.c      |  1 +
 src/lib-storage/mailbox-uidvalidity.c       |  4 +++-
 src/lib/unix-socket-create.c                |  1 +
 src/plugins/acl/acl-backend-vfile-acllist.c |  1 +
 src/plugins/fts-squat/squat-trie.c          |  1 +
 src/plugins/zlib/zlib-plugin.c              |  2 +-
 src/ssl-params/ssl-params.c                 |  1 +
 11 files changed, 13 insertions(+), 3 deletions(-)

diffs (128 lines):

diff -r 4d297ab881ef -r 3091883c672a src/doveadm/doveadm-dump-log.c
--- a/src/doveadm/doveadm-dump-log.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/doveadm/doveadm-dump-log.c	Wed Sep 04 22:41:42 2013 +0300
@@ -524,6 +524,7 @@
 			ret = dump_record(fd, &modseq);
 		} T_END;
 	} while (ret > 0);
+	i_close_fd(&fd);
 }
 
 static bool test_dump_log(const char *path)
diff -r 4d297ab881ef -r 3091883c672a src/doveadm/doveadm-dump-mailboxlog.c
--- a/src/doveadm/doveadm-dump-mailboxlog.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/doveadm/doveadm-dump-mailboxlog.c	Wed Sep 04 22:41:42 2013 +0300
@@ -73,6 +73,7 @@
 			ret = dump_record(fd);
 		} T_END;
 	} while (ret > 0);
+	i_close_fd(&fd);
 }
 
 static bool test_dump_mailboxlog(const char *path)
diff -r 4d297ab881ef -r 3091883c672a src/doveadm/doveadm-dump-thread.c
--- a/src/doveadm/doveadm-dump-thread.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/doveadm/doveadm-dump-thread.c	Wed Sep 04 22:41:42 2013 +0300
@@ -120,6 +120,7 @@
 			pos += ret;
 		} T_END;
 	} while (ret > 0);
+	i_close_fd(&fd);
 }
 
 static bool test_dump_thread(const char *path)
diff -r 4d297ab881ef -r 3091883c672a src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/lib-master/master-service-settings.c	Wed Sep 04 22:41:42 2013 +0300
@@ -388,8 +388,8 @@
 			if (config_send_request(service, input, fd,
 						path, error_r) == 0)
 				break;
+			i_close_fd(&fd);
 			if (!retry) {
-				i_close_fd(&fd);
 				config_exec_fallback(service, input);
 				return -1;
 			}
diff -r 4d297ab881ef -r 3091883c672a src/lib-storage/index/mbox/mbox-lock.c
--- a/src/lib-storage/index/mbox/mbox-lock.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/lib-storage/index/mbox/mbox-lock.c	Wed Sep 04 22:41:42 2013 +0300
@@ -290,6 +290,7 @@
 		if (access(fname, R_OK) < 0) {
 			mail_storage_set_critical(&mbox->storage->storage,
 				"access(%s) failed: %m", box_path);
+			i_close_fd(&orig_dir_fd);
 			return -1;
 		}
 	}
diff -r 4d297ab881ef -r 3091883c672a src/lib-storage/mailbox-uidvalidity.c
--- a/src/lib-storage/mailbox-uidvalidity.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/lib-storage/mailbox-uidvalidity.c	Wed Sep 04 22:41:42 2013 +0300
@@ -221,8 +221,10 @@
 	}
 
 	/* we now have the current uidvalidity value that's hopefully correct */
-	if (mailbox_uidvalidity_rename(path, &cur_value, FALSE) < 0)
+	if (mailbox_uidvalidity_rename(path, &cur_value, FALSE) < 0) {
+		i_close_fd(&fd);
 		return mailbox_uidvalidity_next_rescan(list, path);
+	}
 
 	/* fast path succeeded. write the current value to the main
 	   uidvalidity file. */
diff -r 4d297ab881ef -r 3091883c672a src/lib/unix-socket-create.c
--- a/src/lib/unix-socket-create.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/lib/unix-socket-create.c	Wed Sep 04 22:41:42 2013 +0300
@@ -27,6 +27,7 @@
 		if (chown(path, uid, gid) < 0) {
 			i_error("chown(%s, %s, %s) failed: %m",
 				path, dec2str(uid), dec2str(gid));
+			i_close_fd(&fd);
 			return -1;
 		}
 	}
diff -r 4d297ab881ef -r 3091883c672a src/plugins/acl/acl-backend-vfile-acllist.c
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Wed Sep 04 22:41:42 2013 +0300
@@ -139,6 +139,7 @@
 			i_error("Broken acllist file: %s", path);
 			if (unlink(path) < 0 && errno != ENOENT)
 				i_error("unlink(%s) failed: %m", path);
+			i_close_fd(&fd);
 			return -1;
 		}
 		acllist.name = p_strdup(backend->acllist_pool, p + 1);
diff -r 4d297ab881ef -r 3091883c672a src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/plugins/fts-squat/squat-trie.c	Wed Sep 04 22:41:42 2013 +0300
@@ -1556,6 +1556,7 @@
 		if (fchown(fd, (uid_t)-1, trie->create_gid) < 0) {
 			i_error("fchown(%s, -1, %ld) failed: %m",
 				path, (long)trie->create_gid);
+			i_close_fd(&fd);
 			return -1;
 		}
 	}
diff -r 4d297ab881ef -r 3091883c672a src/plugins/zlib/zlib-plugin.c
--- a/src/plugins/zlib/zlib-plugin.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/plugins/zlib/zlib-plugin.c	Wed Sep 04 22:41:42 2013 +0300
@@ -312,7 +312,7 @@
 			i_close_fd(&fd);
 			return 0;
 		}
-		input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE);
+		input = i_stream_create_fd(fd, MAX_INBUF_SIZE, TRUE);
 		i_stream_set_name(input, box_path);
 		box->input = handler->create_istream(input, TRUE);
 		i_stream_unref(&input);
diff -r 4d297ab881ef -r 3091883c672a src/ssl-params/ssl-params.c
--- a/src/ssl-params/ssl-params.c	Wed Sep 04 22:16:02 2013 +0300
+++ b/src/ssl-params/ssl-params.c	Wed Sep 04 22:41:42 2013 +0300
@@ -170,6 +170,7 @@
 	}
 	if (st.st_size == 0 || st.st_size > MAX_PARAM_FILE_SIZE) {
 		i_error("Corrupted file: %s", param->path);
+		i_close_fd(&fd);
 		(void)unlink(param->path);
 		return -1;
 	}


More information about the dovecot-cvs mailing list