]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Fix crash handling director_flush_socket when user is freed.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 22 Oct 2016 19:45:48 +0000 (22:45 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Oct 2016 11:26:03 +0000 (14:26 +0300)
src/director/director.c

index 97367ea0b368efa369df672080523d95b00258d2..9f1999a7cafa3eaab958333ffff711444a914af5 100644 (file)
@@ -703,6 +703,7 @@ void director_update_user_weak(struct director *dir, struct director_host *src,
 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 @@ director_flush_user_continue(int result,
                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 @@ director_flush_user(struct director *dir, struct user *user)
        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);