Skip to content

Commit 4968632

Browse files
committed
fixup a config file specified with CURL_RC needs to exist
... or cause an error
1 parent f44badd commit 4968632

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/tool_operate.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,10 +2721,14 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
27212721
!strcmp(first_arg, "--verbose"))) {
27222722
configdebug = TRUE;
27232723
}
2724-
parseconfig(curlrc, global); /* ignore possible failure */
2724+
if(parseconfig(curlrc, global)) {
2725+
if(curlrc)
2726+
errorf(global, "The config file provided in CURL_RC trigged an error");
2727+
result = CURLE_FAILED_INIT;
2728+
}
27252729

27262730
/* If we had no arguments then make sure a url was specified in .curlrc */
2727-
if((argc < 2) && (!global->first->url_list)) {
2731+
else if((argc < 2) && (!global->first->url_list)) {
27282732
helpf(tool_stderr, NULL);
27292733
result = CURLE_FAILED_INIT;
27302734
}

src/tool_parsecfg.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,14 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
115115
#endif
116116
}
117117
else {
118-
if(strcmp(filename, "-"))
118+
if(strcmp(filename, "-")) {
119119
file = fopen(filename, FOPEN_READTEXT);
120+
121+
if(!file) {
122+
msgf(global, "config: ", "could not read '%s'", filename);
123+
rc = 1;
124+
}
125+
}
120126
else
121127
file = stdin;
122128
}
@@ -294,8 +300,6 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
294300
if(fileerror)
295301
rc = 1;
296302
}
297-
else
298-
rc = 1; /* couldn't open the file */
299303

300304
free(pathalloc);
301305
return rc;

0 commit comments

Comments
 (0)