mirror of
https://github.com/curl/curl.git
synced 2025-01-18 14:04:30 +08:00
if HOME isn't set or too long, we attempt to lost the curlrc file from
current directory instead!
This commit is contained in:
parent
4db8c8b1a3
commit
edbe0d166c
25
src/main.c
25
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))) {
|
||||
|
||||
snprintf(filebuffer, sizeof(filebuffer),
|
||||
"%s%s%s", home, DIR_CHAR, CURLRC);
|
||||
|
||||
filename = filebuffer;
|
||||
}
|
||||
free(home); /* we've used it, now free it */
|
||||
}
|
||||
|
||||
sprintf(filebuffer, "%s%s%s", home, DIR_CHAR, CURLRC);
|
||||
|
||||
filename = filebuffer;
|
||||
}
|
||||
|
||||
if(strcmp(filename,"-"))
|
||||
@ -1770,8 +1771,6 @@ static int parseconfig(char *filename,
|
||||
if(file != stdin)
|
||||
fclose(file);
|
||||
}
|
||||
if(home)
|
||||
free(home);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user