From: Aki Tuomi Date: Mon, 5 Jun 2017 09:44:06 +0000 (+0300) Subject: lib-auth: Prevent double-disconnect X-Git-Tag: 2.3.1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e1e25eb9b30e472ffb72340b440bb610eafbcea;p=thirdparty%2Fdovecot%2Fcore.git lib-auth: Prevent double-disconnect When disconnecting, it's possible that disconnect gets called twice by some callback, so protect it with a boolean. Fixes Panic: file hash.c: line 152 (hash_table_clear): assertion failed: (table->frozen == 0) --- diff --git a/src/lib-auth/auth-server-connection.c b/src/lib-auth/auth-server-connection.c index 4a49795939..687ca01409 100644 --- a/src/lib-auth/auth-server-connection.c +++ b/src/lib-auth/auth-server-connection.c @@ -348,6 +348,9 @@ auth_server_connection_remove_requests(struct auth_server_connection *conn, void auth_server_connection_disconnect(struct auth_server_connection *conn, const char *reason) { + if (!conn->connected) + return; + conn->connected = FALSE; conn->handshake_received = FALSE; conn->version_received = FALSE; conn->has_plain_mech = FALSE; @@ -420,6 +423,7 @@ int auth_server_connection_connect(struct auth_server_connection *conn) const char *handshake; int fd; + i_assert(!conn->connected); i_assert(conn->fd == -1); conn->last_connect = ioloop_time; @@ -443,6 +447,7 @@ int auth_server_connection_connect(struct auth_server_connection *conn) conn->io = io_add(fd, IO_READ, auth_server_connection_input, conn); conn->input = i_stream_create_fd(fd, AUTH_SERVER_CONN_MAX_LINE_LENGTH); conn->output = o_stream_create_fd(fd, (size_t)-1); + conn->connected = TRUE; handshake = t_strdup_printf("VERSION\t%u\t%u\nCPID\t%u\n", AUTH_CLIENT_PROTOCOL_MAJOR_VERSION, diff --git a/src/lib-auth/auth-server-connection.h b/src/lib-auth/auth-server-connection.h index 623daf0bd6..988fbfa435 100644 --- a/src/lib-auth/auth-server-connection.h +++ b/src/lib-auth/auth-server-connection.h @@ -25,6 +25,7 @@ struct auth_server_connection { bool version_received:1; bool handshake_received:1; bool has_plain_mech:1; + bool connected:1; }; struct auth_server_connection *