From c79dff9b8baa2cb7ca51060f7303d91092fb7d0a Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 11 Jul 2018 17:51:58 +0200 Subject: [PATCH] Resolves: CVE-2018-0500 - fix heap buffer overflow in SMTP send --- 0005-curl-7.59.0-CVE-2018-0500.patch | 40 ++++++++++++++++++++++++++++ curl.spec | 9 ++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0005-curl-7.59.0-CVE-2018-0500.patch diff --git a/0005-curl-7.59.0-CVE-2018-0500.patch b/0005-curl-7.59.0-CVE-2018-0500.patch new file mode 100644 index 0000000..221c05f --- /dev/null +++ b/0005-curl-7.59.0-CVE-2018-0500.patch @@ -0,0 +1,40 @@ +From 7a5d2b67b8bee753735d4b03f66c4054d9b812f9 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Wed, 13 Jun 2018 12:24:40 +0200 +Subject: [PATCH] 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 + +Upstream-commit: ba1dbd78e5f1ed67c1b8d37ac89d90e5e330b628 +Signed-off-by: Kamil Dudka +--- + lib/smtp.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/smtp.c b/lib/smtp.c +index 3f3b45a..400ad54 100644 +--- a/lib/smtp.c ++++ b/lib/smtp.c +@@ -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; +-- +2.14.4 + diff --git a/curl.spec b/curl.spec index abf84a4..008dd3f 100644 --- a/curl.spec +++ b/curl.spec @@ -1,7 +1,7 @@ Summary: A utility for getting files from remote servers (FTP, HTTP, and others) Name: curl Version: 7.59.0 -Release: 4%{?dist} +Release: 5%{?dist} License: MIT Source: https://curl.haxx.se/download/%{name}-%{version}.tar.xz @@ -17,6 +17,9 @@ Patch3: 0003-curl-7.59.0-CVE-2018-1000300.patch # http2: handle GOAWAY properly (#1585797) Patch4: 0004-curl-7.59.0-http2-GOAWAY.patch +# fix heap buffer overflow in SMTP send (CVE-2018-0500) +Patch5: 0005-curl-7.59.0-CVE-2018-0500.patch + # patch making libcurl multilib ready Patch101: 0101-curl-7.32.0-multilib.patch @@ -167,6 +170,7 @@ be installed. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 # Fedora patches %patch101 -p1 @@ -312,6 +316,9 @@ rm -f ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la %{_libdir}/libcurl.so.4.[0-9].[0-9].minimal %changelog +* Wed Jul 11 2018 Kamil Dudka - 7.59.0-5 +- fix heap buffer overflow in SMTP send (CVE-2018-0500) + * Tue Jun 05 2018 Kamil Dudka - 7.59.0-4 - http2: handle GOAWAY properly (#1585797)