[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.55, 1.56 index-mail.c, 1.88, 1.89 index-mailbox-check.c, 1.13, 1.14 index-search.c, 1.107, 1.108 index-storage.c, 1.80, 1.81 index-sync.c, 1.53, 1.54 index-transaction.c, 1.13, 1.14

cras at dovecot.org cras at dovecot.org
Sat Jan 14 20:47:46 EET 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv16037/lib-storage/index

Modified Files:
	index-mail-headers.c index-mail.c index-mailbox-check.c 
	index-search.c index-storage.c index-sync.c 
	index-transaction.c 
Log Message:
deinit, unref, destroy, close, free, etc. functions now take a pointer to
their data pointer, and set it to NULL. This makes double-frees less likely
to cause security holes.



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- index-mail-headers.c	13 Jan 2006 20:26:25 -0000	1.55
+++ index-mail-headers.c	14 Jan 2006 18:47:42 -0000	1.56
@@ -406,7 +406,7 @@
 				     imap_envelope_parse_callback, mail);
 		mail->data.save_envelope = FALSE;
 	}
-	mailbox_header_lookup_deinit(header_ctx);
+	mailbox_header_lookup_deinit(&header_ctx);
 }
 
 static size_t get_header_size(buffer_t *buffer, size_t pos)
@@ -539,7 +539,7 @@
 		headers_ctx = mailbox_header_lookup_init(&mail->ibox->box,
 							 headers);
 		ret = index_mail_parse_headers(mail, headers_ctx);
-		mailbox_header_lookup_deinit(headers_ctx);
+		mailbox_header_lookup_deinit(&headers_ctx);
 		if (ret < 0)
 			return NULL;
 
@@ -624,7 +624,7 @@
 		return NULL;
 
 	if (mail->data.filter_stream != NULL)
-		i_stream_unref(mail->data.filter_stream);
+		i_stream_unref(&mail->data.filter_stream);
 
 	index_mail_parse_header_init(mail, _headers);
 	mail->data.filter_stream =

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- index-mail.c	13 Jan 2006 20:26:25 -0000	1.88
+++ index-mail.c	14 Jan 2006 18:47:42 -0000	1.89
@@ -371,7 +371,7 @@
 	} else {
 		message_parser_parse_body(data->parser_ctx, NULL, NULL, NULL);
 	}
-	data->parts = message_parser_deinit(data->parser_ctx);
+	data->parts = message_parser_deinit(&data->parser_ctx);
         data->parser_ctx = NULL;
 
 	if (data->parsed_bodystructure &&
@@ -734,9 +734,9 @@
 static void index_mail_close(struct index_mail *mail)
 {
 	if (mail->data.stream != NULL)
-		i_stream_unref(mail->data.stream);
+		i_stream_unref(&mail->data.stream);
 	if (mail->data.filter_stream != NULL)
-		i_stream_unref(mail->data.filter_stream);
+		i_stream_unref(&mail->data.filter_stream);
 }
 
 int index_mail_set_seq(struct mail *_mail, uint32_t seq)

Index: index-mailbox-check.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mailbox-check.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- index-mailbox-check.c	13 Jan 2006 20:26:25 -0000	1.13
+++ index-mailbox-check.c	14 Jan 2006 18:47:42 -0000	1.14
@@ -118,12 +118,10 @@
 		aio = ibox->notify_ios;
 		ibox->notify_ios = aio->next;
 
-		io_remove(aio->io);
+		io_remove(&aio->io);
 		i_free(aio);
 	}
 
-	if (ibox->notify_to != NULL) {
-		timeout_remove(ibox->notify_to);
-		ibox->notify_to = NULL;
-	}
+	if (ibox->notify_to != NULL)
+		timeout_remove(&ibox->notify_to);
 }

