]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fixed potential crash when logging about pending commands at logout.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Dec 2015 09:59:41 +0000 (11:59 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Dec 2015 09:59:41 +0000 (11:59 +0200)
src/imap/imap-client.c

index 07cacd466920a80bb2e10605e4cead242971a552..85cb5f28417ab2d948577c18ef5c68778312c92f 100644 (file)
@@ -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))