mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
ftp.c: ftplistparser related OOM handling fix
This commit is contained in:
parent
b16e3da12a
commit
9753c6bec5
26
lib/ftp.c
26
lib/ftp.c
@ -3824,15 +3824,17 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
|||||||
resources for wildcard transfer */
|
resources for wildcard transfer */
|
||||||
|
|
||||||
/* allocate ftp protocol specific temporary wildcard data */
|
/* allocate ftp protocol specific temporary wildcard data */
|
||||||
ftp_tmp = malloc(sizeof(struct ftp_wc_tmpdata));
|
ftp_tmp = calloc(1, sizeof(struct ftp_wc_tmpdata));
|
||||||
if(!ftp_tmp) {
|
if(!ftp_tmp) {
|
||||||
|
Curl_safefree(wildcard->pattern);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* INITIALIZE parselist structure */
|
/* INITIALIZE parselist structure */
|
||||||
ftp_tmp->parser = Curl_ftp_parselist_data_alloc();
|
ftp_tmp->parser = Curl_ftp_parselist_data_alloc();
|
||||||
if(!ftp_tmp->parser) {
|
if(!ftp_tmp->parser) {
|
||||||
free(ftp_tmp);
|
Curl_safefree(wildcard->pattern);
|
||||||
|
Curl_safefree(ftp_tmp);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3846,9 +3848,22 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
|||||||
/* try to parse ftp url */
|
/* try to parse ftp url */
|
||||||
ret = ftp_parse_url_path(conn);
|
ret = ftp_parse_url_path(conn);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
|
Curl_safefree(wildcard->pattern);
|
||||||
|
wildcard->tmp_dtor(wildcard->tmp);
|
||||||
|
wildcard->tmp_dtor = ZERO_NULL;
|
||||||
|
wildcard->tmp = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wildcard->path = strdup(conn->data->state.path);
|
||||||
|
if(!wildcard->path) {
|
||||||
|
Curl_safefree(wildcard->pattern);
|
||||||
|
wildcard->tmp_dtor(wildcard->tmp);
|
||||||
|
wildcard->tmp_dtor = ZERO_NULL;
|
||||||
|
wildcard->tmp = NULL;
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
/* backup old write_function */
|
/* backup old write_function */
|
||||||
ftp_tmp->backup.write_function = conn->data->set.fwrite_func;
|
ftp_tmp->backup.write_function = conn->data->set.fwrite_func;
|
||||||
/* parsing write function */
|
/* parsing write function */
|
||||||
@ -3858,11 +3873,6 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
|||||||
/* let the writefunc callback know what curl pointer is working with */
|
/* let the writefunc callback know what curl pointer is working with */
|
||||||
conn->data->set.out = conn;
|
conn->data->set.out = conn;
|
||||||
|
|
||||||
wildcard->path = strdup(conn->data->state.path);
|
|
||||||
if(!wildcard->path) {
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
infof(conn->data, "Wildcard - Parsing started\n");
|
infof(conn->data, "Wildcard - Parsing started\n");
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@ -3889,6 +3899,8 @@ static CURLcode wc_statemach(struct connectdata *conn)
|
|||||||
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
|
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
|
||||||
conn->data->set.fwrite_func = ftp_tmp->backup.write_function;
|
conn->data->set.fwrite_func = ftp_tmp->backup.write_function;
|
||||||
conn->data->set.out = ftp_tmp->backup.file_descriptor;
|
conn->data->set.out = ftp_tmp->backup.file_descriptor;
|
||||||
|
ftp_tmp->backup.write_function = ZERO_NULL;
|
||||||
|
ftp_tmp->backup.file_descriptor = NULL;
|
||||||
wildcard->state = CURLWC_DOWNLOADING;
|
wildcard->state = CURLWC_DOWNLOADING;
|
||||||
|
|
||||||
if(Curl_ftp_parselist_geterror(ftp_tmp->parser)) {
|
if(Curl_ftp_parselist_geterror(ftp_tmp->parser)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user