aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-02-12 22:23:46 +0000
committerDaniel Stenberg <daniel@haxx.se>2010-02-12 22:23:46 +0000
commit975814368a8b567a369ab5174c42dbae5b28b86e (patch)
treee01a31b4d49a91dd7c8099e3688c5024dee8aaf7 /lib
parentdc6adb54fbf1c3678e71f0ce281ba37e0d7e2b83 (diff)
- Jack Zhang reported a problem with SMTP: we wrongly used multiple addresses
in the same RCPT TO line, when they should be sent in separate single commands. I updated test case 802 to verify this. - I also fixed a bad use of my_setopt_str() of CURLOPT_MAIL_RCPT in the curl tool which made it try to output it as string for the --libcurl feature which could lead to crashes.
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c41
-rw-r--r--lib/smtp.h3
2 files changed, 25 insertions, 19 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 1e5304723..7e3d4670c 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -344,26 +344,17 @@ static CURLcode smtp_state_mail_resp(struct connectdata *conn,
state(conn, SMTP_STOP);
}
else {
- /* send RCPT TO */
- struct curl_slist *rcpt;
- char *buffer = NULL;
-
- for(rcpt = data->set.mail_rcpt; rcpt; rcpt=rcpt->next) {
- char *add = aprintf("%s%s%s", buffer?buffer:"", buffer?", ":"",
- rcpt->data);
- if(!add) {
- free(buffer);
- return CURLE_OUT_OF_MEMORY;
- }
- buffer = add;
- }
+ struct smtp_conn *smtpc = &conn->proto.smtpc;
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s", buffer);
-
- free(buffer);
+ /* send RCPT TO */
+ smtpc->rcpt = data->set.mail_rcpt;
- if(result)
- return result;
+ if(smtpc->rcpt) {
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
+ smtpc->rcpt->data);
+ if(result)
+ return result;
+ }
state(conn, SMTP_RCPT);
}
@@ -385,6 +376,20 @@ static CURLcode smtp_state_rcpt_resp(struct connectdata *conn,
state(conn, SMTP_STOP);
}
else {
+ struct smtp_conn *smtpc = &conn->proto.smtpc;
+
+ /* one RCPT is done, but if there's one more to send go on */
+ smtpc->rcpt = smtpc->rcpt->next;
+ if(smtpc->rcpt) {
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
+ smtpc->rcpt->data);
+ if(result)
+ return result;
+
+ state(conn, SMTP_RCPT);
+ return CURLE_OK;
+ }
+
/* send DATA */
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "DATA", "");
if(result)
diff --git a/lib/smtp.h b/lib/smtp.h
index a1115e23a..cc581d4d5 100644
--- a/lib/smtp.h
+++ b/lib/smtp.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -49,6 +49,7 @@ struct smtp_conn {
int eob; /* number of bytes of the EOB (End Of Body) that has been
received thus far */
smtpstate state; /* always use smtp.c:state() to change state! */
+ struct curl_slist *rcpt;
};
extern const struct Curl_handler Curl_handler_smtp;