]> 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)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 3 Jan 2018 10:40:29 +0000 (12:40 +0200)
The connection's input buffer may have been reallocated or otherwise moved
while checking for log input.

src/doveadm/server-connection.c

index 2e330f97c6ac7c2c1f2cfe845db637ccf12b30c3..6723fe2a94026a38f8db2b62fb757f8d45753e39 100644 (file)
@@ -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");