setopt: clear proxy auth properly on NULL

Verify NULLed proxy credentials with test1648

Closes #21696
This commit is contained in:
Daniel Stenberg 2026-05-20 13:39:25 +02:00
parent f902c3c486
commit 88c7e16cce
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 206 additions and 8 deletions

View file

@ -1661,16 +1661,16 @@ static CURLcode setopt_cptr_proxy(struct Curl_easy *data, CURLoption option,
result = setstropt_userpwd(ptr, &u, &p);
/* URL decode the components */
if(!result && u) {
if(!result) {
curlx_safefree(s->str[STRING_PROXYUSERNAME]);
result = Curl_urldecode(u, 0, &s->str[STRING_PROXYUSERNAME], NULL,
REJECT_ZERO);
}
if(!result && p) {
curlx_safefree(s->str[STRING_PROXYPASSWORD]);
if(u)
result = Curl_urldecode(u, 0, &s->str[STRING_PROXYUSERNAME], NULL,
REJECT_ZERO);
}
if(!result && p)
result = Curl_urldecode(p, 0, &s->str[STRING_PROXYPASSWORD], NULL,
REJECT_ZERO);
}
curlx_free(u);
curlx_free(p);
break;