changeset 20941:868cf176e7ff

director: Fix crash handling director_flush_socket when user is freed.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 22 Oct 2016 22:45:48 +0300
parents 8de947fa3b4d
children d8169b055abe
files src/director/director.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director.c	Thu Oct 13 16:11:48 2016 +0300
+++ b/src/director/director.c	Sat Oct 22 22:45:48 2016 +0300
@@ -703,6 +703,7 @@
 struct director_user_kill_finish_ctx {
 	struct director *dir;
 	unsigned int username_hash;
+	struct ip_addr host_ip;
 	struct user *user;
 	struct program_client *pclient;
 	struct ostream *reply;
@@ -726,14 +727,14 @@
 		data = i_stream_read_next_line(is);
 		i_error("%s: Failed to flush user hash %u in host %s: %s",
 			ctx->socket_path,
-			user->username_hash,
-			net_ip2addr(&user->host->ip),
+			ctx->username_hash,
+			net_ip2addr(&ctx->host_ip),
 			data == NULL ? "(no output to stdout)" : data);
 		while((data = i_stream_read_next_line(is)) != NULL) {
 			i_error("%s: Failed to flush user hash %u in host %s: %s",
 				ctx->socket_path,
-				user->username_hash,
-				net_ip2addr(&user->host->ip),
+				ctx->username_hash,
+				net_ip2addr(&ctx->host_ip),
 				data);
 		}
 		i_stream_unref(&is);
@@ -763,6 +764,7 @@
 	struct director_user_kill_finish_ctx *ctx =
 		i_new(struct director_user_kill_finish_ctx, 1);
 	ctx->username_hash = user->username_hash;
+	ctx->host_ip = user->host->ip;
 	ctx->dir = dir;
 
 	string_t *s_sock = str_new(default_pool, 32);