setopt: clear proxy auth properties when switching

Verify with test 1588

Closes #21453
This commit is contained in:
Daniel Stenberg 2026-04-27 09:14:51 +02:00
parent 7586ca7455
commit c1cfdf59ac
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 275 additions and 2 deletions

View file

@ -49,6 +49,7 @@
#include "curlx/strdup.h"
#include "escape.h"
#include "bufref.h"
#include "vauth/vauth.h"
static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
{
@ -1622,6 +1623,20 @@ static CURLcode cookiefile(struct Curl_easy *data, const char *ptr)
#endif
#ifndef CURL_DISABLE_PROXY
static CURLcode setproxy(struct Curl_easy *data, const char *proxy)
{
if((data->set.str[STRING_PROXY] && proxy) &&
/* there was one set, is this a new one? */
!strcmp(data->set.str[STRING_PROXY], proxy))
return CURLE_OK; /* same one as before */
Curl_auth_digest_cleanup(&data->state.proxydigest);
memset(&data->state.authproxy, 0, sizeof(data->state.authproxy));
return Curl_setstropt(&data->set.str[STRING_PROXY], proxy);
}
static CURLcode setopt_cptr_proxy(struct Curl_easy *data, CURLoption option,
const char *ptr)
{
@ -1717,7 +1732,7 @@ static CURLcode setopt_cptr_proxy(struct Curl_easy *data, CURLoption option,
* Setting it to NULL, means no proxy but allows the environment variables
* to decide for us (if CURLOPT_PRE_PROXY setting it to NULL).
*/
return Curl_setstropt(&s->str[STRING_PROXY], ptr);
return setproxy(data, ptr);
case CURLOPT_PRE_PROXY:
/*
* Set proxy server:port to use as SOCKS proxy.

View file

@ -117,6 +117,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
/* This is used to clean up the digest specific data */
void Curl_auth_digest_cleanup(struct digestdata *digest);
#else
#define Curl_auth_digest_cleanup(x)
#define Curl_auth_is_digest_supported() FALSE
#endif /* !CURL_DISABLE_DIGEST_AUTH */