mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
ftp wildcard: segfault due to init only in multi_perform
The proper FTP wildcard init is now more properly done in Curl_pretransfer() and the corresponding cleanup in Curl_close(). The previous place of init/cleanup code made the internal pointer to be NULL when this feature was used with the multi_socket() API, as it was made within the curl_multi_perform() function. Reported-by: Jonathan Cardoso Machado Fixes #800
This commit is contained in:
parent
e1372418cd
commit
cba9621342
15
lib/multi.c
15
lib/multi.c
@ -2116,27 +2116,12 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
data=multi->easyp;
|
data=multi->easyp;
|
||||||
while(data) {
|
while(data) {
|
||||||
CURLMcode result;
|
CURLMcode result;
|
||||||
struct WildcardData *wc = &data->wildcard;
|
|
||||||
SIGPIPE_VARIABLE(pipe_st);
|
SIGPIPE_VARIABLE(pipe_st);
|
||||||
|
|
||||||
if(data->set.wildcardmatch) {
|
|
||||||
if(!wc->filelist) {
|
|
||||||
CURLcode ret = Curl_wildcard_init(wc); /* init wildcard structures */
|
|
||||||
if(ret)
|
|
||||||
return CURLM_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sigpipe_ignore(data, &pipe_st);
|
sigpipe_ignore(data, &pipe_st);
|
||||||
result = multi_runsingle(multi, now, data);
|
result = multi_runsingle(multi, now, data);
|
||||||
sigpipe_restore(&pipe_st);
|
sigpipe_restore(&pipe_st);
|
||||||
|
|
||||||
if(data->set.wildcardmatch) {
|
|
||||||
/* destruct wildcard structures if it is needed */
|
|
||||||
if(wc->state == CURLWC_DONE || result)
|
|
||||||
Curl_wildcard_dtor(wc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
returncode = result;
|
returncode = result;
|
||||||
|
|
||||||
|
@ -1385,6 +1385,16 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
|||||||
consider to be fine */
|
consider to be fine */
|
||||||
data->state.authhost.picked &= data->state.authhost.want;
|
data->state.authhost.picked &= data->state.authhost.want;
|
||||||
data->state.authproxy.picked &= data->state.authproxy.want;
|
data->state.authproxy.picked &= data->state.authproxy.want;
|
||||||
|
|
||||||
|
if(data->set.wildcardmatch) {
|
||||||
|
struct WildcardData *wc = &data->wildcard;
|
||||||
|
if(!wc->filelist) {
|
||||||
|
result = Curl_wildcard_init(wc); /* init wildcard structures */
|
||||||
|
if(result)
|
||||||
|
return CURLM_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -484,6 +484,12 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
|
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data->set.wildcardmatch) {
|
||||||
|
/* destruct wildcard structures if it is needed */
|
||||||
|
struct WildcardData *wc = &data->wildcard;
|
||||||
|
Curl_wildcard_dtor(wc);
|
||||||
|
}
|
||||||
|
|
||||||
Curl_freeset(data);
|
Curl_freeset(data);
|
||||||
free(data);
|
free(data);
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user