Skip to content

Commit

Permalink
doveadm: Fix potential crash or reading garbage from doveadm-server
Browse files Browse the repository at this point in the history
The connection's input buffer may have been reallocated or otherwise moved
while checking for log input.
  • Loading branch information
sirainen committed Dec 22, 2017
1 parent 5bb2888 commit 1082d0b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/doveadm/server-connection.c
Expand Up @@ -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");
Expand Down

0 comments on commit 1082d0b

Please sign in to comment.