[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-file.c, 1.3, 1.4 dbox-list.c, 1.2, 1.3 dbox-save.c, 1.2, 1.3 dbox-sync-expunge.c, 1.4, 1.5 dbox-sync.c, 1.4, 1.5 dbox-uidlist.c, 1.12, 1.13

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


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

Modified Files:
	dbox-file.c dbox-list.c dbox-save.c dbox-sync-expunge.c 
	dbox-sync.c dbox-uidlist.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: dbox-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-file.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbox-file.c	5 Jan 2006 01:10:46 -0000	1.3
+++ dbox-file.c	14 Jan 2006 18:47:46 -0000	1.4
@@ -39,7 +39,7 @@
 void dbox_file_close(struct dbox_file *file)
 {
 	if (file->input != NULL)
-		i_stream_unref(file->input);
+		i_stream_unref(&file->input);
 	if (file->fd != -1) {
 		if (close(file->fd) < 0)
 			i_error("close(dbox) failed: %m");

Index: dbox-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-list.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbox-list.c	13 Jan 2006 20:26:29 -0000	1.2
+++ dbox-list.c	14 Jan 2006 18:47:46 -0000	1.3
@@ -195,7 +195,7 @@
 	if (ctx->list_pool != NULL)
 		pool_unref(ctx->list_pool);
 	if (ctx->glob != NULL)
-		imap_match_deinit(ctx->glob);
+		imap_match_deinit(&ctx->glob);
 	i_free(ctx);
 
 	return ret;

Index: dbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-save.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbox-save.c	13 Jan 2006 20:26:29 -0000	1.2
+++ dbox-save.c	14 Jan 2006 18:47:46 -0000	1.3
@@ -242,7 +242,7 @@
 	}
 
 	if (dbox_uidlist_append_commit(ctx->append_ctx) < 0) {
-		mail_index_sync_rollback(ctx->index_sync_ctx);
+		mail_index_sync_rollback(&ctx->index_sync_ctx);
 		i_free(ctx);
 		return -1;
 	}
@@ -251,14 +251,14 @@
 
 void dbox_transaction_save_commit_post(struct dbox_save_context *ctx)
 {
-	mail_index_sync_rollback(ctx->index_sync_ctx);
+	mail_index_sync_rollback(&ctx->index_sync_ctx);
 	i_free(ctx);
 }
 
 void dbox_transaction_save_rollback(struct dbox_save_context *ctx)
 {
 	if (ctx->index_sync_ctx != NULL)
-		mail_index_sync_rollback(ctx->index_sync_ctx);
+		mail_index_sync_rollback(&ctx->index_sync_ctx);
 
         dbox_uidlist_append_rollback(ctx->append_ctx);
 	i_free(ctx);

Index: dbox-sync-expunge.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-expunge.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dbox-sync-expunge.c	13 Jan 2006 20:26:29 -0000	1.4
+++ dbox-sync-expunge.c	14 Jan 2006 18:47:46 -0000	1.5
@@ -155,7 +155,7 @@
 					      mbox->file->mail_header_size +
 					      mbox->file->seeked_mail_size);
 		ret = o_stream_send_istream(output, input);
-		i_stream_unref(input);
+		i_stream_unref(&input);
 
 		if (ret < 0) {
 			mail_storage_set_critical(STORAGE(mbox->storage),
@@ -186,7 +186,7 @@
 				break;
 		}
 	}
-	o_stream_unref(output);
+	o_stream_unref(&output);
 
 	if (ret < 0) {
 		file_dotlock_delete(&dotlock);

Index: dbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dbox-sync.c	13 Jan 2006 20:26:29 -0000	1.4
+++ dbox-sync.c	14 Jan 2006 18:47:46 -0000	1.5
@@ -307,7 +307,7 @@
 	}
 	if (dbox_uidlist_sync_init(mbox->uidlist, &ctx.uidlist_sync_ctx,
 				   &mtime) < 0) {
-		mail_index_sync_rollback(ctx.index_sync_ctx);
+		mail_index_sync_rollback(&ctx.index_sync_ctx);
 		return -1;
 	}
 
@@ -325,7 +325,7 @@
 		ret = dbox_sync_index(&ctx);
 
 	if (ret < 0) {
-		mail_index_sync_rollback(ctx.index_sync_ctx);
+		mail_index_sync_rollback(&ctx.index_sync_ctx);
 		dbox_uidlist_sync_rollback(ctx.uidlist_sync_ctx);
 		return -1;
 	}
@@ -346,7 +346,7 @@
 	}
 
 	if (dbox_uidlist_sync_commit(ctx.uidlist_sync_ctx, &mtime) < 0) {
-		mail_index_sync_rollback(ctx.index_sync_ctx);
+		mail_index_sync_rollback(&ctx.index_sync_ctx);
 		return -1;
 	}
 
@@ -358,18 +358,18 @@
 			&sync_stamp, sizeof(sync_stamp), TRUE);
 	}
 
-	if (mail_index_transaction_commit(ctx.trans, &seq, &offset) < 0) {
+	if (mail_index_transaction_commit(&ctx.trans, &seq, &offset) < 0) {
 		mail_storage_set_index_error(&mbox->ibox);
-		mail_index_sync_rollback(ctx.index_sync_ctx);
+		mail_index_sync_rollback(&ctx.index_sync_ctx);
 		return -1;
 	}
 
 	if (force) {
-		mail_index_sync_rollback(ctx.index_sync_ctx);
+		mail_index_sync_rollback(&ctx.index_sync_ctx);
 		/* now that indexes are ok, sync changes from the index */
 		return dbox_sync(mbox, FALSE);
 	} else {
-		if (mail_index_sync_commit(ctx.index_sync_ctx) < 0) {
+		if (mail_index_sync_commit(&ctx.index_sync_ctx) < 0) {
 			mail_storage_set_index_error(&mbox->ibox);
 			return -1;
 		}

Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbox-uidlist.c	13 Jan 2006 20:26:29 -0000	1.12
+++ dbox-uidlist.c	14 Jan 2006 18:47:46 -0000	1.13
@@ -397,7 +397,7 @@
 		uidlist->fd = -1;
 	}
 
-	i_stream_unref(input);
+	i_stream_unref(&input);
 	return ret;
 }
 
@@ -521,7 +521,7 @@
 			"write(%s) failed: %m", uidlist->path);
 		ret = -1;
 	}
-	o_stream_unref(output);
+	o_stream_unref(&output);
 
 	if (ret < 0)
 		return -1;
@@ -664,7 +664,7 @@
 			"write(%s) failed: %m", ctx->uidlist->path);
 		ret = -1;
 	}
-	o_stream_unref(output);
+	o_stream_unref(&output);
 
 	if (ret < 0)
 		return -1;
@@ -933,7 +933,7 @@
 	save_file->file = file = p_new(ctx->pool, struct dbox_file, 1);
         save_file->dotlock = dotlock;
 	file->file_seq = file_seq;
-	file->path = str_free_without_data(str);
+	file->path = str_free_without_data(&str);
 
 	file->fd = open(file->path, O_CREAT | O_RDWR, 0600);
 	if (file->fd == -1) {
@@ -955,7 +955,7 @@
 	/* we'll be using CRLF linefeeds always */
 	output = o_stream_create_file(file->fd, default_pool, 0, FALSE);
 	file->output = o_stream_create_crlf(default_pool, output);
-	o_stream_unref(output);
+	o_stream_unref(&output);
 
 	if ((uoff_t)st.st_size < sizeof(struct dbox_file_header)) {
 		if (dbox_file_write_header(mbox, file) < 0) {



More information about the dovecot-cvs mailing list