[dovecot-cvs] dovecot/src/lib-dict dict-client.c, 1.4, 1.5 dict-sql.c, 1.4, 1.5 dict.c, 1.4, 1.5 dict.h, 1.4, 1.5

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


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

Modified Files:
	dict-client.c dict-sql.c dict.c dict.h 
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: dict-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-client.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict-client.c	13 Jan 2006 20:26:07 -0000	1.4
+++ dict-client.c	14 Jan 2006 18:47:27 -0000	1.5
@@ -208,14 +208,10 @@
 	dict->connect_counter++;
 	dict->handshaked = FALSE;
 
-	if (dict->input != NULL) {
-		i_stream_unref(dict->input);
-		dict->input = NULL;
-	}
-	if (dict->output != NULL) {
-		o_stream_unref(dict->output);
-		dict->output = NULL;
-	}
+	if (dict->input != NULL)
+		i_stream_unref(&dict->input);
+	if (dict->output != NULL)
+		o_stream_unref(&dict->output);
 
 	if (dict->fd != -1) {
 		if (close(dict->fd) < 0)

Index: dict-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-sql.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict-sql.c	13 Jan 2006 20:26:07 -0000	1.4
+++ dict-sql.c	14 Jan 2006 18:47:27 -0000	1.5
@@ -69,7 +69,7 @@
 
 		t_pop();
 	}
-	i_stream_unref(input);
+	i_stream_unref(&input);
 	(void)close(fd);
 
 	if (dict->connect_string == NULL) {
@@ -117,7 +117,7 @@
 {
 	struct sql_dict *dict = (struct sql_dict *)_dict;
 
-	sql_deinit(dict->db);
+	sql_deinit(&dict->db);
 	pool_unref(dict->pool);
 }
 
@@ -217,7 +217,7 @@
 	const char *error;
 	int ret;
 
-	ret = sql_transaction_commit_s(ctx->sql_ctx, &error);
+	ret = sql_transaction_commit_s(&ctx->sql_ctx, &error);
 	if (ret < 0)
 		i_error("sql dict: commit failed: %s", error);
 	i_free(ctx);
@@ -229,7 +229,7 @@
 	struct sql_dict_transaction_context *ctx =
 		(struct sql_dict_transaction_context *)_ctx;
 
-	sql_transaction_rollback(ctx->sql_ctx);
+	sql_transaction_rollback(&ctx->sql_ctx);
 	i_free(ctx);
 }
 

Index: dict.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict.c	13 Jan 2006 20:26:07 -0000	1.4
+++ dict.c	14 Jan 2006 18:47:27 -0000	1.5
@@ -71,8 +71,11 @@
 	return dict->v.init(dict, p+1);
 }
 
-void dict_deinit(struct dict *dict)
+void dict_deinit(struct dict **_dict)
 {
+	struct dict *dict = *_dict;
+
+	*_dict = NULL;
 	dict->v.deinit(dict);
 }
 

Index: dict.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict.h	13 Jan 2006 20:26:07 -0000	1.4
+++ dict.h	14 Jan 2006 18:47:27 -0000	1.5
@@ -13,7 +13,7 @@
    If URI is invalid, returns NULL. */
 struct dict *dict_init(const char *uri);
 /* Close dictionary. */
-void dict_deinit(struct dict *dict);
+void dict_deinit(struct dict **dict);
 
 /* Lookup value for key. Set it to NULL if it's not found.
    Returns 1 if found, 0 if not found and -1 if lookup failed. */



More information about the dovecot-cvs mailing list