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
This commit is contained in:
Daniel Stenberg 2020-01-11 22:53:34 +01:00
parent 29babeafec
commit ad0aa27a9d
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 48 additions and 52 deletions

View file

@ -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. */