summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-11-22 09:01:24 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-11-23 08:26:51 +0100
commitdcd6f810255785d52b89150e18460fb0899d4f7e (patch)
treec3cb7cdcb79dbf752edcd997934e44a2e9998397 /src
parent9944d6ba334f07b0b6199bdb5bb82091c88c16ed (diff)
downloadgnurl-dcd6f810255785d52b89150e18460fb0899d4f7e.tar.gz
gnurl-dcd6f810255785d52b89150e18460fb0899d4f7e.tar.bz2
gnurl-dcd6f810255785d52b89150e18460fb0899d4f7e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/tool_cb_dbg.c6
-rw-r--r--src/tool_cb_hdr.c2
-rw-r--r--src/tool_cb_prg.c4
-rw-r--r--src/tool_dirhie.c4
-rw-r--r--src/tool_getparam.c4
-rw-r--r--src/tool_operhlp.c4
-rw-r--r--src/tool_parsecfg.c14
-rw-r--r--src/tool_setopt.c22
-rw-r--r--src/tool_urlglob.c22
9 files changed, 40 insertions, 42 deletions
diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c
index a3e033977..bb8c2635b 100644
--- a/src/tool_cb_dbg.c
+++ b/src/tool_cb_dbg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -66,8 +66,8 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we don't care */
- snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
- now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
+ msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
+ now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
}
else
timebuf[0] = 0;
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index 7a7a836c4..84b0d9c87 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -274,7 +274,7 @@ static char *parse_filename(const char *ptr, size_t len)
char *tdir = curlx_getenv("CURL_TESTDIR");
if(tdir) {
char buffer[512]; /* suitably large */
- snprintf(buffer, sizeof(buffer), "%s/%s", tdir, copy);
+ msnprintf(buffer, sizeof(buffer), "%s/%s", tdir, copy);
Curl_safefree(copy);
copy = strdup(buffer); /* clone the buffer, we don't use the libcurl
aprintf() or similar since we want to use the
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index 3eb2c1255..15ff5b2fa 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -72,7 +72,7 @@ static void fly(struct ProgressData *bar, bool moved)
int pos;
int check = bar->width - 2;
- snprintf(buf, sizeof(buf), "%*s\r", bar->width-1, " ");
+ msnprintf(buf, sizeof(buf), "%*s\r", bar->width-1, " ");
memcpy(&buf[bar->bar], "-=O=-", 5);
pos = sinus[bar->tick%200] / (10000 / check);
@@ -166,7 +166,7 @@ int tool_progress_cb(void *clientp,
num = MAX_BARLENGTH;
memset(line, '#', num);
line[num] = '\0';
- snprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
+ msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
fprintf(bar->out, format, line, percent);
}
fflush(bar->out);
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index 24bbc4906..06b3c03e8 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -131,13 +131,13 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors)
if(tempdir2 != NULL) {
size_t dlen = strlen(dirbuildup);
if(dlen)
- snprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir);
+ msnprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir);
else {
if(outdup == tempdir)
/* the output string doesn't start with a separator */
strcpy(dirbuildup, tempdir);
else
- snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
+ msnprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
}
if((-1 == mkdir(dirbuildup, (mode_t)0000750)) && (errno != EEXIST)) {
show_dir_errno(errors, dirbuildup);
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 4e06cd61e..cd21f774c 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -1351,7 +1351,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
return PARAM_NO_MEM;
}
if(nlen > 0) { /* only append '=' if we have a name */
- snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
+ msnprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
size = outlen-1;
}
else {
@@ -1935,7 +1935,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
warnf(global,
"A specified range MUST include at least one dash (-). "
"Appending one for you!\n");
- snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
+ msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
Curl_safefree(config->range);
config->range = strdup(buffer);
if(!config->range)
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c
index 21b5ffe77..c3a826278 100644
--- a/src/tool_operhlp.c
+++ b/src/tool_operhlp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -176,7 +176,7 @@ CURLcode get_url_file_name(char **filename, const char *url)
char *tdir = curlx_getenv("CURL_TESTDIR");
if(tdir) {
char buffer[512]; /* suitably large */
- snprintf(buffer, sizeof(buffer), "%s/%s", tdir, *filename);
+ msnprintf(buffer, sizeof(buffer), "%s/%s", tdir, *filename);
Curl_safefree(*filename);
*filename = strdup(buffer); /* clone the buffer */
curl_free(tdir);
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index e57d76026..e36b06c23 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,8 +60,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
filename = CURLRC; /* sensible default */
if(home) {
if(strlen(home) < (sizeof(filebuffer) - strlen(CURLRC))) {
- snprintf(filebuffer, sizeof(filebuffer),
- "%s%s%s", home, DIR_CHAR, CURLRC);
+ msnprintf(filebuffer, sizeof(filebuffer),
+ "%s%s%s", home, DIR_CHAR, CURLRC);
#ifdef WIN32
/* Check if the file exists - if not, try CURLRC in the same
@@ -87,11 +87,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
/* If we have enough space, build the RC filename */
remaining = sizeof(filebuffer) - strlen(filebuffer);
if(strlen(CURLRC) < remaining - 1) {
- snprintf(lastdirchar, remaining,
- "%s%s", DIR_CHAR, CURLRC);
- /* Don't bother checking if it exists - we do
- * that later
- */
+ msnprintf(lastdirchar, remaining,
+ "%s%s", DIR_CHAR, CURLRC);
+ /* Don't bother checking if it exists - we do that later */
filename = filebuffer;
}
}
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index fb2cb66d3..cd28ad829 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -251,7 +251,7 @@ static char *c_escape(const char *str, size_t len)
e += 2;
}
else if(! isprint(c)) {
- snprintf(e, 5, "\\%03o", (unsigned)c);
+ msnprintf(e, 5, "\\%03o", (unsigned)c);
e += 4;
}
else
@@ -311,8 +311,8 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
char preamble[80]; /* should accommodate any symbol name */
long rest = lval; /* bits not handled yet */
const NameValue *nv = NULL;
- snprintf(preamble, sizeof(preamble),
- "curl_easy_setopt(hnd, %s, ", name);
+ msnprintf(preamble, sizeof(preamble),
+ "curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */
@@ -322,7 +322,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
if(!rest)
break; /* handled them all */
/* replace with all spaces for continuation line */
- snprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
+ msnprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
}
}
/* If any bits have no definition, output an explicit value.
@@ -354,8 +354,8 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
char preamble[80];
unsigned long rest = (unsigned long)lval;
const NameValueUnsigned *nv = NULL;
- snprintf(preamble, sizeof(preamble),
- "curl_easy_setopt(hnd, %s, ", name);
+ msnprintf(preamble, sizeof(preamble),
+ "curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */
@@ -365,7 +365,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
if(!rest)
break; /* handled them all */
/* replace with all spaces for continuation line */
- snprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
+ msnprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
}
}
/* If any bits have no definition, output an explicit value.
@@ -629,7 +629,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
}
}
- snprintf(buf, sizeof(buf), "%ldL", lval);
+ msnprintf(buf, sizeof(buf), "%ldL", lval);
value = buf;
ret = curl_easy_setopt(curl, tag, lval);
if(lval == defval)
@@ -666,8 +666,8 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
else {
/* Value is expected to be curl_off_t */
curl_off_t oval = va_arg(arg, curl_off_t);
- snprintf(buf, sizeof(buf),
- "(curl_off_t)%" CURL_FORMAT_CURL_OFF_T, oval);
+ msnprintf(buf, sizeof(buf),
+ "(curl_off_t)%" CURL_FORMAT_CURL_OFF_T, oval);
value = buf;
ret = curl_easy_setopt(curl, tag, oval);
diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c
index e4a5c33db..babae0416 100644
--- a/src/tool_urlglob.c
+++ b/src/tool_urlglob.c
@@ -462,9 +462,9 @@ CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
char text[512];
const char *t;
if(glob_expand->pos) {
- snprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
- glob_expand->error,
- glob_expand->pos, url, glob_expand->pos - 1, " ");
+ msnprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
+ glob_expand->error,
+ glob_expand->pos, url, glob_expand->pos - 1, " ");
t = text;
}
else
@@ -563,8 +563,8 @@ CURLcode glob_next_url(char **globbed, URLGlob *glob)
switch(pat->type) {
case UPTSet:
if(pat->content.Set.elements) {
- snprintf(buf, buflen, "%s",
- pat->content.Set.elements[pat->content.Set.ptr_s]);
+ msnprintf(buf, buflen, "%s",
+ pat->content.Set.elements[pat->content.Set.ptr_s]);
len = strlen(buf);
buf += len;
buflen -= len;
@@ -578,9 +578,9 @@ CURLcode glob_next_url(char **globbed, URLGlob *glob)
}
break;
case UPTNumRange:
- snprintf(buf, buflen, "%0*lu",
- pat->content.NumRange.padlength,
- pat->content.NumRange.ptr_n);
+ msnprintf(buf, buflen, "%0*lu",
+ pat->content.NumRange.padlength,
+ pat->content.NumRange.ptr_n);
len = strlen(buf);
buf += len;
buflen -= len;
@@ -653,9 +653,9 @@ CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
appendlen = 1;
break;
case UPTNumRange:
- snprintf(numbuf, sizeof(numbuf), "%0*lu",
- pat->content.NumRange.padlength,
- pat->content.NumRange.ptr_n);
+ msnprintf(numbuf, sizeof(numbuf), "%0*lu",
+ pat->content.NumRange.padlength,
+ pat->content.NumRange.ptr_n);
appendthis = numbuf;
appendlen = strlen(numbuf);
break;