snprintf: renamed and we now only use msnprintf()

The function does not return the same value as snprintf() normally does,
so readers may be mislead into thinking the code works differently than
it actually does. A different function name makes this easier to detect.

Reported-by: Tomas Hoger
Assisted-by: Daniel Gustafsson
Fixes #3296
Closes #3297
This commit is contained in:
Daniel Stenberg 2018-11-22 09:01:24 +01:00
parent 9944d6ba33
commit dcd6f81025
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
92 changed files with 632 additions and 631 deletions

View file

@ -203,7 +203,7 @@ void Curl_strcpy_url(char *output, const char *url, bool relative)
/* FALLTHROUGH */
default:
if(urlchar_needs_escaping(*iptr)) {
snprintf(optr, 4, "%%%02x", *iptr);
msnprintf(optr, 4, "%%%02x", *iptr);
optr += 3;
}
else
@ -531,7 +531,7 @@ static CURLUcode parse_port(struct Curl_URL *u, char *hostname)
*portptr++ = '\0'; /* cut off the name there */
*rest = 0;
/* generate a new to get rid of leading zeroes etc */
snprintf(portbuf, sizeof(portbuf), "%ld", port);
msnprintf(portbuf, sizeof(portbuf), "%ld", port);
u->portnum = port;
u->port = strdup(portbuf);
if(!u->port)
@ -964,7 +964,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
const struct Curl_handler *h =
Curl_builtin_scheme(u->scheme);
if(h) {
snprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
ptr = portbuf;
}
}
@ -1023,7 +1023,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
/* there's no stored port number, but asked to deliver
a default one for the scheme */
if(h) {
snprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
port = portbuf;
}
}
@ -1287,7 +1287,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
o++;
}
else {
snprintf(o, 4, "%%%02x", *i);
msnprintf(o, 4, "%%%02x", *i);
o += 3;
}
}