mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
smtp.c: Fixed an issue with the EOB checking
Curl_smtp_escape_eob() would leave off final CRLFs from emails ending in multiple blank lines additionally leaving the smtpc->eob variable with the character count in, which would cause problems for additional emails when sent through multiple calls to curl_easy_perform() after a CURLOPT_CONNECT_ONLY.
This commit is contained in:
parent
4cf742f34f
commit
3d98aed5b3
16
lib/smtp.c
16
lib/smtp.c
@ -1679,12 +1679,15 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
|
|||||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
|
||||||
if(data->state.scratch == NULL)
|
/* Do we need to allocate the scatch buffer? */
|
||||||
|
if(!data->state.scratch) {
|
||||||
data->state.scratch = malloc(2 * BUFSIZE);
|
data->state.scratch = malloc(2 * BUFSIZE);
|
||||||
if(data->state.scratch == NULL) {
|
|
||||||
|
if(!data->state.scratch) {
|
||||||
failf (data, "Failed to alloc scratch buffer!");
|
failf (data, "Failed to alloc scratch buffer!");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This loop can be improved by some kind of Boyer-Moore style of
|
/* This loop can be improved by some kind of Boyer-Moore style of
|
||||||
approach but that is saved for later... */
|
approach but that is saved for later... */
|
||||||
@ -1692,7 +1695,7 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
|
|||||||
if(SMTP_EOB[smtpc->eob] == data->req.upload_fromhere[i])
|
if(SMTP_EOB[smtpc->eob] == data->req.upload_fromhere[i])
|
||||||
smtpc->eob++;
|
smtpc->eob++;
|
||||||
else if(smtpc->eob) {
|
else if(smtpc->eob) {
|
||||||
/* previously a substring matched, output that first */
|
/* A previous substring matched so output that first */
|
||||||
memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob);
|
memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob);
|
||||||
si += smtpc->eob;
|
si += smtpc->eob;
|
||||||
|
|
||||||
@ -1718,6 +1721,13 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, ssize_t nread)
|
|||||||
data->state.scratch[si++] = data->req.upload_fromhere[i];
|
data->state.scratch[si++] = data->req.upload_fromhere[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(smtpc->eob) {
|
||||||
|
/* A substring matched before processing ended so output that now */
|
||||||
|
memcpy(&data->state.scratch[si], SMTP_EOB, smtpc->eob);
|
||||||
|
si += smtpc->eob;
|
||||||
|
smtpc->eob = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(si != nread) {
|
if(si != nread) {
|
||||||
/* only use the new buffer if we replaced something */
|
/* only use the new buffer if we replaced something */
|
||||||
nread = si;
|
nread = si;
|
||||||
|
Loading…
Reference in New Issue
Block a user