]> granicus.if.org Git - curl/commitdiff
smtp: Fixed an issue with the multi-interface always sending postdata
authorSteve Holme <steve_holme@hotmail.com>
Tue, 22 May 2012 21:08:25 +0000 (22:08 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Tue, 22 May 2012 21:08:25 +0000 (22:08 +0100)
Due to the result code being reset to CURLE_OK when smtp_dophase_done()
was called, postdata would incorrectly be sent to the server when the
MAIL FROM or RCPT command was rejected.

As such, libcurl would return the wrong result code from performing the
operation and additionally set CURLINFO_RESPONSE_CODE to be that
returned by the postdata command.

Bug: http://curl.haxx.se/mail/lib-2012-05/0108.html
Reported by: Gokhan Sengun

lib/smtp.c

index aa4f6bd396b15bfcba7ed94aa997759559906d73..5b2d9d38d5c3e171e9f60d0c2b40fb2818ecef86 100644 (file)
@@ -1840,14 +1840,15 @@ static CURLcode smtp_dophase_done(struct connectdata *conn, bool connected)
 /* called from multi.c while DOing */
 static CURLcode smtp_doing(struct connectdata *conn, bool *dophase_done)
 {
-  CURLcode result;
-  result = smtp_multi_statemach(conn, dophase_done);
-
-  if(*dophase_done) {
-    result = smtp_dophase_done(conn, FALSE /* not connected */);
+  CURLcode result = smtp_multi_statemach(conn, dophase_done);
 
+  if(result)
+    DEBUGF(infof(conn->data, "DO phase failed\n"));
+  else
     DEBUGF(infof(conn->data, "DO phase is complete\n"));
-  }
+
+  if(*dophase_done)
+    smtp_dophase_done(conn, FALSE /* not connected */);
 
   return result;
 }