]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smtp: use the upload buffer size for scratch buffer malloc
authorDaniel Stenberg <daniel@haxx.se>
Wed, 13 Jun 2018 10:24:40 +0000 (12:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Jul 2018 06:15:48 +0000 (08:15 +0200)
... 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

lib/smtp.c

index e6872badb8893ff95d8a78320b51f506597c93b4..ecf10a41ac3746087a201e3a2cadeb4dd6dfacef 100644 (file)
@@ -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;