mirror of
https://github.com/curl/curl.git
synced 2026-07-26 00:27:16 +03:00
tool: determine the correct fopen option for -D
This commit fixes a bug in the dump-header feature regarding the determination of the second fopen(3) option. Reported-by: u20221022 on github See #4753 See #4762 Fixes #10074 Closes #10079
This commit is contained in:
parent
1a88b6b653
commit
8b1e5df73d
4 changed files with 98 additions and 2 deletions
|
|
@ -969,7 +969,21 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||
/* open file for output: */
|
||||
if(strcmp(config->headerfile, "-")) {
|
||||
FILE *newfile;
|
||||
newfile = fopen(config->headerfile, per->prev == NULL?"wb":"ab");
|
||||
|
||||
/*
|
||||
* this checks if the previous transfer had the same
|
||||
* OperationConfig, which would mean, that the an output file has
|
||||
* already been created and data can be appened to it, instead
|
||||
* of overwriting it.
|
||||
* TODO: Consider placing the file handle inside the
|
||||
* OperationConfig, so that it does not need to be opened/closed
|
||||
* for every transfer.
|
||||
*/
|
||||
if(per->prev && per->prev->config == config)
|
||||
newfile = fopen(config->headerfile, "ab+");
|
||||
else
|
||||
newfile = fopen(config->headerfile, "wb+");
|
||||
|
||||
if(!newfile) {
|
||||
warnf(global, "Failed to open %s\n", config->headerfile);
|
||||
result = CURLE_WRITE_ERROR;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue