From: Steve Holme Date: Thu, 24 Jan 2013 20:27:43 +0000 (+0000) Subject: smtp.c: Fixed failure detection during TLS upgrade X-Git-Tag: curl-7_29_0~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8ba1273af2b9760d373ed012b081fda29f6169d;p=thirdparty%2Fcurl.git smtp.c: Fixed failure detection during TLS upgrade smtp_state_upgrade_tls() would attempt to incorrectly complete the upgrade to smtps and start the EHLO 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/smtp.c b/lib/smtp.c index 05c0a780a2..36ad586871 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -490,10 +490,8 @@ static CURLcode smtp_state_starttls_resp(struct connectdata *conn, else result = smtp_authenticate(conn); } - else { - state(conn, SMTP_UPGRADETLS); + else result = smtp_state_upgrade_tls(conn); - } return result; } @@ -505,9 +503,14 @@ static CURLcode smtp_state_upgrade_tls(struct connectdata *conn) result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &smtpc->ssldone); - if(smtpc->ssldone) { - smtp_to_smtps(conn); - result = smtp_state_ehlo(conn); + if(!result) { + if(smtpc->state != SMTP_UPGRADETLS) + state(conn, SMTP_UPGRADETLS); + + if(smtpc->ssldone) { + smtp_to_smtps(conn); + result = smtp_state_ehlo(conn); + } } return result;