dovecot-2.2: Make static analyzer happier.

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 24 20:57:39 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/c257b9c19915
changeset: 14673:c257b9c19915
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jun 24 20:52:39 2012 +0300
description:
Make static analyzer happier.

diffstat:

 src/auth/auth-request.c                   |  2 ++
 src/auth/db-ldap.c                        |  1 +
 src/auth/password-scheme.c                |  2 +-
 src/lib-index/mail-transaction-log-file.c |  7 +++++--
 src/lib-index/mail-transaction-log.c      |  1 +
 src/lib-storage/index/mbox/mbox-mail.c    |  4 ++--
 src/lib-storage/index/mbox/mbox-save.c    |  1 +
 src/plugins/fts-squat/squat-uidlist.c     |  2 ++
 8 files changed, 15 insertions(+), 5 deletions(-)

diffs (122 lines):

diff -r cc6d2b34965d -r c257b9c19915 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/auth/auth-request.c	Sun Jun 24 20:52:39 2012 +0300
@@ -1250,6 +1250,8 @@
 	i_assert(*name != '\0');
 	i_assert(value != NULL);
 
+	i_assert(request->passdb != NULL);
+
 	if (strcmp(name, "password") == 0) {
 		auth_request_set_password(request, value,
 					  default_scheme, FALSE);
diff -r cc6d2b34965d -r c257b9c19915 src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/auth/db-ldap.c	Sun Jun 24 20:52:39 2012 +0300
@@ -866,6 +866,7 @@
 		ret = ldap_start_tls_s(conn->ld, NULL, NULL);
 		if (ret != LDAP_SUCCESS) {
 			if (ret == LDAP_OPERATIONS_ERROR &&
+			    conn->set.uris != NULL &&
 			    strncmp(conn->set.uris, "ldaps:", 6) == 0) {
 				i_fatal("LDAP: Don't use both tls=yes "
 					"and ldaps URI");
diff -r cc6d2b34965d -r c257b9c19915 src/auth/password-scheme.c
--- a/src/auth/password-scheme.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/auth/password-scheme.c	Sun Jun 24 20:52:39 2012 +0300
@@ -367,7 +367,7 @@
 		str = password_generate_md5_crypt(plaintext, password);
 		return strcmp(str, password) == 0 ? 1 : 0;
 	} else if (password_decode(password, "PLAIN-MD5",
-				   &md5_password, &md5_size, &error) < 0) {
+				   &md5_password, &md5_size, &error) <= 0) {
 		*error_r = "Not a valid MD5-CRYPT or PLAIN-MD5 password";
 		return -1;
 	} else {
diff -r cc6d2b34965d -r c257b9c19915 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/lib-index/mail-transaction-log-file.c	Sun Jun 24 20:52:39 2012 +0300
@@ -1673,6 +1673,7 @@
 				file->filepath);
 			return 0;
 		}
+		i_assert(file->buffer != NULL);
 		return log_file_map_check_offsets(file, start_offset,
 						  end_offset);
 	}
@@ -1695,9 +1696,11 @@
 
 	i_assert(file->buffer == NULL || file->mmap_base != NULL ||
 		 file->sync_offset >= file->buffer_offset + file->buffer->used);
+	if (ret <= 0)
+		return ret;
 
-	return ret <= 0 ? ret :
-		log_file_map_check_offsets(file, start_offset, end_offset);
+	i_assert(file->buffer != NULL);
+	return log_file_map_check_offsets(file, start_offset, end_offset);
 }
 
 void mail_transaction_log_file_move_to_memory(struct mail_transaction_log_file
diff -r cc6d2b34965d -r c257b9c19915 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/lib-index/mail-transaction-log.c	Sun Jun 24 20:52:39 2012 +0300
@@ -463,6 +463,7 @@
 		/* try again */
 	}
 
+	i_assert(ret < 0 || log->head != NULL);
 	return ret;
 }
 
diff -r cc6d2b34965d -r c257b9c19915 src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Sun Jun 24 20:52:39 2012 +0300
@@ -240,6 +240,8 @@
 	int trailer_size;
 	int ret = 1;
 
+	*next_offset_r = (uoff_t)-1;
+
 	hdr = mail_index_get_header(mail->mail.mail.transaction->view);
 	if (mail->mail.mail.seq > hdr->messages_count) {
 		/* we're appending a new message */
@@ -341,8 +343,6 @@
 				  mail->mail.mail.uid);
 		}
 	}
-	if (ret <= 0)
-		next_offset = (uoff_t)-1;
 
 	raw_stream = mbox->mbox_stream;
 	hdr_offset = istream_raw_mbox_get_header_offset(raw_stream);
diff -r cc6d2b34965d -r c257b9c19915 src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Sun Jun 24 20:52:39 2012 +0300
@@ -666,6 +666,7 @@
 
 	ctx->finished = TRUE;
 	if (!ctx->failed) {
+		i_assert(ctx->output != NULL);
 		T_BEGIN {
 			if (mbox_write_content_length(ctx) < 0 ||
 			    mbox_append_lf(ctx) < 0)
diff -r cc6d2b34965d -r c257b9c19915 src/plugins/fts-squat/squat-uidlist.c
--- a/src/plugins/fts-squat/squat-uidlist.c	Sun Jun 24 19:44:22 2012 +0300
+++ b/src/plugins/fts-squat/squat-uidlist.c	Sun Jun 24 20:52:39 2012 +0300
@@ -1416,6 +1416,7 @@
 		squat_uidlist_set_corrupted(uidlist, "uidlist not found");
 		return -1;
 	}
+	i_assert(uidlist->cur_block_end_indexes != NULL);
 	if (unlikely(idx > 0 &&
 		     uidlist->cur_block_end_indexes[idx-1] > uid_list_idx)) {
 		squat_uidlist_set_corrupted(uidlist, "broken block list");
@@ -1430,6 +1431,7 @@
 		return -1;
 
 	/* find the uidlist inside the block */
+	i_assert(uidlist->cur_block_offsets != NULL);
 	p = CONST_PTR_OFFSET(uidlist->data, uidlist->cur_block_offsets[idx]);
 	end = CONST_PTR_OFFSET(uidlist->data, uidlist->data_size);
 


More information about the dovecot-cvs mailing list