diff options
author | Marc Hoersken <info@marc-hoersken.de> | 2014-04-19 15:23:04 +0200 |
---|---|---|
committer | Marc Hoersken <info@marc-hoersken.de> | 2014-04-19 15:23:04 +0200 |
commit | 662fc625177208896ce707c5e39ea58d9936cb84 (patch) | |
tree | 924c5ab6b0287cef3860791cfe7c52479a5163f2 /lib/telnet.c | |
parent | f9ffbfce909fe68b476f2fcd046508a45066b35d (diff) | |
download | curl-662fc625177208896ce707c5e39ea58d9936cb84.tar.gz |
telnet.c: check sscanf results before passing them to snprintf
Diffstat (limited to 'lib/telnet.c')
-rw-r--r-- | lib/telnet.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/telnet.c b/lib/telnet.c index f8946f494..1f03a00fc 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -932,8 +932,8 @@ static void suboption(struct connectdata *conn) size_t len; size_t tmplen; int err; - char varname[128]; - char varval[128]; + char varname[128] = ""; + char varval[128] = ""; struct SessionHandle *data = conn->data; struct TELNET *tn = (struct TELNET *)data->req.protop; @@ -973,11 +973,12 @@ static void suboption(struct connectdata *conn) tmplen = (strlen(v->data) + 1); /* Add the variable only if it fits */ if(len + tmplen < (int)sizeof(temp)-6) { - sscanf(v->data, "%127[^,],%127s", varname, varval); - snprintf((char *)&temp[len], sizeof(temp) - len, - "%c%s%c%s", CURL_NEW_ENV_VAR, varname, - CURL_NEW_ENV_VALUE, varval); - len += tmplen; + if(sscanf(v->data, "%127[^,],%127s", varname, varval)) { + snprintf((char *)&temp[len], sizeof(temp) - len, + "%c%s%c%s", CURL_NEW_ENV_VAR, varname, + CURL_NEW_ENV_VALUE, varval); + len += tmplen; + } } } snprintf((char *)&temp[len], sizeof(temp) - len, |