diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-01-11 22:53:34 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-01-12 17:17:44 +0100 |
commit | ad0aa27a9dfd027ffb62b86dfe8a09feb0fee0d8 (patch) | |
tree | a7378517025666cdca40ea9500431ca6b971d1fb /src/tool_operate.c | |
parent | 29babeafec2cbe4a598a4d90d82bb80b7534f959 (diff) |
curl: remove 'config' field from OutStruct
As it was just unnecessary duplicated information already stored in the
'per_transfer' struct and that's around mostly anyway.
The duplicated pointer caused problems when the code flow was aborted
before the dupe was filled in and could cause a NULL pointer access.
Reported-by: Brian Carpenter
Fixes #4807
Closes #4810
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index 2bee9349a..66f2139c8 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -380,7 +380,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global, /* do not create (or even overwrite) the file in case we get no data because of unmet condition */ curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &cond_unmet); - if(!cond_unmet && !tool_create_output_file(outs)) + if(!cond_unmet && !tool_create_output_file(outs, config)) result = CURLE_WRITE_ERROR; } @@ -866,7 +866,6 @@ static CURLcode single_transfer(struct GlobalConfig *global, /* default headers output stream is stdout */ heads = &per->heads; heads->stream = stdout; - heads->config = config; /* Single header file for all URLs */ if(config->headerfile) { @@ -891,10 +890,22 @@ static CURLcode single_transfer(struct GlobalConfig *global, } } + hdrcbdata = &per->hdrcbdata; + + outs = &per->outs; + input = &per->input; + + per->outfile = NULL; + per->infdopen = FALSE; + per->infd = STDIN_FILENO; + + /* default output stream is stdout */ + outs->stream = stdout; + /* --etag-save */ etag_save = &per->etag_save; etag_save->stream = stdout; - etag_save->config = config; + if(config->etag_save_file) { /* open file for output: */ if(strcmp(config->etag_save_file, "-")) { @@ -961,19 +972,6 @@ static CURLcode single_transfer(struct GlobalConfig *global, } } - hdrcbdata = &per->hdrcbdata; - - outs = &per->outs; - input = &per->input; - - per->outfile = NULL; - per->infdopen = FALSE; - per->infd = STDIN_FILENO; - - /* default output stream is stdout */ - outs->stream = stdout; - outs->config = config; - if(metalink) { /* For Metalink download, use name in Metalink file as filename. */ |