From: Steve Holme Date: Thu, 24 Jan 2013 20:22:20 +0000 (+0000) Subject: imap.c: Fixed failure detection during TLS upgrade X-Git-Tag: curl-7_29_0~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=379d63ecc7e361fcfea5ef40881307b497e0c625;p=thirdparty%2Fcurl.git imap.c: Fixed failure detection during TLS upgrade imap_state_upgrade_tls() would attempt to incorrectly complete the upgrade to imaps and start the CAPABILITY command if Curl_ssl_connect_nonblocking() returned a failure code and if ssldone was set to TRUE. This would only happen when a non-blocking API hadn't been provided by the SSL implementation and curlssl_connect() was called underneath. --- diff --git a/lib/imap.c b/lib/imap.c index 288d1994f3..5e845fb356 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -627,10 +627,8 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn, else result = imap_state_capability(conn); } - else { - state(conn, IMAP_UPGRADETLS); + else result = imap_state_upgrade_tls(conn); - } return result; } @@ -642,9 +640,14 @@ static CURLcode imap_state_upgrade_tls(struct connectdata *conn) result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); - if(imapc->ssldone) { - imap_to_imaps(conn); - result = imap_state_capability(conn); + if(!result) { + if(imapc->state != IMAP_UPGRADETLS) + state(conn, IMAP_UPGRADETLS); + + if(imapc->ssldone) { + imap_to_imaps(conn); + result = imap_state_capability(conn); + } } return result;