mirror of
https://github.com/curl/curl.git
synced 2026-07-24 20:17:17 +03:00
tool_operate: more transfer cleanup after parallel transfer fail
In some circumstances when doing parallel transfers, the single_transfer_cleanup() would not be called and then 'inglob' could leak. Test 496 verifies Reported-by: Trail of Bits Closes #9749
This commit is contained in:
parent
3ccaddc9fc
commit
ec977b050d
5 changed files with 60 additions and 21 deletions
|
|
@ -350,6 +350,26 @@ static void AmigaSetComment(struct per_transfer *per,
|
|||
/* When doing serial transfers, we use a single fixed error area */
|
||||
static char global_errorbuffer[CURL_ERROR_SIZE];
|
||||
|
||||
void single_transfer_cleanup(struct OperationConfig *config)
|
||||
{
|
||||
if(config) {
|
||||
struct State *state = &config->state;
|
||||
if(state->urls) {
|
||||
/* Free list of remaining URLs */
|
||||
glob_cleanup(state->urls);
|
||||
state->urls = NULL;
|
||||
}
|
||||
Curl_safefree(state->outfiles);
|
||||
Curl_safefree(state->httpgetfields);
|
||||
Curl_safefree(state->uploadfile);
|
||||
if(state->inglob) {
|
||||
/* Free list of globbed upload files */
|
||||
glob_cleanup(state->inglob);
|
||||
state->inglob = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Call this after a transfer has completed.
|
||||
*/
|
||||
|
|
@ -666,26 +686,6 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||
return result;
|
||||
}
|
||||
|
||||
static void single_transfer_cleanup(struct OperationConfig *config)
|
||||
{
|
||||
if(config) {
|
||||
struct State *state = &config->state;
|
||||
if(state->urls) {
|
||||
/* Free list of remaining URLs */
|
||||
glob_cleanup(state->urls);
|
||||
state->urls = NULL;
|
||||
}
|
||||
Curl_safefree(state->outfiles);
|
||||
Curl_safefree(state->httpgetfields);
|
||||
Curl_safefree(state->uploadfile);
|
||||
if(state->inglob) {
|
||||
/* Free list of globbed upload files */
|
||||
glob_cleanup(state->inglob);
|
||||
state->inglob = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the protocol token for the scheme used in the given URL
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ struct per_transfer {
|
|||
};
|
||||
|
||||
CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[]);
|
||||
void single_transfer_cleanup(struct OperationConfig *config);
|
||||
|
||||
extern struct per_transfer *transfers; /* first node */
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "tool_setup.h"
|
||||
#include "tool_operate.h"
|
||||
|
||||
#include "strcase.h"
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ void clean_getout(struct OperationConfig *config)
|
|||
}
|
||||
config->url_list = NULL;
|
||||
}
|
||||
single_transfer_cleanup(config);
|
||||
}
|
||||
|
||||
bool output_expected(const char *url, const char *uploadfile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue