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.
else
result = imap_state_capability(conn);
}
- else {
- state(conn, IMAP_UPGRADETLS);
+ else
result = imap_state_upgrade_tls(conn);
- }
return result;
}
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;