To make it clearer that they are ephemeral.
Closes #21301
/* If a proxy-authorization header was used for the proxy, then we should
make sure that it is not accidentally used for the document request
after we have connected. Let's thus free and clear it here. */
- curlx_safefree(data->state.aptr.proxyuserpwd);
+ curlx_safefree(data->req.proxyuserpwd);
break;
}
}
if(!nread) {
if(data->set.proxyauth && data->state.authproxy.avail &&
- data->state.aptr.proxyuserpwd) {
+ data->req.proxyuserpwd) {
/* proxy auth was requested and there was proxy auth available,
then deem this as "mere" proxy disconnect */
ts->close_connection = TRUE;
result = H1_CONNECT(cf, data, ts);
if(result)
goto out;
- curlx_safefree(data->state.aptr.proxyuserpwd);
+ curlx_safefree(data->req.proxyuserpwd);
out:
*done = (result == CURLE_OK) && tunnel_is_established(cf->ctx);
/* If a proxy-authorization header was used for the proxy, then we should
make sure that it is not accidentally used for the document request
after we have connected. Let's thus free and clear it here. */
- curlx_safefree(data->state.aptr.proxyuserpwd);
+ curlx_safefree(data->req.proxyuserpwd);
break;
}
}
connection */
if(proxy) {
#ifndef CURL_DISABLE_PROXY
- userp = &data->state.aptr.proxyuserpwd;
+ userp = &data->req.proxyuserpwd;
user = data->state.aptr.proxyuser;
pwd = data->state.aptr.proxypasswd;
#else
#endif
}
else {
- userp = &data->state.aptr.userpwd;
+ userp = &data->req.userpwd;
user = data->state.aptr.user;
pwd = data->state.aptr.passwd;
}
char **userp;
CURLcode result = CURLE_OK;
- userp = &data->state.aptr.userpwd;
+ userp = &data->req.userpwd;
curlx_free(*userp);
*userp = curl_maprintf("Authorization: Bearer %s\r\n",
data->set.str[STRING_BEARER]);
#ifndef CURL_DISABLE_PROXY
case H1_HD_PROXY_AUTH:
- if(data->state.aptr.proxyuserpwd)
- result = curlx_dyn_add(req, data->state.aptr.proxyuserpwd);
+ if(data->req.proxyuserpwd)
+ result = curlx_dyn_add(req, data->req.proxyuserpwd);
break;
#endif
case H1_HD_USER_AUTH:
- if(data->state.aptr.userpwd)
- result = curlx_dyn_add(req, data->state.aptr.userpwd);
+ if(data->req.userpwd)
+ result = curlx_dyn_add(req, data->req.userpwd);
break;
case H1_HD_RANGE:
if(result == CURLE_TOO_LARGE)
failf(data, "HTTP request too large");
- /* clear userpwd and proxyuserpwd to avoid reusing old credentials
- * from reused connections */
- curlx_safefree(data->state.aptr.userpwd);
-#ifndef CURL_DISABLE_PROXY
- curlx_safefree(data->state.aptr.proxyuserpwd);
-#endif
curlx_dyn_free(&req);
return result;
}
Curl_strntoupper(&auth_headers[sizeof("Authorization: ") - 1],
curlx_str(&provider0), curlx_strlen(&provider0));
- curlx_free(data->state.aptr.userpwd);
- data->state.aptr.userpwd = auth_headers;
+ curlx_free(data->req.userpwd);
+ data->req.userpwd = auth_headers;
data->state.authhost.done = TRUE;
result = CURLE_OK;
return CURLE_NOT_BUILT_IN;
#else
digest = &data->state.proxydigest;
- allocuserpwd = &data->state.aptr.proxyuserpwd;
+ allocuserpwd = &data->req.proxyuserpwd;
userp = data->state.aptr.proxyuser;
passwdp = data->state.aptr.proxypasswd;
authp = &data->state.authproxy;
}
else {
digest = &data->state.digest;
- allocuserpwd = &data->state.aptr.userpwd;
+ allocuserpwd = &data->req.userpwd;
userp = data->state.aptr.user;
passwdp = data->state.aptr.passwd;
authp = &data->state.authhost;
if(proxy) {
#ifndef CURL_DISABLE_PROXY
- curlx_free(data->state.aptr.proxyuserpwd);
- data->state.aptr.proxyuserpwd = userp;
+ curlx_free(data->req.proxyuserpwd);
+ data->req.proxyuserpwd = userp;
#endif
}
else {
- curlx_free(data->state.aptr.userpwd);
- data->state.aptr.userpwd = userp;
+ curlx_free(data->req.userpwd);
+ data->req.userpwd = userp;
}
curlx_free(base64);
if(proxy) {
#ifndef CURL_DISABLE_PROXY
- allocuserpwd = &data->state.aptr.proxyuserpwd;
+ allocuserpwd = &data->req.proxyuserpwd;
userp = data->state.aptr.proxyuser;
passwdp = data->state.aptr.proxypasswd;
service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
#endif
}
else {
- allocuserpwd = &data->state.aptr.userpwd;
+ allocuserpwd = &data->req.userpwd;
userp = data->state.aptr.user;
passwdp = data->state.aptr.passwd;
service = data->set.str[STRING_SERVICE_NAME] ?
goto out;
}
- if(data->state.aptr.proxyuserpwd) {
+ if(data->req.proxyuserpwd) {
result = Curl_dynhds_h1_cadd_line(&req->headers,
- data->state.aptr.proxyuserpwd);
+ data->req.proxyuserpwd);
if(result)
goto out;
}
struct curltime t0 = { 0, 0 };
curlx_safefree(req->newurl);
+ curlx_safefree(req->userpwd);
+#ifndef CURL_DISABLE_PROXY
+ curlx_safefree(req->proxyuserpwd);
+#endif
Curl_client_reset(data);
if(req->sendbuf_init)
Curl_bufq_reset(&req->sendbuf);
void Curl_req_free(struct SingleRequest *req, struct Curl_easy *data)
{
curlx_safefree(req->newurl);
+ curlx_safefree(req->userpwd);
+#ifndef CURL_DISABLE_PROXY
+ curlx_safefree(req->proxyuserpwd);
+#endif
if(req->sendbuf_init)
Curl_bufq_free(&req->sendbuf);
Curl_client_cleanup(data);
wanted */
uint8_t io_flags; /* REQ_IO_RECV | REQ_IO_SEND */
+ char *userpwd; /* auth header */
+#ifndef CURL_DISABLE_PROXY
+ char *proxyuserpwd; /* proxy auth header */
+#endif
#ifndef CURL_DISABLE_COOKIES
unsigned char setcookies;
#endif
goto out;
#ifndef CURL_DISABLE_PROXY
- p_proxyuserpwd = data->state.aptr.proxyuserpwd;
+ p_proxyuserpwd = data->req.proxyuserpwd;
#endif
- p_userpwd = data->state.aptr.userpwd;
+ p_userpwd = data->req.userpwd;
/* Referrer */
curlx_safefree(data->state.aptr.ref);
p_proxyuserpwd ? p_proxyuserpwd : "",
p_userpwd ? p_userpwd : "");
- /*
- * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
- * with basic and digest, it will be freed anyway by the next request
- */
- curlx_safefree(data->state.aptr.userpwd);
-
if(result)
goto out;
DEBUGASSERT(0);
Curl_hash_destroy(&data->meta_hash);
-#ifndef CURL_DISABLE_PROXY
- curlx_safefree(data->state.aptr.proxyuserpwd);
-#endif
curlx_safefree(data->state.aptr.uagent);
- curlx_safefree(data->state.aptr.userpwd);
curlx_safefree(data->state.aptr.accept_encoding);
curlx_safefree(data->state.aptr.rangeline);
curlx_safefree(data->state.aptr.ref);
struct dynamically_allocated_data {
char *uagent;
char *accept_encoding;
- char *userpwd;
char *rangeline;
char *ref;
char *host;
char *user;
char *passwd;
#ifndef CURL_DISABLE_PROXY
- char *proxyuserpwd;
char *proxyuser;
char *proxypasswd;
#endif