From 43400b40862ea274d501f6692beb28a72ec7f776 Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Wed, 30 Oct 2013 20:56:38 +0000 Subject: email: Post graceful SASL authentication cancellation tidy up --- lib/imap.c | 85 ++++++++++++++++++++++++++------------------------------------ 1 file changed, 35 insertions(+), 50 deletions(-) (limited to 'lib/imap.c') diff --git a/lib/imap.c b/lib/imap.c index c11e43bd6..60e7489df 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1007,20 +1007,17 @@ static CURLcode imap_state_auth_plain_resp(struct connectdata *conn, /* Create the authorisation message */ result = Curl_sasl_create_plain_message(data, conn->user, conn->passwd, &plainauth, &len); + if(!result && plainauth) { + /* Send the message */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", plainauth); - /* Send the message */ - if(!result) { - if(plainauth) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", plainauth); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - - Curl_safefree(plainauth); + if(!result) + state(conn, IMAP_AUTHENTICATE_FINAL); } } + Curl_safefree(plainauth); + return result; } @@ -1044,20 +1041,17 @@ static CURLcode imap_state_auth_login_resp(struct connectdata *conn, /* Create the user message */ result = Curl_sasl_create_login_message(data, conn->user, &authuser, &len); + if(!result && authuser) { + /* Send the user */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authuser); - /* Send the user */ - if(!result) { - if(authuser) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authuser); - - if(!result) - state(conn, IMAP_AUTHENTICATE_LOGIN_PASSWD); - } - - Curl_safefree(authuser); + if(!result) + state(conn, IMAP_AUTHENTICATE_LOGIN_PASSWD); } } + Curl_safefree(authuser); + return result; } @@ -1081,20 +1075,17 @@ static CURLcode imap_state_auth_login_password_resp(struct connectdata *conn, /* Create the password message */ result = Curl_sasl_create_login_message(data, conn->passwd, &authpasswd, &len); + if(!result && authpasswd) { + /* Send the password */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authpasswd); - /* Send the password */ - if(!result) { - if(authpasswd) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", authpasswd); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - - Curl_safefree(authpasswd); + if(!result) + state(conn, IMAP_AUTHENTICATE_FINAL); } } + Curl_safefree(authpasswd); + return result; } @@ -1252,20 +1243,17 @@ static CURLcode imap_state_auth_ntlm_resp(struct connectdata *conn, result = Curl_sasl_create_ntlm_type1_message(conn->user, conn->passwd, &conn->ntlm, &type1msg, &len); + if(!result && type1msg) { + /* Send the message */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type1msg); - /* Send the message */ - if(!result) { - if(type1msg) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", type1msg); - - if(!result) - state(conn, IMAP_AUTHENTICATE_NTLM_TYPE2MSG); - } - - Curl_safefree(type1msg); + if(!result) + state(conn, IMAP_AUTHENTICATE_NTLM_TYPE2MSG); } } + Curl_safefree(type1msg); + return result; } @@ -1341,20 +1329,17 @@ static CURLcode imap_state_auth_xoauth2_resp(struct connectdata *conn, result = Curl_sasl_create_xoauth2_message(conn->data, conn->user, conn->xoauth2_bearer, &xoauth, &len); + if(!result && xoauth) { + /* Send the message */ + result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", xoauth); - /* Send the message */ - if(!result) { - if(xoauth) { - result = Curl_pp_sendf(&conn->proto.imapc.pp, "%s", xoauth); - - if(!result) - state(conn, IMAP_AUTHENTICATE_FINAL); - } - - Curl_safefree(xoauth); + if(!result) + state(conn, IMAP_AUTHENTICATE_FINAL); } } + Curl_safefree(xoauth); + return result; } -- cgit v1.2.3