From aa689a0f225e4e75b1bf1c1df0e32db122ab21d1 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 26 May 2021 10:21:27 +0200 Subject: [PATCH] Resolves: CVE-2021-22898 - fix TELNET stack contents disclosure --- 0002-curl-7.76.1-CVE-2021-22898.patch | 31 +++++++++++++++++++++++++++ curl.spec | 9 +++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 0002-curl-7.76.1-CVE-2021-22898.patch diff --git a/0002-curl-7.76.1-CVE-2021-22898.patch b/0002-curl-7.76.1-CVE-2021-22898.patch new file mode 100644 index 0000000..691850b --- /dev/null +++ b/0002-curl-7.76.1-CVE-2021-22898.patch @@ -0,0 +1,31 @@ +From 886f7458bbf005299f3f8224103d1903cd6fa7a4 Mon Sep 17 00:00:00 2001 +From: Harry Sintonen +Date: Fri, 7 May 2021 13:09:57 +0200 +Subject: [PATCH] telnet: check sscanf() for correct number of matches + +CVE-2021-22898 + +Bug: https://curl.se/docs/CVE-2021-22898.html + +Upstream-commit: 39ce47f219b09c380b81f89fe54ac586c8db6bde +Signed-off-by: Kamil Dudka +--- + lib/telnet.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/telnet.c b/lib/telnet.c +index f96a4cb..4551435 100644 +--- a/lib/telnet.c ++++ b/lib/telnet.c +@@ -921,7 +921,7 @@ static void suboption(struct Curl_easy *data) + size_t tmplen = (strlen(v->data) + 1); + /* Add the variable only if it fits */ + if(len + tmplen < (int)sizeof(temp)-6) { +- if(sscanf(v->data, "%127[^,],%127s", varname, varval)) { ++ if(sscanf(v->data, "%127[^,],%127s", varname, varval) == 2) { + msnprintf((char *)&temp[len], sizeof(temp) - len, + "%c%s%c%s", CURL_NEW_ENV_VAR, varname, + CURL_NEW_ENV_VALUE, varval); +-- +2.31.1 + diff --git a/curl.spec b/curl.spec index 628c0f8..9459f4a 100644 --- a/curl.spec +++ b/curl.spec @@ -1,13 +1,16 @@ Summary: A utility for getting files from remote servers (FTP, HTTP, and others) Name: curl Version: 7.76.1 -Release: 2%{?dist} +Release: 3%{?dist} License: MIT Source: https://curl.se/download/%{name}-%{version}.tar.xz # http2: fix resource leaks detected by Coverity Patch1: 0001-curl-7.76.1-resource-leaks.patch +# fix TELNET stack contents disclosure (CVE-2021-22898) +Patch2: 0002-curl-7.76.1-CVE-2021-22898.patch + # patch making libcurl multilib ready Patch101: 0101-curl-7.32.0-multilib.patch @@ -184,6 +187,7 @@ be installed. # upstream patches %patch1 -p1 +%patch2 -p1 # Fedora patches %patch101 -p1 @@ -364,6 +368,9 @@ rm -f ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la %{_libdir}/libcurl.so.4.[0-9].[0-9].minimal %changelog +* Wed May 26 2021 Kamil Dudka - 7.76.1-3 +- fix TELNET stack contents disclosure (CVE-2021-22898) + * Mon May 03 2021 Kamil Dudka - 7.76.1-2 - http2: fix resource leaks detected by Coverity