aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 2c205ffdd..338d52b7d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1604,26 +1604,27 @@ static int parseconfig(char *filename,
{
int res;
FILE *file;
- char filebuffer[256];
+ char filebuffer[512];
bool usedarg;
- char *home=NULL;
+ char *home;
if(!filename || !*filename) {
/* NULL or no file name attempts to load .curlrc from the homedir! */
#define CURLRC DOT_CHAR "curlrc"
+ filename = CURLRC; /* sensible default */
home = curl_getenv("HOME"); /* portable environment reader */
- if(!home)
- return 0;
- if(strlen(home)>(sizeof(filebuffer)-strlen(CURLRC))) {
- free(home);
- return 0;
- }
+ if(home) {
+ if(strlen(home)<(sizeof(filebuffer)-strlen(CURLRC))) {
- sprintf(filebuffer, "%s%s%s", home, DIR_CHAR, CURLRC);
+ snprintf(filebuffer, sizeof(filebuffer),
+ "%s%s%s", home, DIR_CHAR, CURLRC);
- filename = filebuffer;
+ filename = filebuffer;
+ }
+ free(home); /* we've used it, now free it */
+ }
}
if(strcmp(filename,"-"))
@@ -1770,8 +1771,6 @@ static int parseconfig(char *filename,
if(file != stdin)
fclose(file);
}
- if(home)
- free(home);
return 0;
}