aboutsummaryrefslogtreecommitdiff
path: root/src/tool_parsecfg.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_parsecfg.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_parsecfg.c')
-rw-r--r--src/tool_parsecfg.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index 561dada11..680688ab7 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -275,32 +275,33 @@ static char *my_get_line(FILE *fp)
{
char buf[4096];
char *nl = NULL;
- char *retval = NULL;
+ char *line = NULL;
do {
if(NULL == fgets(buf, sizeof(buf), fp))
break;
- if(!retval) {
- retval = strdup(buf);
- if(!retval)
+ if(!line) {
+ line = strdup(buf);
+ if(!line)
return NULL;
}
else {
char *ptr;
- ptr = realloc(retval, strlen(retval) + strlen(buf) + 1);
+ size_t linelen = strlen(line);
+ ptr = realloc(line, linelen + strlen(buf) + 1);
if(!ptr) {
- Curl_safefree(retval);
+ Curl_safefree(line);
return NULL;
}
- retval = ptr;
- strcat(retval, buf);
+ line = ptr;
+ strcpy(&line[linelen], buf);
}
- nl = strchr(retval, '\n');
+ nl = strchr(line, '\n');
} while(!nl);
if(nl)
*nl = '\0';
- return retval;
+ return line;
}