mirror of
https://github.com/curl/curl.git
synced 2026-08-24 22:43:38 +03:00
tool_operate: Fix error codes on bad URL & OOM
curl would erroneously report CURLE_OUT_OF_MEMORY in some cases instead of CURLE_URL_MALFORMAT. In other cases, it would erroneously return CURLE_URL_MALFORMAT instead of CURLE_OUT_OF_MEMORY. Add a test case to test the former condition. Fixes #10130 Closes #10414
This commit is contained in:
parent
a0adda4b47
commit
349c5391f2
5 changed files with 117 additions and 51 deletions
|
|
@ -1209,21 +1209,26 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||
CURLU *uh = curl_url();
|
||||
if(uh) {
|
||||
char *updated;
|
||||
if(curl_url_set(uh, CURLUPART_URL, per->this_url,
|
||||
CURLU_GUESS_SCHEME)) {
|
||||
result = CURLE_FAILED_INIT;
|
||||
CURLUcode uerr;
|
||||
uerr = curl_url_set(uh, CURLUPART_URL, per->this_url,
|
||||
CURLU_GUESS_SCHEME);
|
||||
if(uerr) {
|
||||
result = urlerr_cvt(uerr);
|
||||
errorf(global, "(%d) Could not parse the URL, "
|
||||
"failed to set query\n", result);
|
||||
config->synthetic_error = TRUE;
|
||||
}
|
||||
else if(curl_url_set(uh, CURLUPART_QUERY, q, CURLU_APPENDQUERY) ||
|
||||
curl_url_get(uh, CURLUPART_URL, &updated,
|
||||
CURLU_GUESS_SCHEME)) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
else {
|
||||
Curl_safefree(per->this_url); /* free previous URL */
|
||||
per->this_url = updated; /* use our new URL instead! */
|
||||
uerr = curl_url_set(uh, CURLUPART_QUERY, q, CURLU_APPENDQUERY);
|
||||
if(!uerr)
|
||||
uerr = curl_url_get(uh, CURLUPART_URL, &updated,
|
||||
CURLU_GUESS_SCHEME);
|
||||
if(uerr)
|
||||
result = urlerr_cvt(uerr);
|
||||
else {
|
||||
Curl_safefree(per->this_url); /* free previous URL */
|
||||
per->this_url = updated; /* use our new URL instead! */
|
||||
}
|
||||
}
|
||||
curl_url_cleanup(uh);
|
||||
if(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue