aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-04-05 15:04:04 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-04-05 15:04:04 +0000
commitedbe0d166cfdd30e1e15df08f1acbb26a3be1d3c (patch)
tree77011171bc19414d946577cb23d49349f12780ac
parent4db8c8b1a3b858e348c13249f8f659a0f69ae123 (diff)
if HOME isn't set or too long, we attempt to lost the curlrc file from
current directory instead!
-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;
}