Some response handlers can end up recursively calling
imap_cmd_start(), processing all the command completions. If the
outer call was an imap_exec(), this would result in the loop never
being terminated (or just blocking reading a server that has already
finished all the commands).
Change the callers that are simply using it to read a response,
without having called cmd_start(), to check for IMAP_CMD_OK instead.
Currently this is just the open connection function.
if (idata->buf[0] == '+')
return IMAP_CMD_RESPOND;
- /* look for tagged command completions */
- rc = IMAP_CMD_CONTINUE;
+ /* Look for tagged command completions.
+ *
+ * Some response handlers can end up recursively calling
+ * imap_cmd_step() and end up handling all tagged command
+ * completions.
+ * (e.g. FETCH->set_flag->set_header_color->~h pattern match.)
+ *
+ * Other callers don't even create an idata->cmds entry.
+ *
+ * For both these cases, we default to returning OK */
+ rc = IMAP_CMD_OK;
c = idata->lastcmd;
do
{
idata->state = IMAP_CONNECTED;
- if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE)
+ if (imap_cmd_step(idata) != IMAP_CMD_OK)
{
imap_close_connection(idata);
return -1;