diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-12-17 12:51:51 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-12-19 08:44:02 +0100 |
commit | 4849267197682e69cfa056c2bd7a44acd123a917 (patch) | |
tree | a6d0ed8d497b48ebdcd7dd6bb837d49662d561e6 /src/tool_cb_wrt.c | |
parent | f097669248a877dece74fdb525e82bfe1b69df90 (diff) |
curl -J: do not append to the destination file
Reported-by: Kamil Dudka
Fixes #3380
Closes #3381
Diffstat (limited to 'src/tool_cb_wrt.c')
-rw-r--r-- | src/tool_cb_wrt.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 2cb5e1b41..195d6e79c 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -32,8 +32,7 @@ #include "memdebug.h" /* keep this as LAST include */ /* create a local file for writing, return TRUE on success */ -bool tool_create_output_file(struct OutStruct *outs, - bool append) +bool tool_create_output_file(struct OutStruct *outs) { struct GlobalConfig *global = outs->config->global; FILE *file; @@ -43,7 +42,7 @@ bool tool_create_output_file(struct OutStruct *outs, return FALSE; } - if(outs->is_cd_filename && !append) { + if(outs->is_cd_filename) { /* don't overwrite existing files */ file = fopen(outs->filename, "rb"); if(file) { @@ -55,7 +54,7 @@ bool tool_create_output_file(struct OutStruct *outs, } /* open file for writing */ - file = fopen(outs->filename, append?"ab":"wb"); + file = fopen(outs->filename, "wb"); if(!file) { warnf(global, "Failed to create the file %s: %s\n", outs->filename, strerror(errno)); @@ -142,7 +141,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) } #endif - if(!outs->stream && !tool_create_output_file(outs, FALSE)) + if(!outs->stream && !tool_create_output_file(outs)) return failure; if(is_tty && (outs->bytes < 2000) && !config->terminal_binary_ok) { |