From ad0aa27a9dfd027ffb62b86dfe8a09feb0fee0d8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 11 Jan 2020 22:53:34 +0100 Subject: 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 --- src/tool_operate.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/tool_operate.c') 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. */ -- cgit v1.2.3