mirror of
https://github.com/curl/curl.git
synced 2026-08-02 02:10:29 +03:00
tool: change some fopen failures from warnings to errors
- Error on missing input file for --data, --data-binary, --data-urlencode, --header, --variable, --write-out. Prior to this change if a user of the curl tool specified an input file for one of the above options and that file could not be opened then it would be treated as zero length data instead of an error. For example, a POST using `--data @filenametypo` would cause a zero length POST which is probably not what the user intended. Closes https://github.com/curl/curl/pull/11677
This commit is contained in:
parent
2fe26a7c6a
commit
aacbeae7bb
4 changed files with 28 additions and 71 deletions
12
src/var.c
12
src/var.c
|
|
@ -431,12 +431,14 @@ ParameterError setvariable(struct GlobalConfig *global,
|
|||
file = stdin;
|
||||
else {
|
||||
file = fopen(line, "rb");
|
||||
if(!file) {
|
||||
errorf(global, "Failed to open %s", line);
|
||||
return PARAM_READ_ERROR;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
err = file2memory(&content, &clen, file);
|
||||
/* in case of out of memory, this should fail the entire operation */
|
||||
contalloc = TRUE;
|
||||
}
|
||||
err = file2memory(&content, &clen, file);
|
||||
/* in case of out of memory, this should fail the entire operation */
|
||||
contalloc = TRUE;
|
||||
if(!use_stdin)
|
||||
fclose(file);
|
||||
if(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue