]> granicus.if.org Git - mutt/commitdiff
Improve imap_append_message() error message handling.
authorKevin McCarthy <kevin@8t8.us>
Fri, 7 Jun 2019 20:43:36 +0000 (13:43 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 7 Jun 2019 21:03:35 +0000 (14:03 -0700)
If the rc is IMAP_CMD_BAD, then either idata->buf is stale or an error
message has already been printed (in cmd_handle_untagged()).

Use imap_next_word() to skip over the next two words instead of
directly skipping over SEQLEN, in case the buffer is in a different
format.  We don't want to jump over the end of string.

Skip the mutt_error() if there is nothing to print.

imap/message.c

index db779bd1724c63e580c85cc4dbc90ac01a1437b7..be6e4a7e3955e82528648235249b51a437b8d997 100644 (file)
@@ -1201,19 +1201,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
   while (rc == IMAP_CMD_CONTINUE);
 
   if (rc != IMAP_CMD_RESPOND)
-  {
-    char *pc;
-
-    dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
-               idata->buf));
-
-    pc = idata->buf + SEQLEN;
-    SKIPWS (pc);
-    pc = imap_next_word (pc);
-    mutt_error ("%s", pc);
-    mutt_sleep (1);
-    goto fail;
-  }
+    goto cmd_step_fail;
 
   for (last = EOF, sent = len = 0; (c = fgetc(fp)) != EOF; last = c)
   {
@@ -1244,22 +1232,27 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
   while (rc == IMAP_CMD_CONTINUE);
 
   if (rc != IMAP_CMD_OK)
+    goto cmd_step_fail;
+
+  FREE (&mx.mbox);
+  return 0;
+
+cmd_step_fail:
+  dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
+              idata->buf));
+  if (rc != IMAP_CMD_BAD)
   {
     char *pc;
 
-    dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
-               idata->buf));
-    pc = idata->buf + SEQLEN;
-    SKIPWS (pc);
-    pc = imap_next_word (pc);
-    mutt_error ("%s", pc);
-    mutt_sleep (1);
-    goto fail;
+    pc = imap_next_word (idata->buf);  /* skip sequence number or token */
+    pc = imap_next_word (pc);          /* skip response code */
+    if (*pc)
+    {
+      mutt_error ("%s", pc);
+      mutt_sleep (1);
+    }
   }
 
-  FREE (&mx.mbox);
-  return 0;
-
 fail:
   safe_fclose (&fp);
   FREE (&mx.mbox);