Skip to content

Commit ba1dbd7

Browse files
committed
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
1 parent 0b4ccc9 commit ba1dbd7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: lib/smtp.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1563,13 +1563,14 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
15631563
if(!scratch || data->set.crlf) {
15641564
oldscratch = scratch;
15651565

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

15701570
return CURLE_OUT_OF_MEMORY;
15711571
}
15721572
}
1573+
DEBUGASSERT(UPLOAD_BUFSIZE >= nread);
15731574

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

0 commit comments

Comments
 (0)