From: Timo Sirainen Date: Wed, 16 Dec 2015 09:59:41 +0000 (+0200) Subject: imap: Fixed potential crash when logging about pending commands at logout. X-Git-Tag: 2.2.22.rc1~403 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8e9fa2ffa2566e75f0500808b1bc9bf5d9db024;p=thirdparty%2Fdovecot%2Fcore.git imap: Fixed potential crash when logging about pending commands at logout. --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 07cacd4669..85cb5f2841 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -279,6 +279,11 @@ static const char *client_get_commands_status(struct client *client) str = t_str_new(128); str_append(str, " ("); for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) { + if (cmd->name == NULL) { + /* (parts of a) tag were received, but not yet + the command name */ + continue; + } str_append(str, cmd->name); if (cmd->next != NULL) str_append_c(str, ','); @@ -287,6 +292,8 @@ static const char *client_get_commands_status(struct client *client) bytes_out += cmd->bytes_out; last_cmd = cmd; } + if (str_len(str) <= 2) + return ""; cond = io_loop_find_fd_conditions(current_ioloop, client->fd_out); if ((cond & (IO_READ | IO_WRITE)) == (IO_READ | IO_WRITE))