]> granicus.if.org Git - neomutt/commitdiff
Handle a BAD response in AUTH PLAIN w/o initial response (#1237)
authorPietro Cerutti <gahr@gahr.ch>
Wed, 30 May 2018 12:44:14 +0000 (13:44 +0100)
committerGitHub <noreply@github.com>
Wed, 30 May 2018 12:44:14 +0000 (13:44 +0100)
The incorrect assumption was that the first line of an AUTH PLAIN w/o
I-R was always successful, so the client could write the second line and
end up with a readable socket that would be activated by the server
sending the final OK or BAD response.
If however the first line results in a BAD response already, the server
wouldn't write anything else and the client would be left polling for an
additional response that never arrives, effectively hanging the process.

Issue #1236

imap/auth_plain.c

index 8d2be3eeda95d9ed6f4d20faa4920530ec031dd5..a46a2ad2b6c1385270464cda3e9417b7346ce1bd 100644 (file)
@@ -45,7 +45,7 @@
  */
 enum ImapAuthRes imap_auth_plain(struct ImapData *idata, const char *method)
 {
-  int rc;
+  int rc = IMAP_CMD_CONTINUE;
   enum ImapAuthRes res = IMAP_AUTH_SUCCESS;
   static const char auth_plain_cmd[] = "AUTHENTICATE PLAIN";
   char buf[STRING];
@@ -72,9 +72,10 @@ enum ImapAuthRes imap_auth_plain(struct ImapData *idata, const char *method)
      * credentials after the first command continuation request */
     buf[sizeof(auth_plain_cmd) - 1] = '\0';
     imap_cmd_start(idata, buf);
-    do
+    while (rc == IMAP_CMD_CONTINUE)
+    {
       rc = imap_cmd_step(idata);
-    while (rc == IMAP_CMD_CONTINUE);
+    }
     if (rc == IMAP_CMD_RESPOND)
     {
       mutt_socket_send(idata->conn, buf + sizeof(auth_plain_cmd));
@@ -82,9 +83,10 @@ enum ImapAuthRes imap_auth_plain(struct ImapData *idata, const char *method)
     }
   }
 
-  do
+  while (rc == IMAP_CMD_CONTINUE)
+  {
     rc = imap_cmd_step(idata);
-  while (rc == IMAP_CMD_CONTINUE);
+  }
 
   if (rc == IMAP_CMD_BAD)
   {