]> granicus.if.org Git - neomutt/commitdiff
Change imap_cmd_start() to return OK when the cmd_queue is finished. (closes #3956)
authorKevin McCarthy <kevin@8t8.us>
Wed, 19 Jul 2017 21:04:39 +0000 (14:04 -0700)
committerRichard Russon <rich@flatcap.org>
Thu, 3 Aug 2017 15:52:53 +0000 (16:52 +0100)
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.

imap/command.c
imap/imap.c

index dac5d5fcd3e0ab7bf2dd77305be687b8b58a8012..902a9ff14abd92e59dfdb8cd898c2f98624bfdd1 100644 (file)
@@ -911,8 +911,17 @@ int imap_cmd_step(struct ImapData *idata)
   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
   {
index b906ca28351768956a4c5082939f196cefa6fb90..048a4a295ef68311f54151642edd20c969dea8e7 100644 (file)
@@ -454,7 +454,7 @@ int imap_open_connection(struct ImapData *idata)
 
   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;