]> granicus.if.org Git - mutt/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)
committerKevin McCarthy <kevin@8t8.us>
Wed, 19 Jul 2017 21:04:39 +0000 (14:04 -0700)
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 c0c370f6ef5c57e4761b8df6d406f8a439bb7721..468af8158352d1ea203530ad1834d328a391e2e9 100644 (file)
@@ -146,8 +146,17 @@ int imap_cmd_step (IMAP_DATA* 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 b2c48a7b22aab61738c30546a7876fb3d71a3327..967d02598f8447771c219b1037382e08a3159b4c 100644 (file)
@@ -412,7 +412,7 @@ int imap_open_connection (IMAP_DATA* 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;