From: Timo Sirainen Date: Fri, 22 Dec 2017 13:07:28 +0000 (+0200) Subject: doveadm: Fix potential crash or reading garbage from doveadm-server X-Git-Tag: 2.2.34~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=902b195ded57c866dad9563653c59eb77fbf158c;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Fix potential crash or reading garbage from doveadm-server The connection's input buffer may have been reallocated or otherwise moved while checking for log input. --- diff --git a/src/doveadm/server-connection.c b/src/doveadm/server-connection.c index 2e330f97c6..6723fe2a94 100644 --- a/src/doveadm/server-connection.c +++ b/src/doveadm/server-connection.c @@ -397,14 +397,15 @@ static bool server_connection_input_one(struct server_connection *conn) const char *line; int exit_code; + /* check logs - NOTE: must be before i_stream_get_data() since checking + for logs may add data to our channel. */ + if (conn->log_input != NULL) + (void)server_connection_print_log(conn); + data = i_stream_get_data(conn->input, &size); if (size == 0) return FALSE; - /* check logs */ - if (conn->log_input != NULL) - (void)server_connection_print_log(conn); - switch (conn->state) { case SERVER_REPLY_STATE_DONE: i_error("doveadm server sent unexpected input");