Index: index-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- index-search.c	14 Jan 2006 15:19:56 -0000	1.107
+++ index-search.c	14 Jan 2006 18:47:42 -0000	1.108
@@ -515,7 +515,7 @@
 							   headers);
 			input = mail_get_header_stream(ctx->mail, headers_ctx);
 			if (input == NULL) {
-				mailbox_header_lookup_deinit(headers_ctx);
+				mailbox_header_lookup_deinit(&headers_ctx);
 				return FALSE;
 			}
 		}
@@ -530,7 +530,7 @@
 		message_parse_header(NULL, input, NULL,
 				     search_header, &hdr_ctx);
 		if (headers_ctx != NULL)
-			mailbox_header_lookup_deinit(headers_ctx);
+			mailbox_header_lookup_deinit(&headers_ctx);
 	} else {
 		struct message_size hdr_size;
 

Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- index-storage.c	13 Jan 2006 20:26:25 -0000	1.80
+++ index-storage.c	14 Jan 2006 18:47:42 -0000	1.81
@@ -81,7 +81,7 @@
 
 static void index_list_free(struct index_list *list)
 {
-	mail_index_free(list->index);
+	mail_index_free(&list->index);
 	i_free(list->mailbox_path);
 	i_free(list);
 }
@@ -165,10 +165,8 @@
 		}
 	}
 
-	if (indexes == NULL && to_index != NULL) {
-		timeout_remove(to_index);
-		to_index = NULL;
-	}
+	if (indexes == NULL && to_index != NULL)
+		timeout_remove(&to_index);
 }
 
 static void index_removal_timeout(void *context __attr_unused__)
@@ -374,7 +372,7 @@
 	struct index_mailbox *ibox = (struct index_mailbox *) box;
 
 	if (ibox->view != NULL)
-		mail_index_view_close(ibox->view);
+		mail_index_view_close(&ibox->view);
 
 	index_mailbox_check_remove_all(ibox);
 	if (ibox->index != NULL)
@@ -454,5 +452,5 @@
 void index_keywords_free(struct mailbox_transaction_context *t __attr_unused__,
 			 struct mail_keywords *keywords)
 {
-	mail_index_keywords_free(keywords);
+	mail_index_keywords_free(&keywords);
 }

Index: index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- index-sync.c	13 Jan 2006 20:26:25 -0000	1.53
+++ index-sync.c	14 Jan 2006 18:47:42 -0000	1.54
@@ -248,7 +248,7 @@
 	int ret = ctx->failed ? -1 : 0;
 
 	if (ctx->sync_ctx != NULL)
-		mail_index_view_sync_end(ctx->sync_ctx);
+		mail_index_view_sync_end(&ctx->sync_ctx);
 
 	if (ret == 0) {
 		messages_count = mail_index_view_get_messages_count(ibox->view);

Index: index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-transaction.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- index-transaction.c	10 Dec 2005 18:56:03 -0000	1.13
+++ index-transaction.c	14 Jan 2006 18:47:42 -0000	1.14
@@ -27,7 +27,7 @@
 static void index_transaction_free(struct index_transaction_context *t)
 {
 	mail_cache_view_close(t->cache_view);
-	mail_index_view_close(t->trans_view);
+	mail_index_view_close(&t->trans_view);
 	mail_index_view_unlock(t->ibox->view);
 	array_free(&t->mailbox_ctx.module_contexts);
 	i_free(t);
@@ -41,7 +41,7 @@
 	uoff_t offset;
 	int ret;
 
-	ret = mail_index_transaction_commit(t->trans, &seq, &offset);
+	ret = mail_index_transaction_commit(&t->trans, &seq, &offset);
 	if (ret < 0)
 		mail_storage_set_index_error(t->ibox);
 	else {
@@ -60,6 +60,6 @@
 	struct index_transaction_context *t =
 		(struct index_transaction_context *)_t;
 
-	mail_index_transaction_rollback(t->trans);
+	mail_index_transaction_rollback(&t->trans);
 	index_transaction_free(t);
 }



More information about the dovecot-cvs mailing list