mirror of
https://github.com/curl/curl.git
synced 2026-08-25 01:33:31 +03:00
transfer: fix CURLOPT_CURLU override logic
- Change setopt and pretransfer to always reset URL related variables for a CURLU handle set CURLOPT_CURLU. This change is to ensure we are in compliance with the doc which says CURLU handles must be able to override a URL set via CURLOPT_URL and that if the contents of the CURLU handle changes between transfers then the updated contents must be used. Prior to this change, although subsequent transfers appear to be performed correctly in those cases, the work URL `data->state.url` was not updated. CURLINFO_EFFECTIVE_URL returns data->state.url to the user so it would return the URL from the initial transfer which was the wrong URL. It's likely there are other cases as well. Ref: https://curl.se/libcurl/c/CURLOPT_CURLU.html Reported-by: Nicolás San Martín Fixes https://github.com/curl/curl/issues/15984 Closes https://github.com/curl/curl/pull/15985
This commit is contained in:
parent
8ab468c8aa
commit
5ffc73c78e
6 changed files with 182 additions and 13 deletions
|
|
@ -2103,7 +2103,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
|
|||
* The URL to fetch.
|
||||
*/
|
||||
if(data->state.url_alloc) {
|
||||
/* the already set URL is allocated, free it first! */
|
||||
Curl_safefree(data->state.url);
|
||||
data->state.url_alloc = FALSE;
|
||||
}
|
||||
|
|
@ -2191,6 +2190,13 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
|
|||
/*
|
||||
* pass CURLU to set URL
|
||||
*/
|
||||
if(data->state.url_alloc) {
|
||||
Curl_safefree(data->state.url);
|
||||
data->state.url_alloc = FALSE;
|
||||
}
|
||||
else
|
||||
data->state.url = NULL;
|
||||
Curl_safefree(data->set.str[STRING_SET_URL]);
|
||||
data->set.uh = (CURLU *)ptr;
|
||||
break;
|
||||
case CURLOPT_SSLCERT:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue