mirror of https://github.com/moparisthebest/curl
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
This commit is contained in:
parent
12284e008b
commit
894f6ec730
13
lib/telnet.c
13
lib/telnet.c
|
@ -920,12 +920,17 @@ static void suboption(struct Curl_easy *data)
|
||||||
size_t tmplen = (strlen(v->data) + 1);
|
size_t tmplen = (strlen(v->data) + 1);
|
||||||
/* Add the variable only if it fits */
|
/* Add the variable only if it fits */
|
||||||
if(len + tmplen < (int)sizeof(temp)-6) {
|
if(len + tmplen < (int)sizeof(temp)-6) {
|
||||||
if(sscanf(v->data, "%127[^,],%127s", varname, varval) == 2) {
|
int rv;
|
||||||
msnprintf((char *)&temp[len], sizeof(temp) - len,
|
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,
|
"%c%s%c%s", CURL_NEW_ENV_VAR, varname,
|
||||||
CURL_NEW_ENV_VALUE, varval);
|
CURL_NEW_ENV_VALUE, varval);
|
||||||
len += tmplen;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msnprintf((char *)&temp[len], sizeof(temp) - len,
|
msnprintf((char *)&temp[len], sizeof(temp) - len,
|
||||||
|
|
Loading…
Reference in New Issue