email: Added support for canceling CRAM-MD5 authentication
This commit is contained in:
26
lib/smtp.c
26
lib/smtp.c
@@ -944,6 +944,7 @@ static CURLcode smtp_state_auth_cram_resp(struct connectdata *conn,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SessionHandle *data = conn->data;
|
||||
char *chlg = NULL;
|
||||
char *chlg64 = NULL;
|
||||
char *rplyb64 = NULL;
|
||||
size_t len = 0;
|
||||
@@ -958,22 +959,31 @@ static CURLcode smtp_state_auth_cram_resp(struct connectdata *conn,
|
||||
/* Get the challenge message */
|
||||
smtp_get_message(data->state.buffer, &chlg64);
|
||||
|
||||
/* Create the response message */
|
||||
result = Curl_sasl_create_cram_md5_message(data, chlg64, conn->user,
|
||||
conn->passwd, &rplyb64, &len);
|
||||
/* Decode the challenge message */
|
||||
result = Curl_sasl_decode_cram_md5_message(chlg64, &chlg, &len);
|
||||
if(result) {
|
||||
/* Send the cancellation */
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "*");
|
||||
|
||||
/* Send the response */
|
||||
if(!result) {
|
||||
if(rplyb64) {
|
||||
if(!result)
|
||||
state(conn, SMTP_AUTH_CANCEL);
|
||||
}
|
||||
else {
|
||||
/* Create the response message */
|
||||
result = Curl_sasl_create_cram_md5_message(data, chlg64, conn->user,
|
||||
conn->passwd, &rplyb64, &len);
|
||||
if(!result && rplyb64) {
|
||||
/* Send the response */
|
||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", rplyb64);
|
||||
|
||||
if(!result)
|
||||
state(conn, SMTP_AUTH_FINAL);
|
||||
}
|
||||
|
||||
Curl_safefree(rplyb64);
|
||||
}
|
||||
|
||||
Curl_safefree(chlg);
|
||||
Curl_safefree(rplyb64);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user