]> granicus.if.org Git - curl/commitdiff
smtp.c: Reworked message encoding in smtp_state_authpasswd_resp()
authorSteve Holme <steve_holme@hotmail.com>
Thu, 31 May 2012 21:58:07 +0000 (22:58 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Thu, 31 May 2012 21:58:07 +0000 (22:58 +0100)
Rather than encoding the password message itself the
smtp_state_authpasswd_resp() function now delegates the work to the same
function that smtp_state_authlogin_resp() and smtp_authenticate() use
when constructing the encoded user name.

lib/smtp.c

index d2b02bd629ee18d8f6c089a4f1b667a7ebf24c45..f202fd6a76597d1f79310c14b9f5cd2edac0df75 100644 (file)
@@ -708,7 +708,6 @@ static CURLcode smtp_state_authpasswd_resp(struct connectdata *conn,
 {
   CURLcode result = CURLE_OK;
   struct SessionHandle *data = conn->data;
-  size_t plen;
   size_t len = 0;
   char *authpasswd = NULL;
 
@@ -719,22 +718,16 @@ static CURLcode smtp_state_authpasswd_resp(struct connectdata *conn,
     result = CURLE_LOGIN_DENIED;
   }
   else {
-    plen = strlen(conn->passwd);
+    result = smtp_auth_login(conn, conn->passwd, &authpasswd, &len);
 
-    if(!plen)
-      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "=");
-    else {
-      result = Curl_base64_encode(data, conn->passwd, plen, &authpasswd, &len);
-
-      if(!result) {
-        if(authpasswd) {
-          result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);
+    if(!result) {
+      if(authpasswd) {
+        result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);
 
-          if(!result)
-            state(conn, SMTP_AUTH);
-        }
-        Curl_safefree(authpasswd);
+        if(!result)
+          state(conn, SMTP_AUTH);
       }
+      Curl_safefree(authpasswd);
     }
   }