aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-11-30 14:24:35 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-11-30 14:24:35 +0000
commit9afd97022eb3ff586b13d33a7d85ce502d06e93c (patch)
tree41ff6752332cbb944a060857711e9dfd0484656d /lib/transfer.c
parent5409f32984f17c25e84a52fe86f890c73133d531 (diff)
smtp: Fixed dot stuffing being performed when no new data read
Whilst I had moved the dot stuffing code from being performed before CRLF conversion takes place to after it, in commit 4bd860a001, I had moved it outside the 'when something read' block of code when meant it could perform the dot stuffing twice on partial send if nread happened to contain the right values. It also meant the function could potentially read past the end of buffer. This was highlighted by the following warning: warning: `nread' might be used uninitialized in this function
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 2324f2bdd..84a7e2be4 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -935,6 +935,7 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
else
data->state.scratch[si] = data->req.upload_fromhere[i];
}
+
if(si != nread) {
/* only perform the special operation if we really did replace
anything */
@@ -947,20 +948,20 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
data->req.upload_present = nread;
}
}
+
+#ifndef CURL_DISABLE_SMTP
+ if(conn->handler->protocol & PROTO_FAMILY_SMTP) {
+ result = Curl_smtp_escape_eob(conn, nread);
+ if(result)
+ return result;
+ }
+#endif /* CURL_DISABLE_SMTP */
} /* if 0 == data->req.upload_present */
else {
/* We have a partial buffer left from a previous "round". Use
that instead of reading more data */
}
-#ifndef CURL_DISABLE_SMTP
- if(conn->handler->protocol & PROTO_FAMILY_SMTP) {
- result = Curl_smtp_escape_eob(conn, nread);
- if(result)
- return result;
- }
-#endif /* CURL_DISABLE_SMTP */
-
/* write to socket (send away data) */
result = Curl_write(conn,
conn->writesockfd, /* socket to send to */