aboutsummaryrefslogtreecommitdiff
path: root/src/tool_operhlp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-03-06 13:27:51 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-03-07 11:08:05 +0100
commit7f963a19ecbceef5d7e95e677ccc089d04ef987f (patch)
tree459db8c1b5d5243e9b5e3ebfd3e8974131d321de /src/tool_operhlp.c
parent9ceee69ff7d6139de759a4f25051e0d661e0c2b0 (diff)
checksrc: ban unsafe functions
The list of unsafe functions currently consists of sprintf, vsprintf, strcat, strncat and gets. Subsequently, some existing code needed updating to avoid warnings on this.
Diffstat (limited to 'src/tool_operhlp.c')
-rw-r--r--src/tool_operhlp.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c
index 631488727..d3c1a88a9 100644
--- a/src/tool_operhlp.c
+++ b/src/tool_operhlp.c
@@ -123,22 +123,20 @@ char *add_file_name_to_url(CURL *curl, char *url, const char *filename)
/* URL encode the file name */
encfile = curl_easy_escape(curl, filep, 0 /* use strlen */);
if(encfile) {
- char *urlbuffer = malloc(strlen(url) + strlen(encfile) + 3);
- if(!urlbuffer) {
- curl_free(encfile);
- Curl_safefree(url);
- return NULL;
- }
+ char *urlbuffer;
if(ptr)
/* there is a trailing slash on the URL */
- sprintf(urlbuffer, "%s%s", url, encfile);
+ urlbuffer = aprintf("%s%s", url, encfile);
else
/* there is no trailing slash on the URL */
- sprintf(urlbuffer, "%s/%s", url, encfile);
+ urlbuffer = aprintf("%s/%s", url, encfile);
curl_free(encfile);
Curl_safefree(url);
+ if(!urlbuffer)
+ return NULL;
+
url = urlbuffer; /* use our new URL instead! */
}
}