Blame SOURCES/0006-curl-7.76.1-CVE-2021-22925.patch

d889a8
From 3dbac7fb8b39a4f9aa871401d9d2790f0583ba01 Mon Sep 17 00:00:00 2001
d889a8
From: Daniel Stenberg <daniel@haxx.se>
d889a8
Date: Sat, 12 Jun 2021 18:25:15 +0200
d889a8
Subject: [PATCH] telnet: fix option parser to not send uninitialized contents
d889a8
d889a8
CVE-2021-22925
d889a8
d889a8
Reported-by: Red Hat Product Security
d889a8
Bug: https://curl.se/docs/CVE-2021-22925.html
d889a8
d889a8
Upstream-commit: 894f6ec730597eb243618d33cc84d71add8d6a8a
d889a8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d889a8
---
d889a8
 lib/telnet.c | 17 +++++++++++------
d889a8
 1 file changed, 11 insertions(+), 6 deletions(-)
d889a8
d889a8
diff --git a/lib/telnet.c b/lib/telnet.c
d889a8
index fdd137f..567c22c 100644
d889a8
--- a/lib/telnet.c
d889a8
+++ b/lib/telnet.c
d889a8
@@ -922,12 +922,17 @@ static void suboption(struct Curl_easy *data)
d889a8
         size_t tmplen = (strlen(v->data) + 1);
d889a8
         /* Add the variable only if it fits */
d889a8
         if(len + tmplen < (int)sizeof(temp)-6) {
d889a8
-          if(sscanf(v->data, "%127[^,],%127s", varname, varval) == 2) {
d889a8
-            msnprintf((char *)&temp[len], sizeof(temp) - len,
d889a8
-                      "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
d889a8
-                      CURL_NEW_ENV_VALUE, varval);
d889a8
-            len += tmplen;
d889a8
-          }
d889a8
+          int rv;
d889a8
+          char sep[2] = "";
d889a8
+          varval[0] = 0;
d889a8
+          rv = sscanf(v->data, "%127[^,]%1[,]%127s", varname, sep, varval);
d889a8
+          if(rv == 1)
d889a8
+            len += msnprintf((char *)&temp[len], sizeof(temp) - len,
d889a8
+                             "%c%s", CURL_NEW_ENV_VAR, varname);
d889a8
+          else if(rv >= 2)
d889a8
+            len += msnprintf((char *)&temp[len], sizeof(temp) - len,
d889a8
+                             "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
d889a8
+                             CURL_NEW_ENV_VALUE, varval);
d889a8
         }
d889a8
       }
d889a8
       msnprintf((char *)&temp[len], sizeof(temp) - len,
d889a8
-- 
d889a8
2.31.1
d889a8