]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Fix potential crash or reading garbage from doveadm-server
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 22 Dec 2017 13:07:28 +0000 (15:07 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 22 Dec 2017 13:33:29 +0000 (15:33 +0200)
The connection's input buffer may have been reallocated or otherwise moved
while checking for log input.

src/doveadm/server-connection.c

index b8a0263eaefba8d0fd042b78a11eb5934188331c..306bc68e0792e3f038011fb722424eae2a170cb8 100644 (file)
@@ -409,14 +409,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");