Loading lib/imap.c +29 −20 Original line number Original line Diff line number Diff line Loading @@ -480,14 +480,7 @@ static CURLcode imap_state_capability(struct connectdata *conn) imapc->authmechs = 0; /* No known authentication mechanisms yet */ imapc->authmechs = 0; /* No known authentication mechanisms yet */ imapc->authused = 0; /* Clear the authentication mechanism used */ imapc->authused = 0; /* Clear the authentication mechanism used */ imapc->tls_supported = FALSE; /* Clear the TLS capability */ /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Send the CAPABILITY command */ /* Send the CAPABILITY command */ result = imap_sendf(conn, "CAPABILITY"); result = imap_sendf(conn, "CAPABILITY"); Loading @@ -502,11 +495,19 @@ static CURLcode imap_state_capability(struct connectdata *conn) static CURLcode imap_state_login(struct connectdata *conn) static CURLcode imap_state_login(struct connectdata *conn) { { CURLcode result; CURLcode result = CURLE_OK; struct FTP *imap = conn->data->state.proto.imap; struct FTP *imap = conn->data->state.proto.imap; char *user = imap_atom(imap->user); char *user = imap_atom(imap->user); char *passwd = imap_atom(imap->passwd); char *passwd = imap_atom(imap->passwd); /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Send USER and password */ /* Send USER and password */ result = imap_sendf(conn, "LOGIN %s %s", user ? user : "", result = imap_sendf(conn, "LOGIN %s %s", user ? user : "", passwd ? passwd : ""); passwd ? passwd : ""); Loading @@ -532,6 +533,14 @@ static CURLcode imap_authenticate(struct connectdata *conn) imapstate state1 = IMAP_STOP; imapstate state1 = IMAP_STOP; imapstate state2 = IMAP_STOP; imapstate state2 = IMAP_STOP; /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Calculate the supported authentication mechanism by decreasing order of /* Calculate the supported authentication mechanism by decreasing order of security */ security */ #ifndef CURL_DISABLE_CRYPTO_AUTH #ifndef CURL_DISABLE_CRYPTO_AUTH Loading Loading @@ -644,12 +653,6 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn, return CURLE_FTP_WEIRD_SERVER_REPLY; return CURLE_FTP_WEIRD_SERVER_REPLY; } } if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) { /* We don't have a SSL/TLS connection yet, but SSL is requested. Switch to TLS connection now */ result = imap_state_starttls(conn); } else result = imap_state_capability(conn); result = imap_state_capability(conn); return result; return result; Loading @@ -671,7 +674,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn, result = CURLE_USE_SSL_FAILED; result = CURLE_USE_SSL_FAILED; } } else else result = imap_state_capability(conn); result = imap_authenticate(conn); } } else else result = imap_state_upgrade_tls(conn); result = imap_state_upgrade_tls(conn); Loading Loading @@ -705,13 +708,19 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn, imapstate instate) imapstate instate) { { CURLcode result = CURLE_OK; CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; (void)instate; /* no use for this yet */ (void)instate; /* no use for this yet */ if(imapcode == 'O') if(imapcode != 'O') result = imap_authenticate(conn); else result = imap_state_login(conn); result = imap_state_login(conn); else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) { /* We don't have a SSL/TLS connection yet, but SSL is requested. Switch to TLS connection now */ result = imap_state_starttls(conn); } else result = imap_authenticate(conn); return result; return result; } } Loading Loading
lib/imap.c +29 −20 Original line number Original line Diff line number Diff line Loading @@ -480,14 +480,7 @@ static CURLcode imap_state_capability(struct connectdata *conn) imapc->authmechs = 0; /* No known authentication mechanisms yet */ imapc->authmechs = 0; /* No known authentication mechanisms yet */ imapc->authused = 0; /* Clear the authentication mechanism used */ imapc->authused = 0; /* Clear the authentication mechanism used */ imapc->tls_supported = FALSE; /* Clear the TLS capability */ /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Send the CAPABILITY command */ /* Send the CAPABILITY command */ result = imap_sendf(conn, "CAPABILITY"); result = imap_sendf(conn, "CAPABILITY"); Loading @@ -502,11 +495,19 @@ static CURLcode imap_state_capability(struct connectdata *conn) static CURLcode imap_state_login(struct connectdata *conn) static CURLcode imap_state_login(struct connectdata *conn) { { CURLcode result; CURLcode result = CURLE_OK; struct FTP *imap = conn->data->state.proto.imap; struct FTP *imap = conn->data->state.proto.imap; char *user = imap_atom(imap->user); char *user = imap_atom(imap->user); char *passwd = imap_atom(imap->passwd); char *passwd = imap_atom(imap->passwd); /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Send USER and password */ /* Send USER and password */ result = imap_sendf(conn, "LOGIN %s %s", user ? user : "", result = imap_sendf(conn, "LOGIN %s %s", user ? user : "", passwd ? passwd : ""); passwd ? passwd : ""); Loading @@ -532,6 +533,14 @@ static CURLcode imap_authenticate(struct connectdata *conn) imapstate state1 = IMAP_STOP; imapstate state1 = IMAP_STOP; imapstate state2 = IMAP_STOP; imapstate state2 = IMAP_STOP; /* Check we have a username and password to authenticate with and end the connect phase if we don't */ if(!conn->bits.user_passwd) { state(conn, IMAP_STOP); return result; } /* Calculate the supported authentication mechanism by decreasing order of /* Calculate the supported authentication mechanism by decreasing order of security */ security */ #ifndef CURL_DISABLE_CRYPTO_AUTH #ifndef CURL_DISABLE_CRYPTO_AUTH Loading Loading @@ -644,12 +653,6 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn, return CURLE_FTP_WEIRD_SERVER_REPLY; return CURLE_FTP_WEIRD_SERVER_REPLY; } } if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) { /* We don't have a SSL/TLS connection yet, but SSL is requested. Switch to TLS connection now */ result = imap_state_starttls(conn); } else result = imap_state_capability(conn); result = imap_state_capability(conn); return result; return result; Loading @@ -671,7 +674,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn, result = CURLE_USE_SSL_FAILED; result = CURLE_USE_SSL_FAILED; } } else else result = imap_state_capability(conn); result = imap_authenticate(conn); } } else else result = imap_state_upgrade_tls(conn); result = imap_state_upgrade_tls(conn); Loading Loading @@ -705,13 +708,19 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn, imapstate instate) imapstate instate) { { CURLcode result = CURLE_OK; CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; (void)instate; /* no use for this yet */ (void)instate; /* no use for this yet */ if(imapcode == 'O') if(imapcode != 'O') result = imap_authenticate(conn); else result = imap_state_login(conn); result = imap_state_login(conn); else if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) { /* We don't have a SSL/TLS connection yet, but SSL is requested. Switch to TLS connection now */ result = imap_state_starttls(conn); } else result = imap_authenticate(conn); return result; return result; } } Loading