Skip to content
Permalink
Browse files Browse the repository at this point in the history
smtp: use the upload buffer size for scratch buffer malloc
... not the read buffer size, as that can be set smaller and thus cause
a buffer overflow! CVE-2018-0500

Reported-by: Peter Wu
Bug: https://curl.haxx.se/docs/adv_2018-70a2.html
  • Loading branch information
bagder committed Jul 9, 2018
1 parent 0b4ccc9 commit ba1dbd7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/smtp.c
Expand Up @@ -1563,13 +1563,14 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
if(!scratch || data->set.crlf) {
oldscratch = scratch;

scratch = newscratch = malloc(2 * data->set.buffer_size);
scratch = newscratch = malloc(2 * UPLOAD_BUFSIZE);
if(!newscratch) {
failf(data, "Failed to alloc scratch buffer!");

return CURLE_OUT_OF_MEMORY;
}
}
DEBUGASSERT(UPLOAD_BUFSIZE >= nread);

/* Have we already sent part of the EOB? */
eob_sent = smtp->eob;
Expand Down

0 comments on commit ba1dbd7

Please sign in to comment.