From 499e30c4bb185b3a52414ef716543b329ba46a2e Mon Sep 17 00:00:00 2001
From: Steve Holme <steve_holme@hotmail.com>
Date: Sun, 27 Jan 2013 10:41:10 +0000
Subject: [PATCH] imap.c: Fixed unnecessary state change if starttls fails

The state machine should only be changed to IMAP_STARTTLS when the
STARTTLS command has been successfully sent to the server.
---
 lib/imap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/imap.c b/lib/imap.c
index 5e845fb356..4191f5722c 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -601,7 +601,8 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn,
        to TLS connection now */
     const char *str = getcmdid(conn);
     result = imap_sendf(conn, str, "%s STARTTLS", str);
-    state(conn, IMAP_STARTTLS);
+    if(!result)
+      state(conn, IMAP_STARTTLS);
   }
   else
     result = imap_state_capability(conn);
-- 
GitLab