[dovecot-cvs] dovecot/src/login-common login-proxy.c, 1.5, 1.6 main.c, 1.29, 1.30 master.c, 1.15, 1.16 ssl-proxy-openssl.c, 1.31, 1.32

cras at dovecot.org cras at dovecot.org
Sat Jan 14 20:48:05 EET 2006


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

Modified Files:
	login-proxy.c main.c master.c ssl-proxy-openssl.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: login-proxy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/login-proxy.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- login-proxy.c	7 Jan 2005 12:40:40 -0000	1.5
+++ login-proxy.c	14 Jan 2006 18:48:01 -0000	1.6
@@ -38,7 +38,7 @@
 	    OUTBUF_THRESHOLD) {
 		/* client's output buffer is already quite full.
 		   don't send more until we're below threshold. */
-		io_remove(proxy->server_io);
+		io_remove(&proxy->server_io);
 		proxy->server_io = NULL;
 		return;
 	}
@@ -60,7 +60,7 @@
 	    OUTBUF_THRESHOLD) {
 		/* proxy's output buffer is already quite full.
 		   don't send more until we're below threshold. */
-		io_remove(proxy->client_io);
+		io_remove(&proxy->client_io);
 		proxy->client_io = NULL;
 		return;
 	}
@@ -141,7 +141,7 @@
 		o_stream_create_file(proxy->server_fd, default_pool,
 				     (size_t)-1, FALSE);
 
-	io_remove(proxy->server_io);
+	io_remove(&proxy->server_io);
 	proxy->server_io =
 		io_add(proxy->server_fd, IO_READ, proxy_prelogin_input, proxy);
 }
@@ -205,9 +205,9 @@
 		       proxy->user, net_ip2addr(&ip));
 
 		if (proxy->client_io != NULL)
-			io_remove(proxy->client_io);
+			io_remove(&proxy->client_io);
 		if (proxy->client_output != NULL)
-			o_stream_unref(proxy->client_output);
+			o_stream_unref(&proxy->client_output);
 		net_disconnect(proxy->client_fd);
 	} else {
 		proxy->destroying = TRUE;
@@ -215,11 +215,11 @@
 	}
 
 	if (proxy->server_io != NULL)
-		io_remove(proxy->server_io);
+		io_remove(&proxy->server_io);
 	if (proxy->server_input != NULL)
-		i_stream_unref(proxy->server_input);
+		i_stream_unref(&proxy->server_input);
 	if (proxy->server_output != NULL)
-		o_stream_unref(proxy->server_output);
+		o_stream_unref(&proxy->server_output);
 	net_disconnect(proxy->server_fd);
 
 	i_free(proxy->host);
@@ -243,16 +243,16 @@
 	data = i_stream_get_data(client_input, &size);
 	if (size != 0)
 		(void)o_stream_send(proxy->server_output, data, size);
-	i_stream_unref(client_input);
+	i_stream_unref(&client_input);
 
 	/* from now on, just do dummy proxying */
-	io_remove(proxy->server_io);
+	io_remove(&proxy->server_io);
 	proxy->server_io = io_add(proxy->server_fd, IO_READ, server_input, proxy);
 	proxy->client_io = io_add(proxy->client_fd, IO_READ,
 				  proxy_client_input, proxy);
 	o_stream_set_flush_callback(proxy->server_output, server_output, proxy);
 
-	i_stream_unref(proxy->server_input);
+	i_stream_unref(&proxy->server_input);
         proxy->server_input = NULL;
 
 	if (login_proxies == NULL) {

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- main.c	13 Jan 2006 20:26:39 -0000	1.29
+++ main.c	14 Jan 2006 18:48:01 -0000	1.30
@@ -58,16 +58,14 @@
 		if (close(LOGIN_LISTEN_FD) < 0)
 			i_fatal("close(listen) failed: %m");
 
-		io_remove(io_listen);
-		io_listen = NULL;
+		io_remove(&io_listen);
 	}
 
 	if (io_ssl_listen != NULL) {
 		if (close(LOGIN_SSL_LISTEN_FD) < 0)
 			i_fatal("close(ssl_listen) failed: %m");
 
-		io_remove(io_ssl_listen);
-		io_ssl_listen = NULL;
+		io_remove(&io_ssl_listen);
 	}
 
 	closing_down = TRUE;
@@ -247,13 +245,13 @@
 
 static void main_deinit(void)
 {
-	if (io_listen != NULL) io_remove(io_listen);
-	if (io_ssl_listen != NULL) io_remove(io_ssl_listen);
+	if (io_listen != NULL) io_remove(&io_listen);
+	if (io_ssl_listen != NULL) io_remove(&io_ssl_listen);
 
 	ssl_proxy_deinit();
 	login_proxy_deinit();
 
-	auth_client_free(auth_client);
+	auth_client_free(&auth_client);
 	clients_deinit();
 	master_deinit();
 
@@ -343,7 +341,7 @@
 	io_loop_run(ioloop);
 	main_deinit();
 
-	io_loop_destroy(ioloop);
+	io_loop_destroy(&ioloop);
 	lib_deinit();
 
         return 0;

Index: master.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/master.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- master.c	13 Jan 2006 20:26:39 -0000	1.15
+++ master.c	14 Jan 2006 18:48:01 -0000	1.16
@@ -97,8 +97,7 @@
 		i_fatal("close(master) failed: %m");
 	master_fd = -1;
 
-	io_remove(io_master);
-	io_master = NULL;
+	io_remove(&io_master);
 
         main_close_listen();
 	main_unref();
@@ -153,7 +152,7 @@
 			env_put(line);
 	} while (line == NULL);
 
-	i_stream_unref(input);
+	i_stream_unref(&input);
 }
 
 int master_connect(const char *group_name)
@@ -248,5 +247,5 @@
 	hash_destroy(master_requests);
 
 	if (io_master != NULL)
-		io_remove(io_master);
+		io_remove(&io_master);
 }

Index: ssl-proxy-openssl.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/ssl-proxy-openssl.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- ssl-proxy-openssl.c	13 Jan 2006 20:26:39 -0000	1.31
+++ ssl-proxy-openssl.c	14 Jan 2006 18:48:01 -0000	1.32
@@ -66,10 +66,8 @@
 					    ssl_step, proxy);
 		break;
 	case SSL_REMOVE_INPUT:
-		if (proxy->io_ssl_read != NULL) {
-			io_remove(proxy->io_ssl_read);
-			proxy->io_ssl_read = NULL;
-		}
+		if (proxy->io_ssl_read != NULL)
+			io_remove(&proxy->io_ssl_read);
 		break;
 	case SSL_ADD_OUTPUT:
 		if (proxy->io_ssl_write != NULL)
@@ -78,10 +76,8 @@
 					     ssl_step, proxy);
 		break;
 	case SSL_REMOVE_OUTPUT:
-		if (proxy->io_ssl_write != NULL) {
-			io_remove(proxy->io_ssl_write);
-			proxy->io_ssl_write = NULL;
-		}
+		if (proxy->io_ssl_write != NULL)
+			io_remove(&proxy->io_ssl_write);
 		break;
 	}
 }
@@ -89,10 +85,8 @@
 static void plain_block_input(struct ssl_proxy *proxy, bool block)
 {
 	if (block) {
-		if (proxy->io_plain_read != NULL) {
-			io_remove(proxy->io_plain_read);
-			proxy->io_plain_read = NULL;
-		}
+		if (proxy->io_plain_read != NULL)
+			io_remove(&proxy->io_plain_read);
 	} else {
 		if (proxy->io_plain_read == NULL) {
 			proxy->io_plain_read = io_add(proxy->fd_plain, IO_READ,
@@ -164,10 +158,8 @@
 					       plain_write, proxy);
 			}
 		} else {
-			if (proxy->io_plain_write != NULL) {
-				io_remove(proxy->io_plain_write);
-                                proxy->io_plain_write = NULL;
-			}
+			if (proxy->io_plain_write != NULL)
+				io_remove(&proxy->io_plain_write);
 		}
 
 		ssl_set_io(proxy, SSL_ADD_INPUT);
@@ -428,13 +420,13 @@
 	(void)net_disconnect(proxy->fd_plain);
 
 	if (proxy->io_ssl_read != NULL)
-		io_remove(proxy->io_ssl_read);
+		io_remove(&proxy->io_ssl_read);
 	if (proxy->io_ssl_write != NULL)
-		io_remove(proxy->io_ssl_write);
+		io_remove(&proxy->io_ssl_write);
 	if (proxy->io_plain_read != NULL)
-		io_remove(proxy->io_plain_read);
+		io_remove(&proxy->io_plain_read);
 	if (proxy->io_plain_write != NULL)
-		io_remove(proxy->io_plain_write);
+		io_remove(&proxy->io_plain_write);
 
 	ssl_proxy_unref(proxy);
 }



More information about the dovecot-cvs mailing list