summaryrefslogtreecommitdiff
path: root/lib/telnet.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-06-12 18:25:15 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-07-20 09:36:06 +0200
commit894f6ec730597eb243618d33cc84d71add8d6a8a (patch)
tree57d1530816af5050e535003ae39c117cdf22e684 /lib/telnet.c
parent12284e008bad5156b67d0ac253331a96d77201d1 (diff)
downloadcurl-894f6ec730597eb243618d33cc84d71add8d6a8a.tar.gz
telnet: fix option parser to not send uninitialized contents
CVS-2021-22925 Reported-by: Red Hat Product Security Bug: https://curl.se/docs/CVE-2021-22925.html
Diffstat (limited to 'lib/telnet.c')
-rw-r--r--lib/telnet.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/telnet.c b/lib/telnet.c
index 1d3024ec4..a81bb81c3 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -920,12 +920,17 @@ 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) == 2) {
- msnprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
- CURL_NEW_ENV_VALUE, varval);
- len += tmplen;
- }
+ int rv;
+ char sep[2] = "";
+ varval[0] = 0;
+ rv = sscanf(v->data, "%127[^,]%1[,]%127s", varname, sep, varval);
+ if(rv == 1)
+ len += msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%s", CURL_NEW_ENV_VAR, varname);
+ else if(rv >= 2)
+ len += msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
+ CURL_NEW_ENV_VALUE, varval);
}
}
msnprintf((char *)&temp[len], sizeof(temp) - len,