dovecot-2.2: Added various asserts to try to silence Coverity fa...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jun 12 23:20:48 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/4a396f0c3b79
changeset: 17476:4a396f0c3b79
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 13 01:57:04 2014 +0300
description:
Added various asserts to try to silence Coverity false positives.

diffstat:

 src/auth/auth-request.c                        |  3 +++
 src/lib-imap-client/imapc-client.c             |  1 +
 src/lib-index/mail-index-map-read.c            |  1 +
 src/lib-settings/settings.c                    |  1 +
 src/lib-storage/index/dbox-common/dbox-save.c  |  2 ++
 src/lib-storage/index/mbox/mbox-save.c         |  1 +
 src/lib-storage/list/mailbox-list-index-sync.c |  1 +
 src/lib/connection.c                           |  1 +
 src/lib/ioloop-notify-inotify.c                |  1 +
 src/master/main.c                              |  1 +
 10 files changed, 13 insertions(+), 0 deletions(-)

diffs (122 lines):

diff -r d26130954761 -r 4a396f0c3b79 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/auth/auth-request.c	Fri Jun 13 01:57:04 2014 +0300
@@ -2151,15 +2151,18 @@
 
 	if (subsystem == AUTH_SUBSYS_DB) {
 		if (!auth_request->userdb_lookup) {
+			i_assert(auth_request->passdb != NULL);
 			name = auth_request->passdb->set->name[0] != '\0' ?
 				auth_request->passdb->set->name :
 				auth_request->passdb->passdb->iface.name;
 		} else {
+			i_assert(auth_request->userdb != NULL);
 			name = auth_request->userdb->set->name[0] != '\0' ?
 				auth_request->userdb->set->name :
 				auth_request->userdb->userdb->iface->name;
 		}
 	} else if (subsystem == AUTH_SUBSYS_MECH) {
+		i_assert(auth_request->mech == NULL);
 		name = t_str_lcase(auth_request->mech->mech_name);
 	} else {
 		name = subsystem;
diff -r d26130954761 -r 4a396f0c3b79 src/lib-imap-client/imapc-client.c
--- a/src/lib-imap-client/imapc-client.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-imap-client/imapc-client.c	Fri Jun 13 01:57:04 2014 +0300
@@ -411,6 +411,7 @@
 	}
 
 	/* fallback to whatever exists (there always exists one) */
+	i_assert(conn != NULL);
 	return imapc_connection_get_capabilities(conn);
 }
 
diff -r d26130954761 -r 4a396f0c3b79 src/lib-index/mail-index-map-read.c
--- a/src/lib-index/mail-index-map-read.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-index/mail-index-map-read.c	Fri Jun 13 01:57:04 2014 +0300
@@ -306,6 +306,7 @@
 		   build it from the transaction log. */
 		return 1;
 	}
+	i_assert(index->fd != -1);
 
 	if ((index->flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0)
 		nfs_flush_attr_cache_fd_locked(index->filepath, index->fd);
diff -r d26130954761 -r 4a396f0c3b79 src/lib-settings/settings.c
--- a/src/lib-settings/settings.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-settings/settings.c	Fri Jun 13 01:57:04 2014 +0300
@@ -356,6 +356,7 @@
 				if (skip > 0)
 					skip--;
 				else {
+					i_assert(sect_callback != NULL);
 					sect_callback(NULL, NULL, context,
 						      &errormsg);
 					if (root_section == sections &&
diff -r d26130954761 -r 4a396f0c3b79 src/lib-storage/index/dbox-common/dbox-save.c
--- a/src/lib-storage/index/dbox-common/dbox-save.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-save.c	Fri Jun 13 01:57:04 2014 +0300
@@ -102,6 +102,8 @@
 	struct mail_save_data *mdata = &ctx->ctx.data;
 	struct ostream *dbox_output = ctx->dbox_output;
 
+	i_assert(mdata->output != NULL);
+
 	if (mdata->attach != NULL && !ctx->failed) {
 		if (index_attachment_save_finish(&ctx->ctx) < 0)
 			ctx->failed = TRUE;
diff -r d26130954761 -r 4a396f0c3b79 src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Fri Jun 13 01:57:04 2014 +0300
@@ -768,6 +768,7 @@
 	int ret = 0;
 
 	i_assert(ctx->finished);
+	i_assert(mbox->mbox_fd != -1);
 
 	if (fstat(mbox->mbox_fd, &st) < 0) {
 		mbox_set_syscall_error(mbox, "fstat()");
diff -r d26130954761 -r 4a396f0c3b79 src/lib-storage/list/mailbox-list-index-sync.c
--- a/src/lib-storage/list/mailbox-list-index-sync.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib-storage/list/mailbox-list-index-sync.c	Fri Jun 13 01:57:04 2014 +0300
@@ -175,6 +175,7 @@
 			buffer_append(hdr_buf, id_p, sizeof(*id_p));
 			name = hash_table_lookup(ilist->mailbox_names,
 						 POINTER_CAST(*id_p));
+			i_assert(name != NULL);
 			buffer_append(hdr_buf, name, strlen(name) + 1);
 			prev_id = *id_p;
 		}
diff -r d26130954761 -r 4a396f0c3b79 src/lib/connection.c
--- a/src/lib/connection.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib/connection.c	Fri Jun 13 01:57:04 2014 +0300
@@ -325,6 +325,7 @@
 		case CONNECTION_BEHAVIOR_ALLOW:
 			return -2;
 		}
+		i_unreached();
 	case -1:
 		/* disconnected */
 		conn->disconnect_reason =
diff -r d26130954761 -r 4a396f0c3b79 src/lib/ioloop-notify-inotify.c
--- a/src/lib/ioloop-notify-inotify.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/lib/ioloop-notify-inotify.c	Fri Jun 13 01:57:04 2014 +0300
@@ -61,6 +61,7 @@
 			break;
 
 		event = (struct inotify_event *)(event_buf + pos);
+		i_assert(event->len < ret);
 		pos += sizeof(*event) + event->len;
 
 		io = io_notify_fd_find(&ctx->fd_ctx, event->wd);
diff -r d26130954761 -r 4a396f0c3b79 src/master/main.c
--- a/src/master/main.c	Fri Jun 13 01:52:13 2014 +0300
+++ b/src/master/main.c	Fri Jun 13 01:57:04 2014 +0300
@@ -816,6 +816,7 @@
 			break;
 		}
 	}
+	i_assert(optind <= argc);
 
 	if (doveconf_arg != NULL) {
 		const char **args;


More information about the dovecot-cvs mailing list