public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/curl] f44: curl-8.18.0-15
@ 2026-11-27 13:15 Jan Macku
0 siblings, 0 replies; only message in thread
From: Jan Macku @ 2026-11-27 13:15 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/curl
Branch : f44
Commit : 7f56c98ee75c2c8f85f58a3884124bec122884ed
Author : Jan Macku <jamacku@redhat.com>
Date : 2026-11-27T12:48:42+01:00
Stats : +9845/-9898 in 69 file(s)
URL : https://src.fedoraproject.org/rpms/curl/c/7f56c98ee75c2c8f85f58a3884124bec122884ed?branch=f44
Log:
curl-8.18.0-15
Resolves: CVE-2026-92392
---
diff --git a/0001-curl-8.18.0-multi-update-timer-unconditionally-in-multi_remove_h.patch b/0001-curl-8.18.0-multi-update-timer-unconditionally-in-multi_remove_h.patch
deleted file mode 100644
index aabe577..0000000
--- a/0001-curl-8.18.0-multi-update-timer-unconditionally-in-multi_remove_h.patch
+++ /dev/null
@@ -1,109 +0,0 @@
-From 0f566bd818245dd1f6cb42b0d409ce34ebff9259 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Tue, 3 Feb 2026 10:18:13 +0100
-Subject: [PATCH] multi: update timer unconditionally in multi_remove_handle
-
-When removing an easy handle from a multi, there was an optimization
-to update the timer only when the removed handle had any timers.
-
-With the introduction of the "dirty" bitset, easy handles can now cause
-a timeout of 0 to be set without having anything in their timer list.
-Removing such a handle needs to update the timer now always, so that
-it may get cleared when there is nothing more to wait for.
-
-The previous "not clearing a 0 timer" should not have any effect on
-application's logic. Without clearing, the timer will fire and then
-adjust itself to the proper value. But it would cause one more timer
-fire than necessary.
-
-Reported-by: Jan Macku
-
-Fixes https://github.com/curl/curl/issues/20498
-Closes https://github.com/curl/curl/pull/20502
-
-(cherry picked from commit 2d4efbb9b36c0f883651020fd7d9a3f62fc0829b)
----
- lib/multi.c | 17 ++++++-----------
- lib/multiif.h | 2 +-
- 2 files changed, 7 insertions(+), 12 deletions(-)
-
-diff --git a/lib/multi.c b/lib/multi.c
-index 7cfd053c90..6db86abda2 100644
---- a/lib/multi.c
-+++ b/lib/multi.c
-@@ -750,7 +750,6 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
- bool premature;
- struct Curl_llist_node *e;
- CURLMcode mresult;
-- bool removed_timer = FALSE;
- uint32_t mid;
-
- /* First, make some basic checks that the CURLM handle is a good handle */
-@@ -805,7 +804,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
- /* The timer must be shut down before data->multi is set to NULL, else the
- timenode will remain in the splay tree after curl_easy_cleanup is
- called. Do it after multi_done() in case that sets another time! */
-- removed_timer = Curl_expire_clear(data);
-+ Curl_expire_clear(data);
-
- /* If in `msgsent`, it was deducted from `multi->xfers_alive` already. */
- if(!Curl_uint32_bset_contains(&multi->msgsent, data->mid))
-@@ -878,11 +877,9 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
- We do not touch the easy handle here! */
- process_pending_handles(multi);
-
-- if(removed_timer) {
-- mresult = Curl_update_timer(multi);
-- if(mresult)
-- return mresult;
-- }
-+ mresult = Curl_update_timer(multi);
-+ if(mresult)
-+ return mresult;
-
- CURL_TRC_M(data, "removed from multi, mid=%u, running=%u, total=%u",
- mid, Curl_multi_xfers_running(multi),
-@@ -3649,7 +3646,7 @@ void Curl_expire_done(struct Curl_easy *data, expire_id eid)
- *
- * Clear ALL timeout values for this handle.
- */
--bool Curl_expire_clear(struct Curl_easy *data)
-+void Curl_expire_clear(struct Curl_easy *data)
- {
- struct Curl_multi *multi = data->multi;
- struct curltime *nowp = &data->state.expiretime;
-@@ -3657,7 +3654,7 @@ bool Curl_expire_clear(struct Curl_easy *data)
- /* this is only interesting while there is still an associated multi struct
- remaining! */
- if(!multi)
-- return FALSE;
-+ return;
-
- if(nowp->tv_sec || nowp->tv_usec) {
- /* Since this is an cleared time, we must remove the previous entry from
-@@ -3677,9 +3674,7 @@ bool Curl_expire_clear(struct Curl_easy *data)
- CURL_TRC_M(data, "[TIMEOUT] all cleared");
- nowp->tv_sec = 0;
- nowp->tv_usec = 0;
-- return TRUE;
- }
-- return FALSE;
- }
-
- CURLMcode curl_multi_assign(CURLM *m, curl_socket_t s,
-diff --git a/lib/multiif.h b/lib/multiif.h
-index 15fc070341..f368639857 100644
---- a/lib/multiif.h
-+++ b/lib/multiif.h
-@@ -30,7 +30,7 @@
- void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id);
- void Curl_expire_ex(struct Curl_easy *data,
- timediff_t milli, expire_id id);
--bool Curl_expire_clear(struct Curl_easy *data);
-+void Curl_expire_clear(struct Curl_easy *data);
- void Curl_expire_done(struct Curl_easy *data, expire_id id);
- CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
- void Curl_attach_connection(struct Curl_easy *data,
---
-2.52.0
-
diff --git a/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch b/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
new file mode 100644
index 0000000..6a4caf0
--- /dev/null
+++ b/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
@@ -0,0 +1,90 @@
+From b2d57e5a8b673c3b39fae60b9aab65b7c9acc5cd Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Fri, 12 Apr 2013 12:04:05 +0200
+Subject: [PATCH] prevent multilib conflicts on the curl-config script
+
+fedora-only
+---
+ curl-config.in | 23 +++++------------------
+ docs/curl-config.md | 4 +++-
+ libcurl.pc.in | 1 +
+ 3 files changed, 9 insertions(+), 19 deletions(-)
+
+diff --git a/curl-config.in b/curl-config.in
+index a1c8185875..bb43ca8335 100644
+--- a/curl-config.in
++++ b/curl-config.in
+@@ -74,7 +74,7 @@ while test "$#" -gt 0; do
+ ;;
+
+ --cc)
+- echo '@CC@'
++ echo 'gcc'
+ ;;
+
+ --prefix)
+@@ -149,16 +149,7 @@ while test "$#" -gt 0; do
+ ;;
+
+ --libs)
+- if test "@libdir@" != '/usr/lib' && test "@libdir@" != '/usr/lib64'; then
+- curllibdir="-L@libdir@ "
+- else
+- curllibdir=''
+- fi
+- if test '@ENABLE_SHARED@' = 'no'; then
+- echo "${curllibdir}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
+- else
+- echo "${curllibdir}-lcurl"
+- fi
++ echo '-lcurl'
+ ;;
+
+ --ssl-backends)
+@@ -166,16 +157,12 @@ while test "$#" -gt 0; do
+ ;;
+
+ --static-libs)
+- if test '@ENABLE_STATIC@' != 'no'; then
+- echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
+- else
+- echo 'curl was built with static libraries disabled' >&2
+- exit 1
+- fi
++ echo 'curl was built with static libraries disabled' >&2
++ exit 1
+ ;;
+
+ --configure)
+- echo @CONFIGURE_OPTIONS@
++ pkg-config libcurl --variable=configure_options | sed 's/^"//;s/"$//'
+ ;;
+
+ *)
+diff --git a/docs/curl-config.md b/docs/curl-config.md
+index 12ad245b79..fa0e03d273 100644
+--- a/docs/curl-config.md
++++ b/docs/curl-config.md
+@@ -87,7 +87,9 @@ no, one or several names. If more than one name, they appear comma-separated.
+ ## `--static-libs`
+
+ Shows the complete set of libs and other linker options you need in order to
+-link your application with libcurl statically. (Added in 7.17.1)
++link your application with libcurl statically. Note that Fedora/RHEL libcurl
++packages do not provide any static libraries, thus cannot be linked statically.
++(Added in 7.17.1)
+
+ ## `--version`
+
+diff --git a/libcurl.pc.in b/libcurl.pc.in
+index c0ba5244a8..f3645e1748 100644
+--- a/libcurl.pc.in
++++ b/libcurl.pc.in
+@@ -28,6 +28,7 @@ libdir=@libdir@
+ includedir=@includedir@
+ supported_protocols="@SUPPORT_PROTOCOLS@"
+ supported_features="@SUPPORT_FEATURES@"
++configure_options=@CONFIGURE_OPTIONS@
+
+ Name: libcurl
+ URL: https://curl.se/
diff --git a/0002-curl-8.18.0-openssl-channel_binding-lookup-digest-algorithm-with.patch b/0002-curl-8.18.0-openssl-channel_binding-lookup-digest-algorithm-with.patch
deleted file mode 100644
index a2ee712..0000000
--- a/0002-curl-8.18.0-openssl-channel_binding-lookup-digest-algorithm-with.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-From de50b544dd655d509213c36ff9676a7952eca98a Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Thu, 26 Feb 2026 10:21:31 +0100
-Subject: [PATCH] openssl channel_binding: lookup digest algorithm without NID
-
-Use an alternate OpenSSL API to get the digest algorithm tied
-to a certificate signature to compute the channel binding.
-
-Fixes #20590
-Reported-by: Rob Crittenden
-Closes #20734
-
-(cherry picked from commit b0f6e9a3d7be02e8f2e323aa97f2ff9b30662b32)
----
- lib/vtls/openssl.c | 97 +++++++++++++++++++++++++++++++++++++++-------
- 1 file changed, 82 insertions(+), 15 deletions(-)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 84e6eaadd5..ebe583154f 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -5235,13 +5235,15 @@ out:
- return result;
- }
-
--static CURLcode ossl_get_channel_binding(struct Curl_easy *data, int sockindex,
-+static CURLcode ossl_get_channel_binding(struct Curl_easy *data,
-+ int sockindex,
- struct dynbuf *binding)
- {
- X509 *cert;
-- int algo_nid;
-- const EVP_MD *algo_type;
-- const char *algo_name;
-+ int mdnid;
-+ bool no_digest_acceptable = FALSE;
-+ const EVP_MD *algo_type = NULL;
-+ const char *algo_name = NULL;
- unsigned int length;
- unsigned char buf[EVP_MAX_MD_SIZE];
-
-@@ -5273,43 +5275,108 @@ static CURLcode ossl_get_channel_binding(struct Curl_easy *data, int sockindex,
- /* No server certificate, do not do channel binding */
- return CURLE_OK;
-
-- if(!OBJ_find_sigid_algs(X509_get_signature_nid(cert), &algo_nid, NULL)) {
-+#ifdef HAVE_OPENSSL3
-+ {
-+ int pknid, secbits;
-+ uint32_t flags;
-+ EVP_PKEY *pkey = X509_get0_pubkey(cert);
-+
-+ if(!X509_get_signature_info(cert, &mdnid, &pknid, &secbits, &flags)) {
-+ failf(data, "certificate signature algorithm not recognized");
-+ result = CURLE_SSL_INVALIDCERTSTATUS;
-+ goto out;
-+ }
-+
-+ if(mdnid != NID_undef) {
-+ if(mdnid == NID_md5 || mdnid == NID_sha1) {
-+ algo_type = EVP_sha256();
-+ }
-+ else
-+ algo_type = EVP_get_digestbynid(mdnid);
-+ }
-+ else if(pkey && !EVP_PKEY_is_a(pkey, OBJ_nid2sn(pknid))) {
-+ /* The cert's pkey is different from the algorithm used to sign
-+ * the certificate. Since the reported `mdnid` is undefined, there
-+ * is no digest algorithm available here. This happens in PQC
-+ * and is accepted, resulting in no addition to the binding. */
-+ no_digest_acceptable = TRUE;
-+ }
-+ else if(pkey) {
-+ /* cert's pkey type is the same as the cert signer (or same family).
-+ * Ask for the mandatory/advisory digest algorithm for the pkey.
-+ */
-+ char mdname[128] = "";
-+ int rc = EVP_PKEY_get_default_digest_name(pkey, mdname, sizeof(mdname));
-+ bool md_is_undef = !strcmp(mdname, "UNDEF");
-+
-+ if(rc == 2 && md_is_undef) {
-+ /* OpenSSL declares "undef" the *mandatory* digest for this key.
-+ * This is some PQC shit, accept it, no addition to binding. */
-+ no_digest_acceptable = TRUE;
-+ }
-+ else if(rc > 0 && mdname[0] != '\0' && !md_is_undef) {
-+ infof(data, "Digest algorithm : %s%s (derived from public key)"
-+ ", but unavailable",
-+ mdname, rc == 2 ? " [mandatory]" : " [advisory]");
-+ }
-+ }
-+ }
-+#else /* HAVE_OPENSSL3 */
-+
-+ if(!OBJ_find_sigid_algs(X509_get_signature_nid(cert), &mdnid, NULL)) {
- failf(data,
- "Unable to find digest NID for certificate signature algorithm");
- result = CURLE_SSL_INVALIDCERTSTATUS;
-- goto error;
-+ goto out;
- }
-
- /* https://datatracker.ietf.org/doc/html/rfc5929#section-4.1 */
-- if(algo_nid == NID_md5 || algo_nid == NID_sha1) {
-+ if(mdnid == NID_md5 || mdnid == NID_sha1) {
- algo_type = EVP_sha256();
- }
- else {
-- algo_type = EVP_get_digestbynid(algo_nid);
-+ algo_type = EVP_get_digestbynid(mdnid);
- if(!algo_type) {
-- algo_name = OBJ_nid2sn(algo_nid);
-+ algo_name = OBJ_nid2sn(mdnid);
- failf(data, "Could not find digest algorithm %s (NID %d)",
-- algo_name ? algo_name : "(null)", algo_nid);
-+ algo_name ? algo_name : "(null)", mdnid);
- result = CURLE_SSL_INVALIDCERTSTATUS;
-- goto error;
-+ goto out;
-+ }
-+ }
-+
-+#endif /* HAVE_OPENSSL3, else */
-+
-+ if(!algo_type) {
-+ if(no_digest_acceptable) {
-+ infof(data, "certificate exposes no signing digest algorithm, "
-+ "nothing to add to channel binding");
-+ result = CURLE_OK;
-+ goto out;
- }
-+ /* unacceptable, something is wrong, fail */
-+ algo_name = OBJ_nid2sn(mdnid);
-+ failf(data, "Unable to find digest algorithm %s (NID %d) "
-+ "for channel binding", algo_name ? algo_name : "(null)", mdnid);
-+ result = CURLE_SSL_INVALIDCERTSTATUS;
-+ goto out;
- }
-
- if(!X509_digest(cert, algo_type, buf, &length)) {
-- failf(data, "X509_digest() failed");
-+ failf(data, "X509_digest() failed for channel binding");
- result = CURLE_SSL_INVALIDCERTSTATUS;
-- goto error;
-+ goto out;
- }
-
- /* Append "tls-server-end-point:" */
- result = curlx_dyn_addn(binding, prefix, sizeof(prefix) - 1);
- if(result)
-- goto error;
-+ goto out;
-
- /* Append digest */
- result = curlx_dyn_addn(binding, buf, length);
-
--error:
-+out:
- X509_free(cert);
- return result;
- }
---
-2.53.0
-
diff --git a/0002-multi-update-timer-unconditionally-in-multi_remove_h.patch b/0002-multi-update-timer-unconditionally-in-multi_remove_h.patch
new file mode 100644
index 0000000..6c653fb
--- /dev/null
+++ b/0002-multi-update-timer-unconditionally-in-multi_remove_h.patch
@@ -0,0 +1,106 @@
+From 080f3e733186487013c092c693996ae0e8f1e096 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Tue, 3 Feb 2026 10:18:13 +0100
+Subject: [PATCH] multi: update timer unconditionally in multi_remove_handle
+
+When removing an easy handle from a multi, there was an optimization
+to update the timer only when the removed handle had any timers.
+
+With the introduction of the "dirty" bitset, easy handles can now cause
+a timeout of 0 to be set without having anything in their timer list.
+Removing such a handle needs to update the timer now always, so that
+it may get cleared when there is nothing more to wait for.
+
+The previous "not clearing a 0 timer" should not have any effect on
+application's logic. Without clearing, the timer will fire and then
+adjust itself to the proper value. But it would cause one more timer
+fire than necessary.
+
+Reported-by: Jan Macku
+
+Fixes https://github.com/curl/curl/issues/20498
+Closes https://github.com/curl/curl/pull/20502
+
+(cherry picked from commit 2d4efbb9b36c0f883651020fd7d9a3f62fc0829b)
+---
+ lib/multi.c | 17 ++++++-----------
+ lib/multiif.h | 2 +-
+ 2 files changed, 7 insertions(+), 12 deletions(-)
+
+diff --git a/lib/multi.c b/lib/multi.c
+index 7cfd053c90..6db86abda2 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -750,7 +750,6 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
+ bool premature;
+ struct Curl_llist_node *e;
+ CURLMcode mresult;
+- bool removed_timer = FALSE;
+ uint32_t mid;
+
+ /* First, make some basic checks that the CURLM handle is a good handle */
+@@ -805,7 +804,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
+ /* The timer must be shut down before data->multi is set to NULL, else the
+ timenode will remain in the splay tree after curl_easy_cleanup is
+ called. Do it after multi_done() in case that sets another time! */
+- removed_timer = Curl_expire_clear(data);
++ Curl_expire_clear(data);
+
+ /* If in `msgsent`, it was deducted from `multi->xfers_alive` already. */
+ if(!Curl_uint32_bset_contains(&multi->msgsent, data->mid))
+@@ -878,11 +877,9 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
+ We do not touch the easy handle here! */
+ process_pending_handles(multi);
+
+- if(removed_timer) {
+- mresult = Curl_update_timer(multi);
+- if(mresult)
+- return mresult;
+- }
++ mresult = Curl_update_timer(multi);
++ if(mresult)
++ return mresult;
+
+ CURL_TRC_M(data, "removed from multi, mid=%u, running=%u, total=%u",
+ mid, Curl_multi_xfers_running(multi),
+@@ -3649,7 +3646,7 @@ void Curl_expire_done(struct Curl_easy *data, expire_id eid)
+ *
+ * Clear ALL timeout values for this handle.
+ */
+-bool Curl_expire_clear(struct Curl_easy *data)
++void Curl_expire_clear(struct Curl_easy *data)
+ {
+ struct Curl_multi *multi = data->multi;
+ struct curltime *nowp = &data->state.expiretime;
+@@ -3657,7 +3654,7 @@ bool Curl_expire_clear(struct Curl_easy *data)
+ /* this is only interesting while there is still an associated multi struct
+ remaining! */
+ if(!multi)
+- return FALSE;
++ return;
+
+ if(nowp->tv_sec || nowp->tv_usec) {
+ /* Since this is an cleared time, we must remove the previous entry from
+@@ -3677,9 +3674,7 @@ bool Curl_expire_clear(struct Curl_easy *data)
+ CURL_TRC_M(data, "[TIMEOUT] all cleared");
+ nowp->tv_sec = 0;
+ nowp->tv_usec = 0;
+- return TRUE;
+ }
+- return FALSE;
+ }
+
+ CURLMcode curl_multi_assign(CURLM *m, curl_socket_t s,
+diff --git a/lib/multiif.h b/lib/multiif.h
+index 15fc070341..f368639857 100644
+--- a/lib/multiif.h
++++ b/lib/multiif.h
+@@ -30,7 +30,7 @@
+ void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id);
+ void Curl_expire_ex(struct Curl_easy *data,
+ timediff_t milli, expire_id id);
+-bool Curl_expire_clear(struct Curl_easy *data);
++void Curl_expire_clear(struct Curl_easy *data);
+ void Curl_expire_done(struct Curl_easy *data, expire_id id);
+ CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
+ void Curl_attach_connection(struct Curl_easy *data,
diff --git a/0003-curl-8.18.0-CVE-2026-1965.patch b/0003-curl-8.18.0-CVE-2026-1965.patch
deleted file mode 100644
index 1a6ca21..0000000
--- a/0003-curl-8.18.0-CVE-2026-1965.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From 559522ccea1e257d12ca029b2083fb05805d9de2 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 5 Feb 2026 08:34:21 +0100
-Subject: [PATCH 4/4] CVE-2026-1965
-
-url: fix reuse of connections using HTTP Negotiate
-
-Assume Negotiate means connection-based
-
-Reported-by: Zhicheng Chen
-Closes #20534
-
-(cherry picked from commit 34fa034d9a390c4bd65e2d05262755ec8646ac12)
-
-url: fix copy and paste url_match_auth_nego mistake
-
-Follow-up to 34fa034
-Reported-by: dahmono on github
-Closes #20662
-
-(cherry picked from commit f1a39f221d57354990e3eeeddc3404aede2aff70)
-
-sws: prevent "connection monitor" to say disconnect twice
-
-(cherry picked from commit 510fdad64df7f91f605b19ffdb0c4c67891f1518)
----
- lib/url.c | 87 +++++++++++++++++++++++++++++++++++++++----
- tests/server/sws.c | 1 +
- 2 files changed, 83 insertions(+), 5 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index fee9aa3a6f..5a75fe71da 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -744,6 +744,8 @@ struct url_conn_match {
- BIT(may_multiplex);
- BIT(want_ntlm_http);
- BIT(want_proxy_ntlm_http);
-+ BIT(want_nego_http);
-+ BIT(want_proxy_nego_http);
-
- BIT(wait_pipe);
- BIT(force_reuse);
-@@ -1166,6 +1168,63 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
- #define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE)
- #endif
-
-+#ifdef USE_SPNEGO
-+static bool url_match_auth_nego(struct connectdata *conn,
-+ struct url_conn_match *m)
-+{
-+ /* If we are looking for an HTTP+Negotiate connection, check if this is
-+ already authenticating with the right credentials. If not, keep looking
-+ so that we can reuse Negotiate connections if possible. */
-+ if(m->want_nego_http) {
-+ if(Curl_timestrcmp(m->needle->user, conn->user) ||
-+ Curl_timestrcmp(m->needle->passwd, conn->passwd))
-+ return FALSE;
-+ }
-+ else if(conn->http_negotiate_state != GSS_AUTHNONE) {
-+ /* Connection is using Negotiate auth but we do not want Negotiate */
-+ return FALSE;
-+ }
-+
-+#ifndef CURL_DISABLE_PROXY
-+ /* Same for Proxy Negotiate authentication */
-+ if(m->want_proxy_nego_http) {
-+ /* Both conn->http_proxy.user and conn->http_proxy.passwd can be
-+ * NULL */
-+ if(!conn->http_proxy.user || !conn->http_proxy.passwd)
-+ return FALSE;
-+
-+ if(Curl_timestrcmp(m->needle->http_proxy.user,
-+ conn->http_proxy.user) ||
-+ Curl_timestrcmp(m->needle->http_proxy.passwd,
-+ conn->http_proxy.passwd))
-+ return FALSE;
-+ }
-+ else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
-+ /* Proxy connection is using Negotiate auth but we do not want Negotiate */
-+ return FALSE;
-+ }
-+#endif
-+ if(m->want_nego_http || m->want_proxy_nego_http) {
-+ /* Credentials are already checked, we may use this connection. We MUST
-+ * use a connection where it has already been fully negotiated. If it has
-+ * not, we keep on looking for a better one. */
-+ m->found = conn;
-+ if((m->want_nego_http &&
-+ (conn->http_negotiate_state != GSS_AUTHNONE)) ||
-+ (m->want_proxy_nego_http &&
-+ (conn->proxy_negotiate_state != GSS_AUTHNONE))) {
-+ /* We must use this connection, no other */
-+ m->force_reuse = TRUE;
-+ return TRUE;
-+ }
-+ return FALSE; /* get another */
-+ }
-+ return TRUE;
-+}
-+#else
-+#define url_match_auth_nego(c, m) ((void)c, (void)m, TRUE)
-+#endif
-+
- static bool url_match_conn(struct connectdata *conn, void *userdata)
- {
- struct url_conn_match *m = userdata;
-@@ -1209,6 +1268,11 @@ static bool url_match_conn(struct connectdata *conn, void *userdata)
- else if(m->force_reuse)
- return TRUE;
-
-+ if(!url_match_auth_nego(conn, m))
-+ return FALSE;
-+ else if(m->force_reuse)
-+ return TRUE;
-+
- if(!url_match_multiplex_limits(conn, m))
- return FALSE;
-
-@@ -1274,13 +1338,26 @@ static bool ConnectionExists(struct Curl_easy *data,
- match.may_multiplex = xfer_may_multiplex(data, needle);
-
- #ifdef USE_NTLM
-- match.want_ntlm_http = ((data->state.authhost.want & CURLAUTH_NTLM) &&
-- (needle->handler->protocol & PROTO_FAMILY_HTTP));
-+ match.want_ntlm_http =
-+ (data->state.authhost.want & CURLAUTH_NTLM) &&
-+ (needle->handler->protocol & PROTO_FAMILY_HTTP);
- #ifndef CURL_DISABLE_PROXY
- match.want_proxy_ntlm_http =
-- (needle->bits.proxy_user_passwd &&
-- (data->state.authproxy.want & CURLAUTH_NTLM) &&
-- (needle->handler->protocol & PROTO_FAMILY_HTTP));
-+ needle->bits.proxy_user_passwd &&
-+ (data->state.authproxy.want & CURLAUTH_NTLM) &&
-+ (needle->handler->protocol & PROTO_FAMILY_HTTP);
-+#endif
-+#endif
-+
-+#if !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)
-+ match.want_nego_http =
-+ (data->state.authhost.want & CURLAUTH_NEGOTIATE) &&
-+ (needle->handler->protocol & PROTO_FAMILY_HTTP);
-+#ifndef CURL_DISABLE_PROXY
-+ match.want_proxy_nego_http =
-+ needle->bits.proxy_user_passwd &&
-+ (data->state.authproxy.want & CURLAUTH_NEGOTIATE) &&
-+ (needle->handler->protocol & PROTO_FAMILY_HTTP);
- #endif
- #endif
-
-diff --git a/tests/server/sws.c b/tests/server/sws.c
-index 1234567890..abcdef1234 100644
---- a/tests/server/sws.c
-+++ b/tests/server/sws.c
-@@ -2416,6 +2416,7 @@ static int test_sws(int argc, const char *argv[])
- if(req->connmon) {
- const char *keepopen = "[DISCONNECT]\n";
- sws_storerequest(keepopen, strlen(keepopen));
-+ req->connmon = FALSE;
- }
-
- if(!req->open)
---
-2.53.0
-
diff --git a/0003-openssl-channel_binding-lookup-digest-algorithm-with.patch b/0003-openssl-channel_binding-lookup-digest-algorithm-with.patch
new file mode 100644
index 0000000..9cf7583
--- /dev/null
+++ b/0003-openssl-channel_binding-lookup-digest-algorithm-with.patch
@@ -0,0 +1,161 @@
+From 573644eaff10d79e414608109cc14ca76b43f855 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Thu, 26 Feb 2026 10:21:31 +0100
+Subject: [PATCH] openssl channel_binding: lookup digest algorithm without NID
+
+Use an alternate OpenSSL API to get the digest algorithm tied
+to a certificate signature to compute the channel binding.
+
+Fixes #20590
+Reported-by: Rob Crittenden
+Closes #20734
+
+(cherry picked from commit b0f6e9a3d7be02e8f2e323aa97f2ff9b30662b32)
+---
+ lib/vtls/openssl.c | 97 +++++++++++++++++++++++++++++++++++++++-------
+ 1 file changed, 82 insertions(+), 15 deletions(-)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 84e6eaadd5..ebe583154f 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -5235,13 +5235,15 @@ out:
+ return result;
+ }
+
+-static CURLcode ossl_get_channel_binding(struct Curl_easy *data, int sockindex,
++static CURLcode ossl_get_channel_binding(struct Curl_easy *data,
++ int sockindex,
+ struct dynbuf *binding)
+ {
+ X509 *cert;
+- int algo_nid;
+- const EVP_MD *algo_type;
+- const char *algo_name;
++ int mdnid;
++ bool no_digest_acceptable = FALSE;
++ const EVP_MD *algo_type = NULL;
++ const char *algo_name = NULL;
+ unsigned int length;
+ unsigned char buf[EVP_MAX_MD_SIZE];
+
+@@ -5273,43 +5275,108 @@ static CURLcode ossl_get_channel_binding(struct Curl_easy *data, int sockindex,
+ /* No server certificate, do not do channel binding */
+ return CURLE_OK;
+
+- if(!OBJ_find_sigid_algs(X509_get_signature_nid(cert), &algo_nid, NULL)) {
++#ifdef HAVE_OPENSSL3
++ {
++ int pknid, secbits;
++ uint32_t flags;
++ EVP_PKEY *pkey = X509_get0_pubkey(cert);
++
++ if(!X509_get_signature_info(cert, &mdnid, &pknid, &secbits, &flags)) {
++ failf(data, "certificate signature algorithm not recognized");
++ result = CURLE_SSL_INVALIDCERTSTATUS;
++ goto out;
++ }
++
++ if(mdnid != NID_undef) {
++ if(mdnid == NID_md5 || mdnid == NID_sha1) {
++ algo_type = EVP_sha256();
++ }
++ else
++ algo_type = EVP_get_digestbynid(mdnid);
++ }
++ else if(pkey && !EVP_PKEY_is_a(pkey, OBJ_nid2sn(pknid))) {
++ /* The cert's pkey is different from the algorithm used to sign
++ * the certificate. Since the reported `mdnid` is undefined, there
++ * is no digest algorithm available here. This happens in PQC
++ * and is accepted, resulting in no addition to the binding. */
++ no_digest_acceptable = TRUE;
++ }
++ else if(pkey) {
++ /* cert's pkey type is the same as the cert signer (or same family).
++ * Ask for the mandatory/advisory digest algorithm for the pkey.
++ */
++ char mdname[128] = "";
++ int rc = EVP_PKEY_get_default_digest_name(pkey, mdname, sizeof(mdname));
++ bool md_is_undef = !strcmp(mdname, "UNDEF");
++
++ if(rc == 2 && md_is_undef) {
++ /* OpenSSL declares "undef" the *mandatory* digest for this key.
++ * This is some PQC shit, accept it, no addition to binding. */
++ no_digest_acceptable = TRUE;
++ }
++ else if(rc > 0 && mdname[0] != '\0' && !md_is_undef) {
++ infof(data, "Digest algorithm : %s%s (derived from public key)"
++ ", but unavailable",
++ mdname, rc == 2 ? " [mandatory]" : " [advisory]");
++ }
++ }
++ }
++#else /* HAVE_OPENSSL3 */
++
++ if(!OBJ_find_sigid_algs(X509_get_signature_nid(cert), &mdnid, NULL)) {
+ failf(data,
+ "Unable to find digest NID for certificate signature algorithm");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+- goto error;
++ goto out;
+ }
+
+ /* https://datatracker.ietf.org/doc/html/rfc5929#section-4.1 */
+- if(algo_nid == NID_md5 || algo_nid == NID_sha1) {
++ if(mdnid == NID_md5 || mdnid == NID_sha1) {
+ algo_type = EVP_sha256();
+ }
+ else {
+- algo_type = EVP_get_digestbynid(algo_nid);
++ algo_type = EVP_get_digestbynid(mdnid);
+ if(!algo_type) {
+- algo_name = OBJ_nid2sn(algo_nid);
++ algo_name = OBJ_nid2sn(mdnid);
+ failf(data, "Could not find digest algorithm %s (NID %d)",
+- algo_name ? algo_name : "(null)", algo_nid);
++ algo_name ? algo_name : "(null)", mdnid);
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+- goto error;
++ goto out;
++ }
++ }
++
++#endif /* HAVE_OPENSSL3, else */
++
++ if(!algo_type) {
++ if(no_digest_acceptable) {
++ infof(data, "certificate exposes no signing digest algorithm, "
++ "nothing to add to channel binding");
++ result = CURLE_OK;
++ goto out;
+ }
++ /* unacceptable, something is wrong, fail */
++ algo_name = OBJ_nid2sn(mdnid);
++ failf(data, "Unable to find digest algorithm %s (NID %d) "
++ "for channel binding", algo_name ? algo_name : "(null)", mdnid);
++ result = CURLE_SSL_INVALIDCERTSTATUS;
++ goto out;
+ }
+
+ if(!X509_digest(cert, algo_type, buf, &length)) {
+- failf(data, "X509_digest() failed");
++ failf(data, "X509_digest() failed for channel binding");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+- goto error;
++ goto out;
+ }
+
+ /* Append "tls-server-end-point:" */
+ result = curlx_dyn_addn(binding, prefix, sizeof(prefix) - 1);
+ if(result)
+- goto error;
++ goto out;
+
+ /* Append digest */
+ result = curlx_dyn_addn(binding, buf, length);
+
+-error:
++out:
+ X509_free(cert);
+ return result;
+ }
diff --git a/0004-CVE-2026-1965.patch b/0004-CVE-2026-1965.patch
new file mode 100644
index 0000000..94f17bf
--- /dev/null
+++ b/0004-CVE-2026-1965.patch
@@ -0,0 +1,163 @@
+From fd009f4e795cc25c5f82ba4a0bc372d3e6842737 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Thu, 5 Feb 2026 08:34:21 +0100
+Subject: [PATCH] CVE-2026-1965
+
+url: fix reuse of connections using HTTP Negotiate
+
+Assume Negotiate means connection-based
+
+Reported-by: Zhicheng Chen
+Closes #20534
+
+(cherry picked from commit 34fa034d9a390c4bd65e2d05262755ec8646ac12)
+
+url: fix copy and paste url_match_auth_nego mistake
+
+Follow-up to 34fa034
+Reported-by: dahmono on github
+Closes #20662
+
+(cherry picked from commit f1a39f221d57354990e3eeeddc3404aede2aff70)
+
+sws: prevent "connection monitor" to say disconnect twice
+
+(cherry picked from commit 510fdad64df7f91f605b19ffdb0c4c67891f1518)
+---
+ lib/url.c | 87 +++++++++++++++++++++++++++++++++++++++++++---
+ tests/server/sws.c | 1 +
+ 2 files changed, 83 insertions(+), 5 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 130be1952c..3a1fc5588d 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -759,6 +759,8 @@ struct url_conn_match {
+ BIT(may_multiplex);
+ BIT(want_ntlm_http);
+ BIT(want_proxy_ntlm_http);
++ BIT(want_nego_http);
++ BIT(want_proxy_nego_http);
+
+ BIT(wait_pipe);
+ BIT(force_reuse);
+@@ -1181,6 +1183,63 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
+ #define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE)
+ #endif
+
++#ifdef USE_SPNEGO
++static bool url_match_auth_nego(struct connectdata *conn,
++ struct url_conn_match *m)
++{
++ /* If we are looking for an HTTP+Negotiate connection, check if this is
++ already authenticating with the right credentials. If not, keep looking
++ so that we can reuse Negotiate connections if possible. */
++ if(m->want_nego_http) {
++ if(Curl_timestrcmp(m->needle->user, conn->user) ||
++ Curl_timestrcmp(m->needle->passwd, conn->passwd))
++ return FALSE;
++ }
++ else if(conn->http_negotiate_state != GSS_AUTHNONE) {
++ /* Connection is using Negotiate auth but we do not want Negotiate */
++ return FALSE;
++ }
++
++#ifndef CURL_DISABLE_PROXY
++ /* Same for Proxy Negotiate authentication */
++ if(m->want_proxy_nego_http) {
++ /* Both conn->http_proxy.user and conn->http_proxy.passwd can be
++ * NULL */
++ if(!conn->http_proxy.user || !conn->http_proxy.passwd)
++ return FALSE;
++
++ if(Curl_timestrcmp(m->needle->http_proxy.user,
++ conn->http_proxy.user) ||
++ Curl_timestrcmp(m->needle->http_proxy.passwd,
++ conn->http_proxy.passwd))
++ return FALSE;
++ }
++ else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
++ /* Proxy connection is using Negotiate auth but we do not want Negotiate */
++ return FALSE;
++ }
++#endif
++ if(m->want_nego_http || m->want_proxy_nego_http) {
++ /* Credentials are already checked, we may use this connection. We MUST
++ * use a connection where it has already been fully negotiated. If it has
++ * not, we keep on looking for a better one. */
++ m->found = conn;
++ if((m->want_nego_http &&
++ (conn->http_negotiate_state != GSS_AUTHNONE)) ||
++ (m->want_proxy_nego_http &&
++ (conn->proxy_negotiate_state != GSS_AUTHNONE))) {
++ /* We must use this connection, no other */
++ m->force_reuse = TRUE;
++ return TRUE;
++ }
++ return FALSE; /* get another */
++ }
++ return TRUE;
++}
++#else
++#define url_match_auth_nego(c, m) ((void)c, (void)m, TRUE)
++#endif
++
+ static bool url_match_conn(struct connectdata *conn, void *userdata)
+ {
+ struct url_conn_match *m = userdata;
+@@ -1224,6 +1283,11 @@ static bool url_match_conn(struct connectdata *conn, void *userdata)
+ else if(m->force_reuse)
+ return TRUE;
+
++ if(!url_match_auth_nego(conn, m))
++ return FALSE;
++ else if(m->force_reuse)
++ return TRUE;
++
+ if(!url_match_multiplex_limits(conn, m))
+ return FALSE;
+
+@@ -1289,13 +1353,26 @@ static bool ConnectionExists(struct Curl_easy *data,
+ match.may_multiplex = xfer_may_multiplex(data, needle);
+
+ #ifdef USE_NTLM
+- match.want_ntlm_http = ((data->state.authhost.want & CURLAUTH_NTLM) &&
+- (needle->handler->protocol & PROTO_FAMILY_HTTP));
++ match.want_ntlm_http =
++ (data->state.authhost.want & CURLAUTH_NTLM) &&
++ (needle->handler->protocol & PROTO_FAMILY_HTTP);
+ #ifndef CURL_DISABLE_PROXY
+ match.want_proxy_ntlm_http =
+- (needle->bits.proxy_user_passwd &&
+- (data->state.authproxy.want & CURLAUTH_NTLM) &&
+- (needle->handler->protocol & PROTO_FAMILY_HTTP));
++ needle->bits.proxy_user_passwd &&
++ (data->state.authproxy.want & CURLAUTH_NTLM) &&
++ (needle->handler->protocol & PROTO_FAMILY_HTTP);
++#endif
++#endif
++
++#if !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)
++ match.want_nego_http =
++ (data->state.authhost.want & CURLAUTH_NEGOTIATE) &&
++ (needle->handler->protocol & PROTO_FAMILY_HTTP);
++#ifndef CURL_DISABLE_PROXY
++ match.want_proxy_nego_http =
++ needle->bits.proxy_user_passwd &&
++ (data->state.authproxy.want & CURLAUTH_NEGOTIATE) &&
++ (needle->handler->protocol & PROTO_FAMILY_HTTP);
+ #endif
+ #endif
+
+diff --git a/tests/server/sws.c b/tests/server/sws.c
+index de0f096d46..9eade9e25f 100644
+--- a/tests/server/sws.c
++++ b/tests/server/sws.c
+@@ -2416,6 +2416,7 @@ static int test_sws(int argc, char *argv[])
+ if(req->connmon) {
+ const char *keepopen = "[DISCONNECT]\n";
+ sws_storerequest(keepopen, strlen(keepopen));
++ req->connmon = FALSE;
+ }
+
+ if(!req->open)
diff --git a/0004-curl-8.18.0-CVE-2026-3783.patch b/0004-curl-8.18.0-CVE-2026-3783.patch
deleted file mode 100644
index 5e3c08b..0000000
--- a/0004-curl-8.18.0-CVE-2026-3783.patch
+++ /dev/null
@@ -1,155 +0,0 @@
-From 77f7a96fbba9f6c6e922a114df72e353c037020c Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Fri, 6 Mar 2026 23:13:07 +0100
-Subject: [PATCH 3/4] CVE-2026-3783
-
-http: only send bearer if auth is allowed
-
-Verify with test 2006
-
-Closes #20843
-
-(cherry picked from commit e3d7401a32a46516c9e5ee877e613e62ed35bddc)
----
- lib/http.c | 5 ++-
- tests/data/Makefile.am | 2 +-
- tests/data/test2006 | 98 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 102 insertions(+), 3 deletions(-)
- create mode 100644 tests/data/test2006
-
-diff --git a/lib/http.c b/lib/http.c
-index ce63dbc5b6..e429e2eacf 100644
---- a/lib/http.c
-+++ b/lib/http.c
-@@ -706,8 +706,9 @@ static CURLcode output_auth_headers(struct Curl_easy *data,
- #ifndef CURL_DISABLE_BEARER_AUTH
- if(authstatus->picked == CURLAUTH_BEARER) {
- /* Bearer */
-- if((!proxy && data->set.str[STRING_BEARER] &&
-- !Curl_checkheaders(data, STRCONST("Authorization")))) {
-+ if(!proxy && data->set.str[STRING_BEARER] &&
-+ Curl_auth_allowed_to_host(data) &&
-+ !Curl_checkheaders(data, STRCONST("Authorization"))) {
- auth = "Bearer";
- result = http_output_bearer(data);
- if(result)
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 26bf95df64..87977e64aa 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -241,7 +241,7 @@ test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
- test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
- test1978 test1979 test1980 test1981 \
- \
--test2000 test2001 test2002 test2003 test2004 test2005 \
-+test2000 test2001 test2002 test2003 test2004 test2005 test2006 \
- \
- test2023 \
- test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
-diff --git a/tests/data/test2006 b/tests/data/test2006
-new file mode 100644
-index 0000000000..200d30a7ce
---- /dev/null
-+++ b/tests/data/test2006
-@@ -0,0 +1,98 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+netrc
-+HTTP
-+</keywords>
-+</info>
-+# Server-side
-+<reply>
-+<data crlf="headers">
-+HTTP/1.1 301 Follow this you fool
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: test-server/fake
-+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-+ETag: "21025-dc7-39462498"
-+Accept-Ranges: bytes
-+Content-Length: 6
-+Connection: close
-+Location: http://b.com/%TESTNUMBER0002
-+
-+-foo-
-+</data>
-+
-+<data2 crlf="headers">
-+HTTP/1.1 200 OK
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: test-server/fake
-+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-+ETag: "21025-dc7-39462498"
-+Accept-Ranges: bytes
-+Content-Length: 7
-+Connection: close
-+
-+target
-+</data2>
-+
-+<datacheck crlf="headers">
-+HTTP/1.1 301 Follow this you fool
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: test-server/fake
-+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-+ETag: "21025-dc7-39462498"
-+Accept-Ranges: bytes
-+Content-Length: 6
-+Connection: close
-+Location: http://b.com/%TESTNUMBER0002
-+
-+HTTP/1.1 200 OK
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: test-server/fake
-+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-+ETag: "21025-dc7-39462498"
-+Accept-Ranges: bytes
-+Content-Length: 7
-+Connection: close
-+
-+target
-+</datacheck>
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+<features>
-+proxy
-+</features>
-+<name>
-+.netrc default with redirect plus oauth2-bearer
-+</name>
-+<command>
-+--netrc --netrc-file %LOGDIR/netrc%TESTNUMBER --oauth2-bearer SECRET_TOKEN -L -x http://%HOSTIP:%HTTPPORT/ http://a.com/
-+</command>
-+<file name="%LOGDIR/netrc%TESTNUMBER" >
-+default login testuser password testpass
-+</file>
-+</client>
-+
-+<verify>
-+<protocol crlf="headers">
-+GET http://a.com/ HTTP/1.1
-+Host: a.com
-+Authorization: Bearer SECRET_TOKEN
-+User-Agent: curl/%VERSION
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://b.com/%TESTNUMBER0002 HTTP/1.1
-+Host: b.com
-+User-Agent: curl/%VERSION
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+</protocol>
-+</verify>
-+</testcase>
---
-2.53.0
-
diff --git a/0005-CVE-2026-3783.patch b/0005-CVE-2026-3783.patch
new file mode 100644
index 0000000..3dbd63f
--- /dev/null
+++ b/0005-CVE-2026-3783.patch
@@ -0,0 +1,152 @@
+From f6de3852772fdfc22d998f104ff7e01589cc42b1 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Fri, 6 Mar 2026 23:13:07 +0100
+Subject: [PATCH] CVE-2026-3783
+
+http: only send bearer if auth is allowed
+
+Verify with test 2006
+
+Closes #20843
+
+(cherry picked from commit e3d7401a32a46516c9e5ee877e613e62ed35bddc)
+---
+ lib/http.c | 5 ++-
+ tests/data/Makefile.am | 2 +-
+ tests/data/test2006 | 98 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 102 insertions(+), 3 deletions(-)
+ create mode 100644 tests/data/test2006
+
+diff --git a/lib/http.c b/lib/http.c
+index a78e2f666b..5efa6a196e 100644
+--- a/lib/http.c
++++ b/lib/http.c
+@@ -724,8 +724,9 @@ static CURLcode output_auth_headers(struct Curl_easy *data,
+ #ifndef CURL_DISABLE_BEARER_AUTH
+ if(authstatus->picked == CURLAUTH_BEARER) {
+ /* Bearer */
+- if((!proxy && data->set.str[STRING_BEARER] &&
+- !Curl_checkheaders(data, STRCONST("Authorization")))) {
++ if(!proxy && data->set.str[STRING_BEARER] &&
++ Curl_auth_allowed_to_host(data) &&
++ !Curl_checkheaders(data, STRCONST("Authorization"))) {
+ auth = "Bearer";
+ result = http_output_bearer(data);
+ if(result)
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 6475055e1e..dce222c054 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -241,7 +241,7 @@ test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
+ test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
+ test1978 test1979 test1980 test1981 \
+ \
+-test2000 test2001 test2002 test2003 test2004 test2005 \
++test2000 test2001 test2002 test2003 test2004 test2005 test2006 \
+ \
+ test2023 \
+ test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
+diff --git a/tests/data/test2006 b/tests/data/test2006
+new file mode 100644
+index 0000000000..200d30a7ce
+--- /dev/null
++++ b/tests/data/test2006
+@@ -0,0 +1,98 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++netrc
++HTTP
++</keywords>
++</info>
++# Server-side
++<reply>
++<data crlf="headers">
++HTTP/1.1 301 Follow this you fool
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: test-server/fake
++Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
++ETag: "21025-dc7-39462498"
++Accept-Ranges: bytes
++Content-Length: 6
++Connection: close
++Location: http://b.com/%TESTNUMBER0002
++
++-foo-
++</data>
++
++<data2 crlf="headers">
++HTTP/1.1 200 OK
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: test-server/fake
++Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
++ETag: "21025-dc7-39462498"
++Accept-Ranges: bytes
++Content-Length: 7
++Connection: close
++
++target
++</data2>
++
++<datacheck crlf="headers">
++HTTP/1.1 301 Follow this you fool
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: test-server/fake
++Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
++ETag: "21025-dc7-39462498"
++Accept-Ranges: bytes
++Content-Length: 6
++Connection: close
++Location: http://b.com/%TESTNUMBER0002
++
++HTTP/1.1 200 OK
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: test-server/fake
++Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
++ETag: "21025-dc7-39462498"
++Accept-Ranges: bytes
++Content-Length: 7
++Connection: close
++
++target
++</datacheck>
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++<features>
++proxy
++</features>
++<name>
++.netrc default with redirect plus oauth2-bearer
++</name>
++<command>
++--netrc --netrc-file %LOGDIR/netrc%TESTNUMBER --oauth2-bearer SECRET_TOKEN -L -x http://%HOSTIP:%HTTPPORT/ http://a.com/
++</command>
++<file name="%LOGDIR/netrc%TESTNUMBER" >
++default login testuser password testpass
++</file>
++</client>
++
++<verify>
++<protocol crlf="headers">
++GET http://a.com/ HTTP/1.1
++Host: a.com
++Authorization: Bearer SECRET_TOKEN
++User-Agent: curl/%VERSION
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://b.com/%TESTNUMBER0002 HTTP/1.1
++Host: b.com
++User-Agent: curl/%VERSION
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++</protocol>
++</verify>
++</testcase>
diff --git a/0005-curl-8.18.0-CVE-2026-3784.patch b/0005-curl-8.18.0-CVE-2026-3784.patch
deleted file mode 100644
index b68dcd7..0000000
--- a/0005-curl-8.18.0-CVE-2026-3784.patch
+++ /dev/null
@@ -1,168 +0,0 @@
-From 8f071cbd38cbc8116658122a3703cb67960c114a Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 6 Mar 2026 14:54:09 +0100
-Subject: [PATCH 2/4] CVE-2026-3784
-
-proxy-auth: additional tests
-
-Also eliminate the special handling for socks proxy match.
-
-Closes #20837
-
-(cherry picked from commit 5f13a7645e565c5c1a06f3ef86e97afb856fb364)
----
- lib/url.c | 29 +++++++----------------------
- tests/http/test_13_proxy_auth.py | 20 ++++++++++++++++++++
- tests/http/testenv/curl.py | 18 +++++++++++++++---
- 3 files changed, 42 insertions(+), 25 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index 130be1952c..fee9aa3a6f 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -590,33 +590,18 @@ static bool proxy_info_matches(const struct proxy_info *data,
- {
- if((data->proxytype == needle->proxytype) &&
- (data->port == needle->port) &&
-- curl_strequal(data->host.name, needle->host.name))
-- return TRUE;
-+ curl_strequal(data->host.name, needle->host.name)) {
-
-+ if(Curl_timestrcmp(data->user, needle->user) ||
-+ Curl_timestrcmp(data->passwd, needle->passwd))
-+ return FALSE;
-+ return TRUE;
-+ }
- return FALSE;
- }
--
--static bool socks_proxy_info_matches(const struct proxy_info *data,
-- const struct proxy_info *needle)
--{
-- if(!proxy_info_matches(data, needle))
-- return FALSE;
--
-- /* the user information is case-sensitive
-- or at least it is not defined as case-insensitive
-- see https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1 */
--
-- /* curl_strequal does a case insensitive comparison,
-- so do not use it here! */
-- if(Curl_timestrcmp(data->user, needle->user) ||
-- Curl_timestrcmp(data->passwd, needle->passwd))
-- return FALSE;
-- return TRUE;
--}
- #else
- /* disabled, will not get called */
- #define proxy_info_matches(x, y) FALSE
--#define socks_proxy_info_matches(x, y) FALSE
- #endif
-
- /* A connection has to have been idle for less than 'conn_max_idle_ms'
-@@ -923,7 +908,7 @@ static bool url_match_proxy_use(struct connectdata *conn,
- return FALSE;
-
- if(m->needle->bits.socksproxy &&
-- !socks_proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
-+ !proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
- return FALSE;
-
- if(m->needle->bits.httpproxy) {
-diff --git a/tests/http/test_13_proxy_auth.py b/tests/http/test_13_proxy_auth.py
-index 080adef187..33fb211e99 100644
---- a/tests/http/test_13_proxy_auth.py
-+++ b/tests/http/test_13_proxy_auth.py
-@@ -169,3 +169,23 @@ class TestProxyAuth:
- '--negotiate', '--proxy-user', 'proxy:proxy'
- ])
- r1.check_response(count=1, http_status=200)
-+
-+ def test_13_10_tunnels_mixed_auth(self, env: Env, httpd, configures_httpd):
-+ self.httpd_configure(env, httpd)
-+ curl = CurlClient(env=env)
-+ url1 = f'http://localhost:{env.http_port}/data.json?1'
-+ url2 = f'http://localhost:{env.http_port}/data.json?2'
-+ url3 = f'http://localhost:{env.http_port}/data.json?3'
-+ xargs1 = curl.get_proxy_args(proxys=False, tunnel=True)
-+ xargs1.extend(['--proxy-user', 'proxy:proxy']) # good auth
-+ xargs2 = curl.get_proxy_args(proxys=False, tunnel=True)
-+ xargs2.extend(['--proxy-user', 'ungood:ungood']) # bad auth
-+ xargs3 = curl.get_proxy_args(proxys=False, tunnel=True)
-+ # no auth
-+ r = curl.http_download(urls=[url1, url2, url3], alpn_proto='http/1.1', with_stats=True,
-+ url_options={url1: xargs1, url2: xargs2, url3: xargs3})
-+ # only url1 succeeds, others fail, no connection reuse
-+ assert r.stats[0]['http_code'] == 200, f'{r.dump_logs()}'
-+ assert r.stats[1]['http_code'] == 0, f'{r.dump_logs()}'
-+ assert r.stats[2]['http_code'] == 0, f'{r.dump_logs()}'
-+ assert r.total_connects == 3, f'{r.dump_logs()}'
-diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py
-index 07430d000b..fd13936142 100644
---- a/tests/http/testenv/curl.py
-+++ b/tests/http/testenv/curl.py
-@@ -724,7 +724,8 @@ class CurlClient:
- with_tcpdump: bool = False,
- no_save: bool = False,
- limit_rate: Optional[str] = None,
-- extra_args: Optional[List[str]] = None):
-+ extra_args: Optional[List[str]] = None,
-+ url_options: Optional[Dict[str,List[str]]] = None):
- if extra_args is None:
- extra_args = []
- if no_save:
-@@ -742,6 +743,7 @@ class CurlClient:
- ])
- return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
- with_stats=with_stats,
-+ url_options=url_options,
- with_headers=with_headers,
- with_profile=with_profile,
- with_tcpdump=with_tcpdump)
-@@ -1083,6 +1085,7 @@ class CurlClient:
-
- def _raw(self, urls, intext='', timeout=None, options=None, insecure=False,
- alpn_proto: Optional[str] = None,
-+ url_options=None,
- force_resolve=True,
- with_stats=False,
- with_headers=True,
-@@ -1092,7 +1095,8 @@ class CurlClient:
- args = self._complete_args(
- urls=urls, timeout=timeout, options=options, insecure=insecure,
- alpn_proto=alpn_proto, force_resolve=force_resolve,
-- with_headers=with_headers, def_tracing=def_tracing)
-+ with_headers=with_headers, def_tracing=def_tracing,
-+ url_options=url_options)
- r = self._run(args, intext=intext, with_stats=with_stats,
- with_profile=with_profile, with_tcpdump=with_tcpdump)
- if r.exit_code == 0 and with_headers:
-@@ -1102,8 +1106,10 @@ class CurlClient:
- def _complete_args(self, urls, timeout=None, options=None,
- insecure=False, force_resolve=True,
- alpn_proto: Optional[str] = None,
-+ url_options=None,
- with_headers: bool = True,
- def_tracing: bool = True):
-+ url_sep = []
- if not isinstance(urls, list):
- urls = [urls]
-
-@@ -1129,7 +1135,13 @@ class CurlClient:
- active_options = options[options.index('--next') + 1:]
-
- for url in urls:
-- u = urlparse(urls[0])
-+ args.extend(url_sep)
-+ if url_options is not None:
-+ url_sep = ['--next']
-+
-+ u = urlparse(url)
-+ if url_options is not None and url in url_options:
-+ args.extend(url_options[url])
- if options:
- args.extend(options)
- if alpn_proto is not None:
---
-2.53.0
-
diff --git a/0006-CVE-2026-3784.patch b/0006-CVE-2026-3784.patch
new file mode 100644
index 0000000..4f74cb6
--- /dev/null
+++ b/0006-CVE-2026-3784.patch
@@ -0,0 +1,165 @@
+From 00798d50b32ee5b39d0559e414575ba36222e91a Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Fri, 6 Mar 2026 14:54:09 +0100
+Subject: [PATCH] CVE-2026-3784
+
+proxy-auth: additional tests
+
+Also eliminate the special handling for socks proxy match.
+
+Closes #20837
+
+(cherry picked from commit 5f13a7645e565c5c1a06f3ef86e97afb856fb364)
+---
+ lib/url.c | 29 +++++++----------------------
+ tests/http/test_13_proxy_auth.py | 20 ++++++++++++++++++++
+ tests/http/testenv/curl.py | 18 +++++++++++++++---
+ 3 files changed, 42 insertions(+), 25 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 3a1fc5588d..5a75fe71da 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -590,33 +590,18 @@ static bool proxy_info_matches(const struct proxy_info *data,
+ {
+ if((data->proxytype == needle->proxytype) &&
+ (data->port == needle->port) &&
+- curl_strequal(data->host.name, needle->host.name))
+- return TRUE;
++ curl_strequal(data->host.name, needle->host.name)) {
+
++ if(Curl_timestrcmp(data->user, needle->user) ||
++ Curl_timestrcmp(data->passwd, needle->passwd))
++ return FALSE;
++ return TRUE;
++ }
+ return FALSE;
+ }
+-
+-static bool socks_proxy_info_matches(const struct proxy_info *data,
+- const struct proxy_info *needle)
+-{
+- if(!proxy_info_matches(data, needle))
+- return FALSE;
+-
+- /* the user information is case-sensitive
+- or at least it is not defined as case-insensitive
+- see https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1 */
+-
+- /* curl_strequal does a case insensitive comparison,
+- so do not use it here! */
+- if(Curl_timestrcmp(data->user, needle->user) ||
+- Curl_timestrcmp(data->passwd, needle->passwd))
+- return FALSE;
+- return TRUE;
+-}
+ #else
+ /* disabled, will not get called */
+ #define proxy_info_matches(x, y) FALSE
+-#define socks_proxy_info_matches(x, y) FALSE
+ #endif
+
+ /* A connection has to have been idle for less than 'conn_max_idle_ms'
+@@ -925,7 +910,7 @@ static bool url_match_proxy_use(struct connectdata *conn,
+ return FALSE;
+
+ if(m->needle->bits.socksproxy &&
+- !socks_proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
++ !proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
+ return FALSE;
+
+ if(m->needle->bits.httpproxy) {
+diff --git a/tests/http/test_13_proxy_auth.py b/tests/http/test_13_proxy_auth.py
+index 080adef187..33fb211e99 100644
+--- a/tests/http/test_13_proxy_auth.py
++++ b/tests/http/test_13_proxy_auth.py
+@@ -169,3 +169,23 @@ class TestProxyAuth:
+ '--negotiate', '--proxy-user', 'proxy:proxy'
+ ])
+ r1.check_response(count=1, http_status=200)
++
++ def test_13_10_tunnels_mixed_auth(self, env: Env, httpd, configures_httpd):
++ self.httpd_configure(env, httpd)
++ curl = CurlClient(env=env)
++ url1 = f'http://localhost:{env.http_port}/data.json?1'
++ url2 = f'http://localhost:{env.http_port}/data.json?2'
++ url3 = f'http://localhost:{env.http_port}/data.json?3'
++ xargs1 = curl.get_proxy_args(proxys=False, tunnel=True)
++ xargs1.extend(['--proxy-user', 'proxy:proxy']) # good auth
++ xargs2 = curl.get_proxy_args(proxys=False, tunnel=True)
++ xargs2.extend(['--proxy-user', 'ungood:ungood']) # bad auth
++ xargs3 = curl.get_proxy_args(proxys=False, tunnel=True)
++ # no auth
++ r = curl.http_download(urls=[url1, url2, url3], alpn_proto='http/1.1', with_stats=True,
++ url_options={url1: xargs1, url2: xargs2, url3: xargs3})
++ # only url1 succeeds, others fail, no connection reuse
++ assert r.stats[0]['http_code'] == 200, f'{r.dump_logs()}'
++ assert r.stats[1]['http_code'] == 0, f'{r.dump_logs()}'
++ assert r.stats[2]['http_code'] == 0, f'{r.dump_logs()}'
++ assert r.total_connects == 3, f'{r.dump_logs()}'
+diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py
+index 07430d000b..fd13936142 100644
+--- a/tests/http/testenv/curl.py
++++ b/tests/http/testenv/curl.py
+@@ -724,7 +724,8 @@ class CurlClient:
+ with_tcpdump: bool = False,
+ no_save: bool = False,
+ limit_rate: Optional[str] = None,
+- extra_args: Optional[List[str]] = None):
++ extra_args: Optional[List[str]] = None,
++ url_options: Optional[Dict[str,List[str]]] = None):
+ if extra_args is None:
+ extra_args = []
+ if no_save:
+@@ -742,6 +743,7 @@ class CurlClient:
+ ])
+ return self._raw(urls, alpn_proto=alpn_proto, options=extra_args,
+ with_stats=with_stats,
++ url_options=url_options,
+ with_headers=with_headers,
+ with_profile=with_profile,
+ with_tcpdump=with_tcpdump)
+@@ -1083,6 +1085,7 @@ class CurlClient:
+
+ def _raw(self, urls, intext='', timeout=None, options=None, insecure=False,
+ alpn_proto: Optional[str] = None,
++ url_options=None,
+ force_resolve=True,
+ with_stats=False,
+ with_headers=True,
+@@ -1092,7 +1095,8 @@ class CurlClient:
+ args = self._complete_args(
+ urls=urls, timeout=timeout, options=options, insecure=insecure,
+ alpn_proto=alpn_proto, force_resolve=force_resolve,
+- with_headers=with_headers, def_tracing=def_tracing)
++ with_headers=with_headers, def_tracing=def_tracing,
++ url_options=url_options)
+ r = self._run(args, intext=intext, with_stats=with_stats,
+ with_profile=with_profile, with_tcpdump=with_tcpdump)
+ if r.exit_code == 0 and with_headers:
+@@ -1102,8 +1106,10 @@ class CurlClient:
+ def _complete_args(self, urls, timeout=None, options=None,
+ insecure=False, force_resolve=True,
+ alpn_proto: Optional[str] = None,
++ url_options=None,
+ with_headers: bool = True,
+ def_tracing: bool = True):
++ url_sep = []
+ if not isinstance(urls, list):
+ urls = [urls]
+
+@@ -1129,7 +1135,13 @@ class CurlClient:
+ active_options = options[options.index('--next') + 1:]
+
+ for url in urls:
+- u = urlparse(urls[0])
++ args.extend(url_sep)
++ if url_options is not None:
++ url_sep = ['--next']
++
++ u = urlparse(url)
++ if url_options is not None and url in url_options:
++ args.extend(url_options[url])
+ if options:
+ args.extend(options)
+ if alpn_proto is not None:
diff --git a/0006-curl-8.18.0-CVE-2026-3805.patch b/0006-curl-8.18.0-CVE-2026-3805.patch
deleted file mode 100644
index 4ae5857..0000000
--- a/0006-curl-8.18.0-CVE-2026-3805.patch
+++ /dev/null
@@ -1,2287 +0,0 @@
-From a824bfa32cb325bbcb7059ed36f6ee00ed6557ad Mon Sep 17 00:00:00 2001
-From: Viktor Szakats <commit@vsz.me>
-Date: Sun, 21 Dec 2025 16:19:52 +0100
-Subject: [PATCH 1/4] CVE-2026-3805
-
-lib: reorder protocol functions to avoid forward declarations (misc)
-
-For protocols: dict, file, gopher, tftp, http, mqtt, smb.
-
-Move protocol hander table to the end of sources, rearrange static
-functions is reverse dependency order as necessary.
-
-Closes #20274
-
-(cherry picked from commit 07926b59828936117a7c6662f850bc09edb14357)
-
-smb: free the path in the request struct properly
-
-Closes #20854
-
-(cherry picked from commit e090be9f73a7a71459ef678c7cc4b1f75e3ea883)
-
-test1850: verify the SMB request path use for two transfers
-
-(cherry picked from commit 1f8cfa049d7a0ea595863abf0230198972873ad6)
----
- lib/dict.c | 64 ++--
- lib/file.c | 97 +++---
- lib/gopher.c | 125 ++++---
- lib/http.c | 616 +++++++++++++++++------------------
- lib/mqtt.c | 71 ++--
- lib/smb.c | 219 ++++++-------
- lib/tftp.c | 718 ++++++++++++++++++++---------------------
- tests/data/Makefile.am | 2 +-
- tests/data/test1850 | 39 +++
- 9 files changed, 948 insertions(+), 1003 deletions(-)
- create mode 100644 tests/data/test1850
-
-diff --git a/lib/dict.c b/lib/dict.c
-index 5839e804c2..54563b4e45 100644
---- a/lib/dict.c
-+++ b/lib/dict.c
-@@ -65,41 +65,6 @@
- #define DICT_DEFINE3 "/LOOKUP:"
-
-
--/*
-- * Forward declarations.
-- */
--
--static CURLcode dict_do(struct Curl_easy *data, bool *done);
--
--/*
-- * DICT protocol handler.
-- */
--
--const struct Curl_handler Curl_handler_dict = {
-- "dict", /* scheme */
-- ZERO_NULL, /* setup_connection */
-- dict_do, /* do_it */
-- ZERO_NULL, /* done */
-- ZERO_NULL, /* do_more */
-- ZERO_NULL, /* connect_it */
-- ZERO_NULL, /* connecting */
-- ZERO_NULL, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- ZERO_NULL, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_DICT, /* defport */
-- CURLPROTO_DICT, /* protocol */
-- CURLPROTO_DICT, /* family */
-- PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
--};
--
- #define DYN_DICT_WORD 10000
- static char *unescape_word(const char *input)
- {
-@@ -306,4 +271,33 @@ error:
- curlx_free(path);
- return result;
- }
-+
-+/*
-+ * DICT protocol handler.
-+ */
-+const struct Curl_handler Curl_handler_dict = {
-+ "dict", /* scheme */
-+ ZERO_NULL, /* setup_connection */
-+ dict_do, /* do_it */
-+ ZERO_NULL, /* done */
-+ ZERO_NULL, /* do_more */
-+ ZERO_NULL, /* connect_it */
-+ ZERO_NULL, /* connecting */
-+ ZERO_NULL, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ ZERO_NULL, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_DICT, /* defport */
-+ CURLPROTO_DICT, /* protocol */
-+ CURLPROTO_DICT, /* family */
-+ PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
-+};
-+
- #endif /* CURL_DISABLE_DICT */
-diff --git a/lib/file.c b/lib/file.c
-index 982f254b2d..9ba536bf2e 100644
---- a/lib/file.c
-+++ b/lib/file.c
-@@ -82,49 +82,6 @@ struct FILEPROTO {
- int fd; /* open file descriptor to read from! */
- };
-
--/*
-- * Forward declarations.
-- */
--
--static CURLcode file_do(struct Curl_easy *data, bool *done);
--static CURLcode file_done(struct Curl_easy *data,
-- CURLcode status, bool premature);
--static CURLcode file_connect(struct Curl_easy *data, bool *done);
--static CURLcode file_disconnect(struct Curl_easy *data,
-- struct connectdata *conn,
-- bool dead_connection);
--static CURLcode file_setup_connection(struct Curl_easy *data,
-- struct connectdata *conn);
--
--/*
-- * FILE scheme handler.
-- */
--
--const struct Curl_handler Curl_handler_file = {
-- "file", /* scheme */
-- file_setup_connection, /* setup_connection */
-- file_do, /* do_it */
-- file_done, /* done */
-- ZERO_NULL, /* do_more */
-- file_connect, /* connect_it */
-- ZERO_NULL, /* connecting */
-- ZERO_NULL, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- ZERO_NULL, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- file_disconnect, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- 0, /* defport */
-- CURLPROTO_FILE, /* protocol */
-- CURLPROTO_FILE, /* family */
-- PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
--};
--
- static void file_cleanup(struct FILEPROTO *file)
- {
- Curl_safefree(file->freepath);
-@@ -158,6 +115,19 @@ static CURLcode file_setup_connection(struct Curl_easy *data,
- return CURLE_OK;
- }
-
-+static CURLcode file_done(struct Curl_easy *data,
-+ CURLcode status, bool premature)
-+{
-+ struct FILEPROTO *file = Curl_meta_get(data, CURL_META_FILE_EASY);
-+ (void)status;
-+ (void)premature;
-+
-+ if(file)
-+ file_cleanup(file);
-+
-+ return CURLE_OK;
-+}
-+
- /*
- * file_connect() gets called from Curl_protocol_connect() to allow us to
- * do protocol-specific actions at connect-time. We emulate a
-@@ -276,19 +246,6 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
- return CURLE_OK;
- }
-
--static CURLcode file_done(struct Curl_easy *data,
-- CURLcode status, bool premature)
--{
-- struct FILEPROTO *file = Curl_meta_get(data, CURL_META_FILE_EASY);
-- (void)status;
-- (void)premature;
--
-- if(file)
-- file_cleanup(file);
--
-- return CURLE_OK;
--}
--
- static CURLcode file_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- bool dead_connection)
-@@ -648,4 +605,32 @@ out:
- return result;
- }
-
-+/*
-+ * FILE scheme handler.
-+ */
-+const struct Curl_handler Curl_handler_file = {
-+ "file", /* scheme */
-+ file_setup_connection, /* setup_connection */
-+ file_do, /* do_it */
-+ file_done, /* done */
-+ ZERO_NULL, /* do_more */
-+ file_connect, /* connect_it */
-+ ZERO_NULL, /* connecting */
-+ ZERO_NULL, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ ZERO_NULL, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ file_disconnect, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ 0, /* defport */
-+ CURLPROTO_FILE, /* protocol */
-+ CURLPROTO_FILE, /* family */
-+ PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
-+};
-+
- #endif
-diff --git a/lib/gopher.c b/lib/gopher.c
-index 186530de9f..9d35c68f31 100644
---- a/lib/gopher.c
-+++ b/lib/gopher.c
-@@ -36,73 +36,7 @@
- #include "url.h"
- #include "escape.h"
-
--/*
-- * Forward declarations.
-- */
--
--static CURLcode gopher_do(struct Curl_easy *data, bool *done);
- #ifdef USE_SSL
--static CURLcode gopher_connect(struct Curl_easy *data, bool *done);
--static CURLcode gopher_connecting(struct Curl_easy *data, bool *done);
--#endif
--
--/*
-- * Gopher protocol handler.
-- * This is also a nice simple template to build off for simple
-- * connect-command-download protocols.
-- */
--
--const struct Curl_handler Curl_handler_gopher = {
-- "gopher", /* scheme */
-- ZERO_NULL, /* setup_connection */
-- gopher_do, /* do_it */
-- ZERO_NULL, /* done */
-- ZERO_NULL, /* do_more */
-- ZERO_NULL, /* connect_it */
-- ZERO_NULL, /* connecting */
-- ZERO_NULL, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- ZERO_NULL, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_GOPHER, /* defport */
-- CURLPROTO_GOPHER, /* protocol */
-- CURLPROTO_GOPHER, /* family */
-- PROTOPT_NONE /* flags */
--};
--
--#ifdef USE_SSL
--const struct Curl_handler Curl_handler_gophers = {
-- "gophers", /* scheme */
-- ZERO_NULL, /* setup_connection */
-- gopher_do, /* do_it */
-- ZERO_NULL, /* done */
-- ZERO_NULL, /* do_more */
-- gopher_connect, /* connect_it */
-- gopher_connecting, /* connecting */
-- ZERO_NULL, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- ZERO_NULL, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_GOPHER, /* defport */
-- CURLPROTO_GOPHERS, /* protocol */
-- CURLPROTO_GOPHER, /* family */
-- PROTOPT_SSL /* flags */
--};
--
- static CURLcode gopher_connect(struct Curl_easy *data, bool *done)
- {
- (void)data;
-@@ -231,4 +165,63 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
- Curl_xfer_setup_recv(data, FIRSTSOCKET, -1);
- return CURLE_OK;
- }
-+
-+/*
-+ * Gopher protocol handler.
-+ * This is also a nice simple template to build off for simple
-+ * connect-command-download protocols.
-+ */
-+
-+const struct Curl_handler Curl_handler_gopher = {
-+ "gopher", /* scheme */
-+ ZERO_NULL, /* setup_connection */
-+ gopher_do, /* do_it */
-+ ZERO_NULL, /* done */
-+ ZERO_NULL, /* do_more */
-+ ZERO_NULL, /* connect_it */
-+ ZERO_NULL, /* connecting */
-+ ZERO_NULL, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ ZERO_NULL, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_GOPHER, /* defport */
-+ CURLPROTO_GOPHER, /* protocol */
-+ CURLPROTO_GOPHER, /* family */
-+ PROTOPT_NONE /* flags */
-+};
-+
-+#ifdef USE_SSL
-+const struct Curl_handler Curl_handler_gophers = {
-+ "gophers", /* scheme */
-+ ZERO_NULL, /* setup_connection */
-+ gopher_do, /* do_it */
-+ ZERO_NULL, /* done */
-+ ZERO_NULL, /* do_more */
-+ gopher_connect, /* connect_it */
-+ gopher_connecting, /* connecting */
-+ ZERO_NULL, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ ZERO_NULL, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_GOPHER, /* defport */
-+ CURLPROTO_GOPHERS, /* protocol */
-+ CURLPROTO_GOPHER, /* family */
-+ PROTOPT_SSL /* flags */
-+};
-+#endif
-+
- #endif /* CURL_DISABLE_GOPHER */
-diff --git a/lib/http.c b/lib/http.c
-index a78e2f666b..ce63dbc5b6 100644
---- a/lib/http.c
-+++ b/lib/http.c
-@@ -85,94 +85,6 @@
- #include "bufref.h"
- #include "curlx/strparse.h"
-
--/*
-- * Forward declarations.
-- */
--
--static bool http_should_fail(struct Curl_easy *data, int httpcode);
--static bool http_exp100_is_waiting(struct Curl_easy *data);
--static CURLcode http_exp100_add_reader(struct Curl_easy *data);
--static void http_exp100_send_anyway(struct Curl_easy *data);
--static bool http_exp100_is_selected(struct Curl_easy *data);
--static void http_exp100_got100(struct Curl_easy *data);
--static CURLcode http_firstwrite(struct Curl_easy *data);
--static CURLcode http_header(struct Curl_easy *data,
-- const char *hd, size_t hdlen);
--static CURLcode http_range(struct Curl_easy *data,
-- Curl_HttpReq httpreq);
--static CURLcode http_req_set_TE(struct Curl_easy *data,
-- struct dynbuf *req,
-- int httpversion);
--static CURLcode http_size(struct Curl_easy *data);
--static CURLcode http_statusline(struct Curl_easy *data,
-- struct connectdata *conn);
--static CURLcode http_target(struct Curl_easy *data, struct dynbuf *req);
--static CURLcode http_useragent(struct Curl_easy *data);
--static CURLcode http_write_header(struct Curl_easy *data,
-- const char *hd, size_t hdlen);
--
--/*
-- * HTTP handler interface.
-- */
--const struct Curl_handler Curl_handler_http = {
-- "http", /* scheme */
-- Curl_http_setup_conn, /* setup_connection */
-- Curl_http, /* do_it */
-- Curl_http_done, /* done */
-- ZERO_NULL, /* do_more */
-- ZERO_NULL, /* connect_it */
-- ZERO_NULL, /* connecting */
-- ZERO_NULL, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- Curl_http_doing_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- Curl_http_perform_pollset, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- Curl_http_write_resp, /* write_resp */
-- Curl_http_write_resp_hd, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- Curl_http_follow, /* follow */
-- PORT_HTTP, /* defport */
-- CURLPROTO_HTTP, /* protocol */
-- CURLPROTO_HTTP, /* family */
-- PROTOPT_CREDSPERREQUEST | /* flags */
-- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
--
--};
--
--#ifdef USE_SSL
--/*
-- * HTTPS handler interface.
-- */
--const struct Curl_handler Curl_handler_https = {
-- "https", /* scheme */
-- Curl_http_setup_conn, /* setup_connection */
-- Curl_http, /* do_it */
-- Curl_http_done, /* done */
-- ZERO_NULL, /* do_more */
-- ZERO_NULL, /* connect_it */
-- NULL, /* connecting */
-- ZERO_NULL, /* doing */
-- NULL, /* proto_pollset */
-- Curl_http_doing_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- Curl_http_perform_pollset, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- Curl_http_write_resp, /* write_resp */
-- Curl_http_write_resp_hd, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- Curl_http_follow, /* follow */
-- PORT_HTTPS, /* defport */
-- CURLPROTO_HTTPS, /* protocol */
-- CURLPROTO_HTTP, /* family */
-- PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
-- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
--};
--
--#endif
--
- void Curl_http_neg_init(struct Curl_easy *data, struct http_negotiation *neg)
- {
- memset(neg, 0, sizeof(*neg));
-@@ -547,13 +459,83 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
- return CURLE_OK;
- }
-
-+/**
-+ * http_should_fail() determines whether an HTTP response code has gotten us
-+ * into an error state or not.
-+ *
-+ * @retval FALSE communications should continue
-+ *
-+ * @retval TRUE communications should not continue
-+ */
-+static bool http_should_fail(struct Curl_easy *data, int httpcode)
-+{
-+ DEBUGASSERT(data);
-+ DEBUGASSERT(data->conn);
-+
-+ /*
-+ ** If we have not been asked to fail on error,
-+ ** do not fail.
-+ */
-+ if(!data->set.http_fail_on_error)
-+ return FALSE;
-+
-+ /*
-+ ** Any code < 400 is never terminal.
-+ */
-+ if(httpcode < 400)
-+ return FALSE;
-+
-+ /*
-+ ** A 416 response to a resume request is presumably because the file is
-+ ** already completely downloaded and thus not actually a fail.
-+ */
-+ if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
-+ httpcode == 416)
-+ return FALSE;
-+
-+ /*
-+ ** Any code >= 400 that is not 401 or 407 is always
-+ ** a terminal error
-+ */
-+ if((httpcode != 401) && (httpcode != 407))
-+ return TRUE;
-+
-+ /*
-+ ** All we have left to deal with is 401 and 407
-+ */
-+ DEBUGASSERT((httpcode == 401) || (httpcode == 407));
-+
-+ /*
-+ ** Examine the current authentication state to see if this is an error. The
-+ ** idea is for this function to get called after processing all the headers
-+ ** in a response message. So, if we have been to asked to authenticate a
-+ ** particular stage, and we have done it, we are OK. If we are already
-+ ** completely authenticated, it is not OK to get another 401 or 407.
-+ **
-+ ** It is possible for authentication to go stale such that the client needs
-+ ** to reauthenticate. Once that info is available, use it here.
-+ */
-+
-+ /*
-+ ** Either we are not authenticating, or we are supposed to be authenticating
-+ ** something else. This is an error.
-+ */
-+ if((httpcode == 401) && !data->state.aptr.user)
-+ return TRUE;
-+#ifndef CURL_DISABLE_PROXY
-+ if((httpcode == 407) && !data->conn->bits.proxy_user_passwd)
-+ return TRUE;
-+#endif
-+
-+ return data->state.authproblem;
-+}
-+
- /*
- * Curl_http_auth_act() gets called when all HTTP headers have been received
- * and it checks what authentication methods that are available and decides
- * which one (if any) to use. It will set 'newurl' if an auth method was
- * picked.
- */
--
- CURLcode Curl_http_auth_act(struct Curl_easy *data)
- {
- struct connectdata *conn = data->conn;
-@@ -1116,77 +1098,6 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
- #endif
- }
-
--/**
-- * http_should_fail() determines whether an HTTP response code has gotten us
-- * into an error state or not.
-- *
-- * @retval FALSE communications should continue
-- *
-- * @retval TRUE communications should not continue
-- */
--static bool http_should_fail(struct Curl_easy *data, int httpcode)
--{
-- DEBUGASSERT(data);
-- DEBUGASSERT(data->conn);
--
-- /*
-- ** If we have not been asked to fail on error,
-- ** do not fail.
-- */
-- if(!data->set.http_fail_on_error)
-- return FALSE;
--
-- /*
-- ** Any code < 400 is never terminal.
-- */
-- if(httpcode < 400)
-- return FALSE;
--
-- /*
-- ** A 416 response to a resume request is presumably because the file is
-- ** already completely downloaded and thus not actually a fail.
-- */
-- if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
-- httpcode == 416)
-- return FALSE;
--
-- /*
-- ** Any code >= 400 that is not 401 or 407 is always
-- ** a terminal error
-- */
-- if((httpcode != 401) && (httpcode != 407))
-- return TRUE;
--
-- /*
-- ** All we have left to deal with is 401 and 407
-- */
-- DEBUGASSERT((httpcode == 401) || (httpcode == 407));
--
-- /*
-- ** Examine the current authentication state to see if this is an error. The
-- ** idea is for this function to get called after processing all the headers
-- ** in a response message. So, if we have been to asked to authenticate a
-- ** particular stage, and we have done it, we are OK. If we are already
-- ** completely authenticated, it is not OK to get another 401 or 407.
-- **
-- ** It is possible for authentication to go stale such that the client needs
-- ** to reauthenticate. Once that info is available, use it here.
-- */
--
-- /*
-- ** Either we are not authenticating, or we are supposed to be authenticating
-- ** something else. This is an error.
-- */
-- if((httpcode == 401) && !data->state.aptr.user)
-- return TRUE;
--#ifndef CURL_DISABLE_PROXY
-- if((httpcode == 407) && !data->conn->bits.proxy_user_passwd)
-- return TRUE;
--#endif
--
-- return data->state.authproblem;
--}
--
- static void http_switch_to_get(struct Curl_easy *data, int code)
- {
- const char *req = data->set.str[STRING_CUSTOMREQUEST];
-@@ -1532,6 +1443,145 @@ bool Curl_compareheader(const char *headerline, /* line to check */
- return FALSE; /* no match */
- }
-
-+struct cr_exp100_ctx {
-+ struct Curl_creader super;
-+ struct curltime start; /* time started waiting */
-+ enum expect100 state;
-+};
-+
-+/* Expect: 100-continue client reader, blocking uploads */
-+
-+static void http_exp100_continue(struct Curl_easy *data,
-+ struct Curl_creader *reader)
-+{
-+ struct cr_exp100_ctx *ctx = reader->ctx;
-+ if(ctx->state > EXP100_SEND_DATA) {
-+ ctx->state = EXP100_SEND_DATA;
-+ Curl_expire_done(data, EXPIRE_100_TIMEOUT);
-+ }
-+}
-+
-+static CURLcode cr_exp100_read(struct Curl_easy *data,
-+ struct Curl_creader *reader,
-+ char *buf, size_t blen,
-+ size_t *nread, bool *eos)
-+{
-+ struct cr_exp100_ctx *ctx = reader->ctx;
-+ timediff_t ms;
-+
-+ switch(ctx->state) {
-+ case EXP100_SENDING_REQUEST:
-+ if(!Curl_req_sendbuf_empty(data)) {
-+ /* The initial request data has not been fully sent yet. Do
-+ * not start the timer yet. */
-+ DEBUGF(infof(data, "cr_exp100_read, request not full sent yet"));
-+ *nread = 0;
-+ *eos = FALSE;
-+ return CURLE_OK;
-+ }
-+ /* We are now waiting for a reply from the server or
-+ * a timeout on our side IFF the request has been fully sent. */
-+ DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, "
-+ "timeout %dms", data->set.expect_100_timeout));
-+ ctx->state = EXP100_AWAITING_CONTINUE;
-+ ctx->start = *Curl_pgrs_now(data);
-+ Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
-+ *nread = 0;
-+ *eos = FALSE;
-+ return CURLE_OK;
-+ case EXP100_FAILED:
-+ DEBUGF(infof(data, "cr_exp100_read, expectation failed, error"));
-+ *nread = 0;
-+ *eos = FALSE;
-+ return CURLE_READ_ERROR;
-+ case EXP100_AWAITING_CONTINUE:
-+ ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &ctx->start);
-+ if(ms < data->set.expect_100_timeout) {
-+ DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
-+ *nread = 0;
-+ *eos = FALSE;
-+ return CURLE_OK;
-+ }
-+ /* we have waited long enough, continue anyway */
-+ http_exp100_continue(data, reader);
-+ infof(data, "Done waiting for 100-continue");
-+ FALLTHROUGH();
-+ default:
-+ DEBUGF(infof(data, "cr_exp100_read, pass through"));
-+ return Curl_creader_read(data, reader->next, buf, blen, nread, eos);
-+ }
-+}
-+
-+static void cr_exp100_done(struct Curl_easy *data,
-+ struct Curl_creader *reader, int premature)
-+{
-+ struct cr_exp100_ctx *ctx = reader->ctx;
-+ ctx->state = premature ? EXP100_FAILED : EXP100_SEND_DATA;
-+ Curl_expire_done(data, EXPIRE_100_TIMEOUT);
-+}
-+
-+static const struct Curl_crtype cr_exp100 = {
-+ "cr-exp100",
-+ Curl_creader_def_init,
-+ cr_exp100_read,
-+ Curl_creader_def_close,
-+ Curl_creader_def_needs_rewind,
-+ Curl_creader_def_total_length,
-+ Curl_creader_def_resume_from,
-+ Curl_creader_def_cntrl,
-+ Curl_creader_def_is_paused,
-+ cr_exp100_done,
-+ sizeof(struct cr_exp100_ctx)
-+};
-+
-+static CURLcode http_exp100_add_reader(struct Curl_easy *data)
-+{
-+ struct Curl_creader *reader = NULL;
-+ CURLcode result;
-+
-+ result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
-+ if(!result)
-+ result = Curl_creader_add(data, reader);
-+ if(!result) {
-+ struct cr_exp100_ctx *ctx = reader->ctx;
-+ ctx->state = EXP100_SENDING_REQUEST;
-+ }
-+
-+ if(result && reader)
-+ Curl_creader_free(data, reader);
-+ return result;
-+}
-+
-+static void http_exp100_got100(struct Curl_easy *data)
-+{
-+ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-+ if(r)
-+ http_exp100_continue(data, r);
-+}
-+
-+static bool http_exp100_is_waiting(struct Curl_easy *data)
-+{
-+ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-+ if(r) {
-+ struct cr_exp100_ctx *ctx = r->ctx;
-+ return ctx->state == EXP100_AWAITING_CONTINUE;
-+ }
-+ return FALSE;
-+}
-+
-+static void http_exp100_send_anyway(struct Curl_easy *data)
-+{
-+ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-+ if(r)
-+ http_exp100_continue(data, r);
-+}
-+
-+static bool http_exp100_is_selected(struct Curl_easy *data)
-+{
-+ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-+ return !!r;
-+}
-+
- /* this returns the socket to wait for in the DO and DOING state for the multi
- interface and then we are always _sending_ a request and thus we wait for
- the single socket to become writable only */
-@@ -1559,6 +1609,33 @@ CURLcode Curl_http_perform_pollset(struct Curl_easy *data,
- return result;
- }
-
-+static CURLcode http_write_header(struct Curl_easy *data,
-+ const char *hd, size_t hdlen)
-+{
-+ CURLcode result;
-+ int writetype;
-+
-+ /* now, only output this if the header AND body are requested:
-+ */
-+ Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
-+
-+ writetype = CLIENTWRITE_HEADER |
-+ ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
-+
-+ result = Curl_client_write(data, writetype, hd, hdlen);
-+ if(result)
-+ return result;
-+
-+ result = Curl_bump_headersize(data, hdlen, FALSE);
-+ if(result)
-+ return result;
-+
-+ data->req.deductheadercount = (100 <= data->req.httpcode &&
-+ 199 >= data->req.httpcode) ?
-+ data->req.headerbytecount : 0;
-+ return result;
-+}
-+
- /*
- * Curl_http_done() gets called after a single HTTP request has been
- * performed.
-@@ -3800,33 +3877,6 @@ CURLcode Curl_bump_headersize(struct Curl_easy *data,
- return CURLE_OK;
- }
-
--static CURLcode http_write_header(struct Curl_easy *data,
-- const char *hd, size_t hdlen)
--{
-- CURLcode result;
-- int writetype;
--
-- /* now, only output this if the header AND body are requested:
-- */
-- Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
--
-- writetype = CLIENTWRITE_HEADER |
-- ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
--
-- result = Curl_client_write(data, writetype, hd, hdlen);
-- if(result)
-- return result;
--
-- result = Curl_bump_headersize(data, hdlen, FALSE);
-- if(result)
-- return result;
--
-- data->req.deductheadercount = (100 <= data->req.httpcode &&
-- 199 >= data->req.httpcode) ?
-- data->req.headerbytecount : 0;
-- return result;
--}
--
- static CURLcode http_on_response(struct Curl_easy *data,
- const char *last_hd, size_t last_hd_len,
- const char *buf, size_t blen,
-@@ -4931,143 +4981,65 @@ void Curl_http_resp_free(struct http_resp *resp)
- }
- }
-
--struct cr_exp100_ctx {
-- struct Curl_creader super;
-- struct curltime start; /* time started waiting */
-- enum expect100 state;
--};
--
--/* Expect: 100-continue client reader, blocking uploads */
--
--static void http_exp100_continue(struct Curl_easy *data,
-- struct Curl_creader *reader)
--{
-- struct cr_exp100_ctx *ctx = reader->ctx;
-- if(ctx->state > EXP100_SEND_DATA) {
-- ctx->state = EXP100_SEND_DATA;
-- Curl_expire_done(data, EXPIRE_100_TIMEOUT);
-- }
--}
--
--static CURLcode cr_exp100_read(struct Curl_easy *data,
-- struct Curl_creader *reader,
-- char *buf, size_t blen,
-- size_t *nread, bool *eos)
--{
-- struct cr_exp100_ctx *ctx = reader->ctx;
-- timediff_t ms;
--
-- switch(ctx->state) {
-- case EXP100_SENDING_REQUEST:
-- if(!Curl_req_sendbuf_empty(data)) {
-- /* The initial request data has not been fully sent yet. Do
-- * not start the timer yet. */
-- DEBUGF(infof(data, "cr_exp100_read, request not full sent yet"));
-- *nread = 0;
-- *eos = FALSE;
-- return CURLE_OK;
-- }
-- /* We are now waiting for a reply from the server or
-- * a timeout on our side IFF the request has been fully sent. */
-- DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, "
-- "timeout %dms", data->set.expect_100_timeout));
-- ctx->state = EXP100_AWAITING_CONTINUE;
-- ctx->start = *Curl_pgrs_now(data);
-- Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
-- *nread = 0;
-- *eos = FALSE;
-- return CURLE_OK;
-- case EXP100_FAILED:
-- DEBUGF(infof(data, "cr_exp100_read, expectation failed, error"));
-- *nread = 0;
-- *eos = FALSE;
-- return CURLE_READ_ERROR;
-- case EXP100_AWAITING_CONTINUE:
-- ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &ctx->start);
-- if(ms < data->set.expect_100_timeout) {
-- DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
-- *nread = 0;
-- *eos = FALSE;
-- return CURLE_OK;
-- }
-- /* we have waited long enough, continue anyway */
-- http_exp100_continue(data, reader);
-- infof(data, "Done waiting for 100-continue");
-- FALLTHROUGH();
-- default:
-- DEBUGF(infof(data, "cr_exp100_read, pass through"));
-- return Curl_creader_read(data, reader->next, buf, blen, nread, eos);
-- }
--}
--
--static void cr_exp100_done(struct Curl_easy *data,
-- struct Curl_creader *reader, int premature)
--{
-- struct cr_exp100_ctx *ctx = reader->ctx;
-- ctx->state = premature ? EXP100_FAILED : EXP100_SEND_DATA;
-- Curl_expire_done(data, EXPIRE_100_TIMEOUT);
--}
-+/*
-+ * HTTP handler interface.
-+ */
-+const struct Curl_handler Curl_handler_http = {
-+ "http", /* scheme */
-+ Curl_http_setup_conn, /* setup_connection */
-+ Curl_http, /* do_it */
-+ Curl_http_done, /* done */
-+ ZERO_NULL, /* do_more */
-+ ZERO_NULL, /* connect_it */
-+ ZERO_NULL, /* connecting */
-+ ZERO_NULL, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ Curl_http_doing_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ Curl_http_perform_pollset, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ Curl_http_write_resp, /* write_resp */
-+ Curl_http_write_resp_hd, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ Curl_http_follow, /* follow */
-+ PORT_HTTP, /* defport */
-+ CURLPROTO_HTTP, /* protocol */
-+ CURLPROTO_HTTP, /* family */
-+ PROTOPT_CREDSPERREQUEST | /* flags */
-+ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
-
--static const struct Curl_crtype cr_exp100 = {
-- "cr-exp100",
-- Curl_creader_def_init,
-- cr_exp100_read,
-- Curl_creader_def_close,
-- Curl_creader_def_needs_rewind,
-- Curl_creader_def_total_length,
-- Curl_creader_def_resume_from,
-- Curl_creader_def_cntrl,
-- Curl_creader_def_is_paused,
-- cr_exp100_done,
-- sizeof(struct cr_exp100_ctx)
- };
-
--static CURLcode http_exp100_add_reader(struct Curl_easy *data)
--{
-- struct Curl_creader *reader = NULL;
-- CURLcode result;
--
-- result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
-- if(!result)
-- result = Curl_creader_add(data, reader);
-- if(!result) {
-- struct cr_exp100_ctx *ctx = reader->ctx;
-- ctx->state = EXP100_SENDING_REQUEST;
-- }
--
-- if(result && reader)
-- Curl_creader_free(data, reader);
-- return result;
--}
--
--static void http_exp100_got100(struct Curl_easy *data)
--{
-- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-- if(r)
-- http_exp100_continue(data, r);
--}
--
--static bool http_exp100_is_waiting(struct Curl_easy *data)
--{
-- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-- if(r) {
-- struct cr_exp100_ctx *ctx = r->ctx;
-- return ctx->state == EXP100_AWAITING_CONTINUE;
-- }
-- return FALSE;
--}
--
--static void http_exp100_send_anyway(struct Curl_easy *data)
--{
-- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-- if(r)
-- http_exp100_continue(data, r);
--}
--
--static bool http_exp100_is_selected(struct Curl_easy *data)
--{
-- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
-- return !!r;
--}
-+#ifdef USE_SSL
-+/*
-+ * HTTPS handler interface.
-+ */
-+const struct Curl_handler Curl_handler_https = {
-+ "https", /* scheme */
-+ Curl_http_setup_conn, /* setup_connection */
-+ Curl_http, /* do_it */
-+ Curl_http_done, /* done */
-+ ZERO_NULL, /* do_more */
-+ ZERO_NULL, /* connect_it */
-+ NULL, /* connecting */
-+ ZERO_NULL, /* doing */
-+ NULL, /* proto_pollset */
-+ Curl_http_doing_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ Curl_http_perform_pollset, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ Curl_http_write_resp, /* write_resp */
-+ Curl_http_write_resp_hd, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ Curl_http_follow, /* follow */
-+ PORT_HTTPS, /* defport */
-+ CURLPROTO_HTTPS, /* protocol */
-+ CURLPROTO_HTTP, /* family */
-+ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
-+ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
-+};
-+#endif
-
- #endif /* CURL_DISABLE_HTTP */
-diff --git a/lib/mqtt.c b/lib/mqtt.c
-index 2ba1ca73e9..5f5c91a49a 100644
---- a/lib/mqtt.c
-+++ b/lib/mqtt.c
-@@ -89,48 +89,6 @@ struct MQTT {
- BIT(pingsent); /* 1 while we wait for ping response */
- };
-
--/*
-- * Forward declarations.
-- */
--
--static CURLcode mqtt_do(struct Curl_easy *data, bool *done);
--static CURLcode mqtt_done(struct Curl_easy *data,
-- CURLcode status, bool premature);
--static CURLcode mqtt_doing(struct Curl_easy *data, bool *done);
--static CURLcode mqtt_pollset(struct Curl_easy *data,
-- struct easy_pollset *ps);
--static CURLcode mqtt_setup_conn(struct Curl_easy *data,
-- struct connectdata *conn);
--
--/*
-- * MQTT protocol handler.
-- */
--
--const struct Curl_handler Curl_handler_mqtt = {
-- "mqtt", /* scheme */
-- mqtt_setup_conn, /* setup_connection */
-- mqtt_do, /* do_it */
-- mqtt_done, /* done */
-- ZERO_NULL, /* do_more */
-- ZERO_NULL, /* connect_it */
-- ZERO_NULL, /* connecting */
-- mqtt_doing, /* doing */
-- ZERO_NULL, /* proto_pollset */
-- mqtt_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_MQTT, /* defport */
-- CURLPROTO_MQTT, /* protocol */
-- CURLPROTO_MQTT, /* family */
-- PROTOPT_NONE /* flags */
--};
--
- static void mqtt_easy_dtor(void *key, size_t klen, void *entry)
- {
- struct MQTT *mq = entry;
-@@ -976,4 +934,33 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done)
- return result;
- }
-
-+/*
-+ * MQTT protocol handler.
-+ */
-+
-+const struct Curl_handler Curl_handler_mqtt = {
-+ "mqtt", /* scheme */
-+ mqtt_setup_conn, /* setup_connection */
-+ mqtt_do, /* do_it */
-+ mqtt_done, /* done */
-+ ZERO_NULL, /* do_more */
-+ ZERO_NULL, /* connect_it */
-+ ZERO_NULL, /* connecting */
-+ mqtt_doing, /* doing */
-+ ZERO_NULL, /* proto_pollset */
-+ mqtt_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_MQTT, /* defport */
-+ CURLPROTO_MQTT, /* protocol */
-+ CURLPROTO_MQTT, /* family */
-+ PROTOPT_NONE /* flags */
-+};
-+
- #endif /* CURL_DISABLE_MQTT */
-diff --git a/lib/smb.c b/lib/smb.c
-index 003a38f19f..23fc4596dc 100644
---- a/lib/smb.c
-+++ b/lib/smb.c
-@@ -285,77 +285,6 @@ struct smb_tree_disconnect {
- # pragma pack(pop)
- #endif
-
--/* Local API functions */
--static CURLcode smb_setup_connection(struct Curl_easy *data,
-- struct connectdata *conn);
--static CURLcode smb_connect(struct Curl_easy *data, bool *done);
--static CURLcode smb_connection_state(struct Curl_easy *data, bool *done);
--static CURLcode smb_do(struct Curl_easy *data, bool *done);
--static CURLcode smb_request_state(struct Curl_easy *data, bool *done);
--static CURLcode smb_pollset(struct Curl_easy *data,
-- struct easy_pollset *ps);
--static CURLcode smb_parse_url_path(struct Curl_easy *data,
-- struct smb_conn *smbc,
-- struct smb_request *req);
--
--/*
-- * SMB handler interface
-- */
--const struct Curl_handler Curl_handler_smb = {
-- "smb", /* scheme */
-- smb_setup_connection, /* setup_connection */
-- smb_do, /* do_it */
-- ZERO_NULL, /* done */
-- ZERO_NULL, /* do_more */
-- smb_connect, /* connect_it */
-- smb_connection_state, /* connecting */
-- smb_request_state, /* doing */
-- smb_pollset, /* proto_pollset */
-- smb_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_SMB, /* defport */
-- CURLPROTO_SMB, /* protocol */
-- CURLPROTO_SMB, /* family */
-- PROTOPT_CONN_REUSE /* flags */
--};
--
--#ifdef USE_SSL
--/*
-- * SMBS handler interface
-- */
--const struct Curl_handler Curl_handler_smbs = {
-- "smbs", /* scheme */
-- smb_setup_connection, /* setup_connection */
-- smb_do, /* do_it */
-- ZERO_NULL, /* done */
-- ZERO_NULL, /* do_more */
-- smb_connect, /* connect_it */
-- smb_connection_state, /* connecting */
-- smb_request_state, /* doing */
-- smb_pollset, /* proto_pollset */
-- smb_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_SMBS, /* defport */
-- CURLPROTO_SMBS, /* protocol */
-- CURLPROTO_SMB, /* family */
-- PROTOPT_SSL | PROTOPT_CONN_REUSE /* flags */
--};
--#endif
--
- #define MAX_PAYLOAD_SIZE 0x8000
- #define MAX_MESSAGE_SIZE (MAX_PAYLOAD_SIZE + 0x1000)
- #define CLIENTNAME "curl"
-@@ -442,9 +371,7 @@ static void smb_easy_dtor(void *key, size_t klen, void *entry)
- struct smb_request *req = entry;
- (void)key;
- (void)klen;
-- /* `req->path` points to somewhere in `struct smb_conn` which is
-- * kept at the connection meta. If the connection is destroyed first,
-- * req->path points to free'd memory. */
-+ Curl_safefree(req->path);
- curlx_free(req);
- }
-
-@@ -460,6 +387,53 @@ static void smb_conn_dtor(void *key, size_t klen, void *entry)
- curlx_free(smbc);
- }
-
-+static CURLcode smb_parse_url_path(struct Curl_easy *data,
-+ struct smb_conn *smbc,
-+ struct smb_request *req)
-+{
-+ char *path;
-+ char *slash, *s;
-+ CURLcode result;
-+
-+ /* URL decode the path */
-+ result = Curl_urldecode(data->state.up.path, 0, &path, NULL, REJECT_CTRL);
-+ if(result)
-+ return result;
-+
-+ /* Parse the path for the share */
-+ Curl_safefree(smbc->share);
-+ smbc->share = curlx_strdup((*path == '/' || *path == '\\')
-+ ? path + 1 : path);
-+ curlx_free(path);
-+ if(!smbc->share)
-+ return CURLE_OUT_OF_MEMORY;
-+
-+ slash = strchr(smbc->share, '/');
-+ if(!slash)
-+ slash = strchr(smbc->share, '\\');
-+
-+ /* The share must be present */
-+ if(!slash) {
-+ Curl_safefree(smbc->share);
-+ failf(data, "missing share in URL path for SMB");
-+ return CURLE_URL_MALFORMAT;
-+ }
-+
-+ /* Parse the path for the file path converting any forward slashes into
-+ backslashes */
-+ *slash++ = 0;
-+ for(s = slash; *s; s++) {
-+ if(*s == '/')
-+ *s = '\\';
-+ }
-+ /* keep a copy at easy struct to not share this with connection state */
-+ req->path = curlx_strdup(slash);
-+ if(!req->path)
-+ return CURLE_OUT_OF_MEMORY;
-+
-+ return CURLE_OK;
-+}
-+
- /* this should setup things in the connection, not in the easy
- handle */
- static CURLcode smb_setup_connection(struct Curl_easy *data,
-@@ -1226,47 +1200,62 @@ static CURLcode smb_do(struct Curl_easy *data, bool *done)
- return CURLE_URL_MALFORMAT;
- }
-
--static CURLcode smb_parse_url_path(struct Curl_easy *data,
-- struct smb_conn *smbc,
-- struct smb_request *req)
--{
-- char *path;
-- char *slash;
-- CURLcode result;
--
-- /* URL decode the path */
-- result = Curl_urldecode(data->state.up.path, 0, &path, NULL, REJECT_CTRL);
-- if(result)
-- return result;
--
-- /* Parse the path for the share */
-- smbc->share = curlx_strdup((*path == '/' || *path == '\\')
-- ? path + 1 : path);
-- curlx_free(path);
-- if(!smbc->share)
-- return CURLE_OUT_OF_MEMORY;
--
-- slash = strchr(smbc->share, '/');
-- if(!slash)
-- slash = strchr(smbc->share, '\\');
--
-- /* The share must be present */
-- if(!slash) {
-- Curl_safefree(smbc->share);
-- failf(data, "missing share in URL path for SMB");
-- return CURLE_URL_MALFORMAT;
-- }
--
-- /* Parse the path for the file path converting any forward slashes into
-- backslashes */
-- *slash++ = 0;
-- req->path = slash;
-+/*
-+ * SMB handler interface
-+ */
-+const struct Curl_handler Curl_handler_smb = {
-+ "smb", /* scheme */
-+ smb_setup_connection, /* setup_connection */
-+ smb_do, /* do_it */
-+ ZERO_NULL, /* done */
-+ ZERO_NULL, /* do_more */
-+ smb_connect, /* connect_it */
-+ smb_connection_state, /* connecting */
-+ smb_request_state, /* doing */
-+ smb_pollset, /* proto_pollset */
-+ smb_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_SMB, /* defport */
-+ CURLPROTO_SMB, /* protocol */
-+ CURLPROTO_SMB, /* family */
-+ PROTOPT_CONN_REUSE /* flags */
-+};
-
-- for(; *slash; slash++) {
-- if(*slash == '/')
-- *slash = '\\';
-- }
-- return CURLE_OK;
--}
-+#ifdef USE_SSL
-+/*
-+ * SMBS handler interface
-+ */
-+const struct Curl_handler Curl_handler_smbs = {
-+ "smbs", /* scheme */
-+ smb_setup_connection, /* setup_connection */
-+ smb_do, /* do_it */
-+ ZERO_NULL, /* done */
-+ ZERO_NULL, /* do_more */
-+ smb_connect, /* connect_it */
-+ smb_connection_state, /* connecting */
-+ smb_request_state, /* doing */
-+ smb_pollset, /* proto_pollset */
-+ smb_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_SMBS, /* defport */
-+ CURLPROTO_SMBS, /* protocol */
-+ CURLPROTO_SMB, /* family */
-+ PROTOPT_SSL | PROTOPT_CONN_REUSE /* flags */
-+};
-+#endif
-
- #endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE && SIZEOF_CURL_OFF_T > 4 */
-diff --git a/lib/tftp.c b/lib/tftp.c
-index 69571bbdde..0c65c57c59 100644
---- a/lib/tftp.c
-+++ b/lib/tftp.c
-@@ -142,49 +142,6 @@ struct tftp_conn {
- BIT(remote_pinned);
- };
-
--/* Forward declarations */
--static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event);
--static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event);
--static CURLcode tftp_connect(struct Curl_easy *data, bool *done);
--static CURLcode tftp_do(struct Curl_easy *data, bool *done);
--static CURLcode tftp_done(struct Curl_easy *data,
-- CURLcode, bool premature);
--static CURLcode tftp_setup_connection(struct Curl_easy *data,
-- struct connectdata *conn);
--static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done);
--static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done);
--static CURLcode tftp_pollset(struct Curl_easy *data,
-- struct easy_pollset *ps);
--static CURLcode tftp_translate_code(tftp_error_t error);
--
--/*
-- * TFTP protocol handler.
-- */
--const struct Curl_handler Curl_handler_tftp = {
-- "tftp", /* scheme */
-- tftp_setup_connection, /* setup_connection */
-- tftp_do, /* do_it */
-- tftp_done, /* done */
-- ZERO_NULL, /* do_more */
-- tftp_connect, /* connect_it */
-- tftp_multi_statemach, /* connecting */
-- tftp_doing, /* doing */
-- tftp_pollset, /* proto_pollset */
-- tftp_pollset, /* doing_pollset */
-- ZERO_NULL, /* domore_pollset */
-- ZERO_NULL, /* perform_pollset */
-- ZERO_NULL, /* disconnect */
-- ZERO_NULL, /* write_resp */
-- ZERO_NULL, /* write_resp_hd */
-- ZERO_NULL, /* connection_check */
-- ZERO_NULL, /* attach connection */
-- ZERO_NULL, /* follow */
-- PORT_TFTP, /* defport */
-- CURLPROTO_TFTP, /* protocol */
-- CURLPROTO_TFTP, /* family */
-- PROTOPT_NOTCPPROXY | PROTOPT_NOURLQUERY /* flags */
--};
--
- /**********************************************************
- *
- * tftp_set_timeouts -
-@@ -383,185 +340,175 @@ static CURLcode tftp_option_add(struct tftp_conn *state, size_t *csize,
- return CURLE_OK;
- }
-
--static CURLcode tftp_connect_for_tx(struct tftp_conn *state,
-- tftp_event_t event)
--{
-- CURLcode result;
--#ifndef CURL_DISABLE_VERBOSE_STRINGS
-- struct Curl_easy *data = state->data;
--
-- infof(data, "%s", "Connected for transmit");
--#endif
-- state->state = TFTP_STATE_TX;
-- result = tftp_set_timeouts(state);
-- if(result)
-- return result;
-- return tftp_tx(state, event);
--}
--
--static CURLcode tftp_connect_for_rx(struct tftp_conn *state,
-- tftp_event_t event)
--{
-- CURLcode result;
--#ifndef CURL_DISABLE_VERBOSE_STRINGS
-- struct Curl_easy *data = state->data;
--
-- infof(data, "%s", "Connected for receive");
--#endif
-- state->state = TFTP_STATE_RX;
-- result = tftp_set_timeouts(state);
-- if(result)
-- return result;
-- return tftp_rx(state, event);
--}
-+/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
-+ boundary */
-+#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
-
--static CURLcode tftp_send_first(struct tftp_conn *state,
-- tftp_event_t event)
-+/**********************************************************
-+ *
-+ * tftp_tx
-+ *
-+ * Event handler for the TX state
-+ *
-+ **********************************************************/
-+static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
- {
-- size_t sbytes;
-- ssize_t senddata;
-- const char *mode = "octet";
-- char *filename;
- struct Curl_easy *data = state->data;
-- const struct Curl_sockaddr_ex *remote_addr = NULL;
-+ ssize_t sbytes;
- CURLcode result = CURLE_OK;
--
-- /* Set ASCII mode if -B flag was used */
-- if(data->state.prefer_ascii)
-- mode = "netascii";
-+ struct SingleRequest *k = &data->req;
-+ size_t cb; /* Bytes currently read */
-+ char buffer[STRERROR_LEN];
-+ char *bufptr;
-+ bool eos;
-
- switch(event) {
-
-- case TFTP_EVENT_INIT: /* Send the first packet out */
-- case TFTP_EVENT_TIMEOUT: /* Resend the first packet out */
-- /* Increment the retry counter, quit if over the limit */
-- state->retries++;
-- if(state->retries > state->retry_max) {
-- state->error = TFTP_ERR_NORESPONSE;
-- state->state = TFTP_STATE_FIN;
-- return result;
-- }
-+ case TFTP_EVENT_ACK:
-+ case TFTP_EVENT_OACK:
-+ if(event == TFTP_EVENT_ACK) {
-+ /* Ack the packet */
-+ int rblock = getrpacketblock(&state->rpacket);
-
-- if(data->state.upload) {
-- /* If we are uploading, send an WRQ */
-- setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
-- if(data->state.infilesize != -1)
-- Curl_pgrsSetUploadSize(data, data->state.infilesize);
-- }
-- else {
-- /* If we are downloading, send an RRQ */
-- setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
-- }
-- /* As RFC3617 describes the separator slash is not actually part of the
-- filename so we skip the always-present first letter of the path
-- string. */
-- if(!state->data->state.up.path[1]) {
-- failf(data, "Missing filename");
-- return CURLE_TFTP_ILLEGAL;
-- }
-- result = Curl_urldecode(&state->data->state.up.path[1], 0,
-- &filename, NULL, REJECT_ZERO);
-- if(result)
-- return result;
-+ if(rblock != state->block &&
-+ /* There is a bug in tftpd-hpa that causes it to send us an ack for
-+ * 65535 when the block number wraps to 0. So when we are expecting
-+ * 0, also accept 65535. See
-+ * https://www.syslinux.org/archives/2010-September/015612.html
-+ * */
-+ !(state->block == 0 && rblock == 65535)) {
-+ /* This is not the expected block. Log it and up the retry counter */
-+ infof(data, "Received ACK for block %d, expecting %d",
-+ rblock, state->block);
-+ state->retries++;
-+ /* Bail out if over the maximum */
-+ if(state->retries > state->retry_max) {
-+ failf(data, "tftp_tx: giving up waiting for block %d ack",
-+ state->block);
-+ result = CURLE_SEND_ERROR;
-+ }
-+ else {
-+ /* Re-send the data packet */
-+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-+ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ (struct sockaddr *)&state->remote_addr,
-+ state->remote_addrlen);
-+ /* Check all sbytes were sent */
-+ if(sbytes < 0) {
-+ failf(data, "%s",
-+ curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ result = CURLE_SEND_ERROR;
-+ }
-+ }
-
-- if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
-- failf(data, "TFTP filename too long");
-- curlx_free(filename);
-- return CURLE_TFTP_ILLEGAL; /* too long filename field */
-+ return result;
-+ }
-+ /* This is the expected packet. Reset the counters and send the next
-+ block */
-+ state->rx_time = time(NULL);
-+ state->block++;
- }
-+ else
-+ state->block = 1; /* first data block is 1 when using OACK */
-
-- curl_msnprintf((char *)state->spacket.data + 2,
-- state->blksize,
-- "%s%c%s%c", filename, '\0', mode, '\0');
-- sbytes = 4 + strlen(filename) + strlen(mode);
-- curlx_free(filename);
--
-- /* optional addition of TFTP options */
-- if(!data->set.tftp_no_options) {
-- char buf[64];
-- /* add tsize option */
-- curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
-- data->state.upload && (data->state.infilesize != -1) ?
-- data->state.infilesize : 0);
--
-- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_TSIZE);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes, sbytes, buf);
--
-- /* add blksize option */
-- curl_msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_BLKSIZE);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes, sbytes, buf);
--
-- /* add timeout option */
-- curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_INTERVAL);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes, sbytes, buf);
--
-- if(result != CURLE_OK) {
-- failf(data, "TFTP buffer too small for options");
-- return CURLE_TFTP_ILLEGAL;
-- }
-+ state->retries = 0;
-+ setpacketevent(&state->spacket, TFTP_EVENT_DATA);
-+ setpacketblock(&state->spacket, state->block);
-+ if(state->block > 1 && state->sbytes < state->blksize) {
-+ state->state = TFTP_STATE_FIN;
-+ return CURLE_OK;
- }
-
-- /* the typecase for the 3rd argument is mostly for systems that do
-- not have a size_t argument, like older unixes that want an 'int' */
--#ifdef __AMIGA__
--#define CURL_SENDTO_ARG5(x) CURL_UNCONST(x)
--#else
--#define CURL_SENDTO_ARG5(x) (x)
--#endif
-- remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
-- if(!remote_addr)
-- return CURLE_FAILED_INIT;
-+ /* TFTP considers data block size < 512 bytes as an end of session. So
-+ * in some cases we must wait for additional data to build full (512 bytes)
-+ * data block.
-+ * */
-+ state->sbytes = 0;
-+ bufptr = (char *)state->spacket.data + 4;
-+ do {
-+ result = Curl_client_read(data, bufptr, state->blksize - state->sbytes,
-+ &cb, &eos);
-+ if(result)
-+ return result;
-+ state->sbytes += cb;
-+ bufptr += cb;
-+ } while(state->sbytes < state->blksize && cb);
-
-- senddata = sendto(state->sockfd, (void *)state->spacket.data,
-- (SEND_TYPE_ARG3)sbytes, 0,
-- CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
-- (curl_socklen_t)remote_addr->addrlen);
-- if(senddata != (ssize_t)sbytes) {
-- char buffer[STRERROR_LEN];
-+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-+ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ (struct sockaddr *)&state->remote_addr,
-+ state->remote_addrlen);
-+ /* Check all sbytes were sent */
-+ if(sbytes < 0) {
- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
- return CURLE_SEND_ERROR;
- }
-+ /* Update the progress meter */
-+ k->writebytecount += state->sbytes;
-+ Curl_pgrs_upload_inc(data, state->sbytes);
- break;
-
-- case TFTP_EVENT_OACK:
-- if(data->state.upload) {
-- result = tftp_connect_for_tx(state, event);
-+ case TFTP_EVENT_TIMEOUT:
-+ /* Increment the retry counter and log the timeout */
-+ state->retries++;
-+ infof(data, "Timeout waiting for block %d ACK. "
-+ " Retries = %d", NEXT_BLOCKNUM(state->block), state->retries);
-+ /* Decide if we have had enough */
-+ if(state->retries > state->retry_max) {
-+ state->error = TFTP_ERR_TIMEOUT;
-+ state->state = TFTP_STATE_FIN;
- }
- else {
-- result = tftp_connect_for_rx(state, event);
-+ /* Re-send the data packet */
-+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-+ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ (struct sockaddr *)&state->remote_addr,
-+ state->remote_addrlen);
-+ /* Check all sbytes were sent */
-+ if(sbytes < 0) {
-+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ return CURLE_SEND_ERROR;
-+ }
-+ /* since this was a re-send, we remain at the still byte position */
-+ Curl_pgrsSetUploadCounter(data, k->writebytecount);
- }
- break;
-
-- case TFTP_EVENT_ACK: /* Connected for transmit */
-- result = tftp_connect_for_tx(state, event);
-- break;
--
-- case TFTP_EVENT_DATA: /* Connected for receive */
-- result = tftp_connect_for_rx(state, event);
-- break;
--
- case TFTP_EVENT_ERROR:
- state->state = TFTP_STATE_FIN;
-+ setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
-+ setpacketblock(&state->spacket, state->block);
-+ (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG,
-+ (struct sockaddr *)&state->remote_addr,
-+ state->remote_addrlen);
-+ /* do not bother with the return code, but if the socket is still up we
-+ * should be a good TFTP client and let the server know we are done */
-+ state->state = TFTP_STATE_FIN;
- break;
-
- default:
-- failf(state->data, "tftp_send_first: internal error");
-- return CURLE_TFTP_ILLEGAL;
-+ failf(data, "tftp_tx: internal error, event: %i", (int)(event));
-+ break;
- }
-
- return result;
- }
-
--/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
-- boundary */
--#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
-+static CURLcode tftp_connect_for_tx(struct tftp_conn *state,
-+ tftp_event_t event)
-+{
-+ CURLcode result;
-+#ifndef CURL_DISABLE_VERBOSE_STRINGS
-+ struct Curl_easy *data = state->data;
-+
-+ infof(data, "%s", "Connected for transmit");
-+#endif
-+ state->state = TFTP_STATE_TX;
-+ result = tftp_set_timeouts(state);
-+ if(result)
-+ return result;
-+ return tftp_tx(state, event);
-+}
-
- /**********************************************************
- *
-@@ -609,217 +556,67 @@ static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
- state->remote_addrlen);
- if(sbytes < 0) {
- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-- return CURLE_SEND_ERROR;
-- }
--
-- /* Check if completed (That is, a less than full packet is received) */
-- if(state->rbytes < (ssize_t)state->blksize + 4) {
-- state->state = TFTP_STATE_FIN;
-- }
-- else {
-- state->state = TFTP_STATE_RX;
-- }
-- state->rx_time = time(NULL);
-- break;
--
-- case TFTP_EVENT_OACK:
-- /* ACK option acknowledgement so we can move on to data */
-- state->block = 0;
-- state->retries = 0;
-- setpacketevent(&state->spacket, TFTP_EVENT_ACK);
-- setpacketblock(&state->spacket, state->block);
-- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-- 4, SEND_4TH_ARG,
-- (struct sockaddr *)&state->remote_addr,
-- state->remote_addrlen);
-- if(sbytes < 0) {
-- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-- return CURLE_SEND_ERROR;
-- }
--
-- /* we are ready to RX data */
-- state->state = TFTP_STATE_RX;
-- state->rx_time = time(NULL);
-- break;
--
-- case TFTP_EVENT_TIMEOUT:
-- /* Increment the retry count and fail if over the limit */
-- state->retries++;
-- infof(data,
-- "Timeout waiting for block %d ACK. Retries = %d",
-- NEXT_BLOCKNUM(state->block), state->retries);
-- if(state->retries > state->retry_max) {
-- state->error = TFTP_ERR_TIMEOUT;
-- state->state = TFTP_STATE_FIN;
-- }
-- else {
-- /* Resend the previous ACK */
-- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-- 4, SEND_4TH_ARG,
-- (struct sockaddr *)&state->remote_addr,
-- state->remote_addrlen);
-- if(sbytes < 0) {
-- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-- return CURLE_SEND_ERROR;
-- }
-- }
-- break;
--
-- case TFTP_EVENT_ERROR:
-- setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
-- setpacketblock(&state->spacket, state->block);
-- (void)sendto(state->sockfd, (void *)state->spacket.data,
-- 4, SEND_4TH_ARG,
-- (struct sockaddr *)&state->remote_addr,
-- state->remote_addrlen);
-- /* do not bother with the return code, but if the socket is still up we
-- * should be a good TFTP client and let the server know we are done */
-- state->state = TFTP_STATE_FIN;
-- break;
--
-- default:
-- failf(data, "%s", "tftp_rx: internal error");
-- return CURLE_TFTP_ILLEGAL; /* not really the perfect return code for
-- this */
-- }
-- return CURLE_OK;
--}
--
--/**********************************************************
-- *
-- * tftp_tx
-- *
-- * Event handler for the TX state
-- *
-- **********************************************************/
--static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
--{
-- struct Curl_easy *data = state->data;
-- ssize_t sbytes;
-- CURLcode result = CURLE_OK;
-- struct SingleRequest *k = &data->req;
-- size_t cb; /* Bytes currently read */
-- char buffer[STRERROR_LEN];
-- char *bufptr;
-- bool eos;
--
-- switch(event) {
--
-- case TFTP_EVENT_ACK:
-- case TFTP_EVENT_OACK:
-- if(event == TFTP_EVENT_ACK) {
-- /* Ack the packet */
-- int rblock = getrpacketblock(&state->rpacket);
--
-- if(rblock != state->block &&
-- /* There is a bug in tftpd-hpa that causes it to send us an ack for
-- * 65535 when the block number wraps to 0. So when we are expecting
-- * 0, also accept 65535. See
-- * https://www.syslinux.org/archives/2010-September/015612.html
-- * */
-- !(state->block == 0 && rblock == 65535)) {
-- /* This is not the expected block. Log it and up the retry counter */
-- infof(data, "Received ACK for block %d, expecting %d",
-- rblock, state->block);
-- state->retries++;
-- /* Bail out if over the maximum */
-- if(state->retries > state->retry_max) {
-- failf(data, "tftp_tx: giving up waiting for block %d ack",
-- state->block);
-- result = CURLE_SEND_ERROR;
-- }
-- else {
-- /* Re-send the data packet */
-- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-- (struct sockaddr *)&state->remote_addr,
-- state->remote_addrlen);
-- /* Check all sbytes were sent */
-- if(sbytes < 0) {
-- failf(data, "%s",
-- curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-- result = CURLE_SEND_ERROR;
-- }
-- }
--
-- return result;
-- }
-- /* This is the expected packet. Reset the counters and send the next
-- block */
-- state->rx_time = time(NULL);
-- state->block++;
-+ return CURLE_SEND_ERROR;
- }
-- else
-- state->block = 1; /* first data block is 1 when using OACK */
-
-- state->retries = 0;
-- setpacketevent(&state->spacket, TFTP_EVENT_DATA);
-- setpacketblock(&state->spacket, state->block);
-- if(state->block > 1 && state->sbytes < state->blksize) {
-+ /* Check if completed (That is, a less than full packet is received) */
-+ if(state->rbytes < (ssize_t)state->blksize + 4) {
- state->state = TFTP_STATE_FIN;
-- return CURLE_OK;
- }
-+ else {
-+ state->state = TFTP_STATE_RX;
-+ }
-+ state->rx_time = time(NULL);
-+ break;
-
-- /* TFTP considers data block size < 512 bytes as an end of session. So
-- * in some cases we must wait for additional data to build full (512 bytes)
-- * data block.
-- * */
-- state->sbytes = 0;
-- bufptr = (char *)state->spacket.data + 4;
-- do {
-- result = Curl_client_read(data, bufptr, state->blksize - state->sbytes,
-- &cb, &eos);
-- if(result)
-- return result;
-- state->sbytes += cb;
-- bufptr += cb;
-- } while(state->sbytes < state->blksize && cb);
--
-+ case TFTP_EVENT_OACK:
-+ /* ACK option acknowledgement so we can move on to data */
-+ state->block = 0;
-+ state->retries = 0;
-+ setpacketevent(&state->spacket, TFTP_EVENT_ACK);
-+ setpacketblock(&state->spacket, state->block);
- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ 4, SEND_4TH_ARG,
- (struct sockaddr *)&state->remote_addr,
- state->remote_addrlen);
-- /* Check all sbytes were sent */
- if(sbytes < 0) {
- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
- return CURLE_SEND_ERROR;
- }
-- /* Update the progress meter */
-- k->writebytecount += state->sbytes;
-- Curl_pgrs_upload_inc(data, state->sbytes);
-+
-+ /* we are ready to RX data */
-+ state->state = TFTP_STATE_RX;
-+ state->rx_time = time(NULL);
- break;
-
- case TFTP_EVENT_TIMEOUT:
-- /* Increment the retry counter and log the timeout */
-+ /* Increment the retry count and fail if over the limit */
- state->retries++;
-- infof(data, "Timeout waiting for block %d ACK. "
-- " Retries = %d", NEXT_BLOCKNUM(state->block), state->retries);
-- /* Decide if we have had enough */
-+ infof(data,
-+ "Timeout waiting for block %d ACK. Retries = %d",
-+ NEXT_BLOCKNUM(state->block), state->retries);
- if(state->retries > state->retry_max) {
- state->error = TFTP_ERR_TIMEOUT;
- state->state = TFTP_STATE_FIN;
- }
- else {
-- /* Re-send the data packet */
-+ /* Resend the previous ACK */
- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ 4, SEND_4TH_ARG,
- (struct sockaddr *)&state->remote_addr,
- state->remote_addrlen);
-- /* Check all sbytes were sent */
- if(sbytes < 0) {
- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
- return CURLE_SEND_ERROR;
- }
-- /* since this was a re-send, we remain at the still byte position */
-- Curl_pgrsSetUploadCounter(data, k->writebytecount);
- }
- break;
-
- case TFTP_EVENT_ERROR:
-- state->state = TFTP_STATE_FIN;
- setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
- setpacketblock(&state->spacket, state->block);
-- (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG,
-+ (void)sendto(state->sockfd, (void *)state->spacket.data,
-+ 4, SEND_4TH_ARG,
- (struct sockaddr *)&state->remote_addr,
- state->remote_addrlen);
- /* do not bother with the return code, but if the socket is still up we
-@@ -828,8 +625,168 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
- break;
-
- default:
-- failf(data, "tftp_tx: internal error, event: %i", (int)(event));
-+ failf(data, "%s", "tftp_rx: internal error");
-+ return CURLE_TFTP_ILLEGAL; /* not really the perfect return code for
-+ this */
-+ }
-+ return CURLE_OK;
-+}
-+
-+static CURLcode tftp_connect_for_rx(struct tftp_conn *state,
-+ tftp_event_t event)
-+{
-+ CURLcode result;
-+#ifndef CURL_DISABLE_VERBOSE_STRINGS
-+ struct Curl_easy *data = state->data;
-+
-+ infof(data, "%s", "Connected for receive");
-+#endif
-+ state->state = TFTP_STATE_RX;
-+ result = tftp_set_timeouts(state);
-+ if(result)
-+ return result;
-+ return tftp_rx(state, event);
-+}
-+
-+static CURLcode tftp_send_first(struct tftp_conn *state,
-+ tftp_event_t event)
-+{
-+ size_t sbytes;
-+ ssize_t senddata;
-+ const char *mode = "octet";
-+ char *filename;
-+ struct Curl_easy *data = state->data;
-+ const struct Curl_sockaddr_ex *remote_addr = NULL;
-+ CURLcode result = CURLE_OK;
-+
-+ /* Set ASCII mode if -B flag was used */
-+ if(data->state.prefer_ascii)
-+ mode = "netascii";
-+
-+ switch(event) {
-+
-+ case TFTP_EVENT_INIT: /* Send the first packet out */
-+ case TFTP_EVENT_TIMEOUT: /* Resend the first packet out */
-+ /* Increment the retry counter, quit if over the limit */
-+ state->retries++;
-+ if(state->retries > state->retry_max) {
-+ state->error = TFTP_ERR_NORESPONSE;
-+ state->state = TFTP_STATE_FIN;
-+ return result;
-+ }
-+
-+ if(data->state.upload) {
-+ /* If we are uploading, send an WRQ */
-+ setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
-+ if(data->state.infilesize != -1)
-+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
-+ }
-+ else {
-+ /* If we are downloading, send an RRQ */
-+ setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
-+ }
-+ /* As RFC3617 describes the separator slash is not actually part of the
-+ filename so we skip the always-present first letter of the path
-+ string. */
-+ if(!state->data->state.up.path[1]) {
-+ failf(data, "Missing filename");
-+ return CURLE_TFTP_ILLEGAL;
-+ }
-+ result = Curl_urldecode(&state->data->state.up.path[1], 0,
-+ &filename, NULL, REJECT_ZERO);
-+ if(result)
-+ return result;
-+
-+ if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
-+ failf(data, "TFTP filename too long");
-+ curlx_free(filename);
-+ return CURLE_TFTP_ILLEGAL; /* too long filename field */
-+ }
-+
-+ curl_msnprintf((char *)state->spacket.data + 2,
-+ state->blksize,
-+ "%s%c%s%c", filename, '\0', mode, '\0');
-+ sbytes = 4 + strlen(filename) + strlen(mode);
-+ curlx_free(filename);
-+
-+ /* optional addition of TFTP options */
-+ if(!data->set.tftp_no_options) {
-+ char buf[64];
-+ /* add tsize option */
-+ curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
-+ data->state.upload && (data->state.infilesize != -1) ?
-+ data->state.infilesize : 0);
-+
-+ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_TSIZE);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes, sbytes, buf);
-+
-+ /* add blksize option */
-+ curl_msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_BLKSIZE);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes, sbytes, buf);
-+
-+ /* add timeout option */
-+ curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_INTERVAL);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes, sbytes, buf);
-+
-+ if(result != CURLE_OK) {
-+ failf(data, "TFTP buffer too small for options");
-+ return CURLE_TFTP_ILLEGAL;
-+ }
-+ }
-+
-+ /* the typecase for the 3rd argument is mostly for systems that do
-+ not have a size_t argument, like older unixes that want an 'int' */
-+#ifdef __AMIGA__
-+#define CURL_SENDTO_ARG5(x) CURL_UNCONST(x)
-+#else
-+#define CURL_SENDTO_ARG5(x) (x)
-+#endif
-+ remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
-+ if(!remote_addr)
-+ return CURLE_FAILED_INIT;
-+
-+ senddata = sendto(state->sockfd, (void *)state->spacket.data,
-+ (SEND_TYPE_ARG3)sbytes, 0,
-+ CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
-+ (curl_socklen_t)remote_addr->addrlen);
-+ if(senddata != (ssize_t)sbytes) {
-+ char buffer[STRERROR_LEN];
-+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ return CURLE_SEND_ERROR;
-+ }
-+ break;
-+
-+ case TFTP_EVENT_OACK:
-+ if(data->state.upload) {
-+ result = tftp_connect_for_tx(state, event);
-+ }
-+ else {
-+ result = tftp_connect_for_rx(state, event);
-+ }
-+ break;
-+
-+ case TFTP_EVENT_ACK: /* Connected for transmit */
-+ result = tftp_connect_for_tx(state, event);
-+ break;
-+
-+ case TFTP_EVENT_DATA: /* Connected for receive */
-+ result = tftp_connect_for_rx(state, event);
-+ break;
-+
-+ case TFTP_EVENT_ERROR:
-+ state->state = TFTP_STATE_FIN;
- break;
-+
-+ default:
-+ failf(state->data, "tftp_send_first: internal error");
-+ return CURLE_TFTP_ILLEGAL;
- }
-
- return result;
-@@ -1377,4 +1334,33 @@ static CURLcode tftp_setup_connection(struct Curl_easy *data,
-
- return CURLE_OK;
- }
-+
-+/*
-+ * TFTP protocol handler.
-+ */
-+const struct Curl_handler Curl_handler_tftp = {
-+ "tftp", /* scheme */
-+ tftp_setup_connection, /* setup_connection */
-+ tftp_do, /* do_it */
-+ tftp_done, /* done */
-+ ZERO_NULL, /* do_more */
-+ tftp_connect, /* connect_it */
-+ tftp_multi_statemach, /* connecting */
-+ tftp_doing, /* doing */
-+ tftp_pollset, /* proto_pollset */
-+ tftp_pollset, /* doing_pollset */
-+ ZERO_NULL, /* domore_pollset */
-+ ZERO_NULL, /* perform_pollset */
-+ ZERO_NULL, /* disconnect */
-+ ZERO_NULL, /* write_resp */
-+ ZERO_NULL, /* write_resp_hd */
-+ ZERO_NULL, /* connection_check */
-+ ZERO_NULL, /* attach connection */
-+ ZERO_NULL, /* follow */
-+ PORT_TFTP, /* defport */
-+ CURLPROTO_TFTP, /* protocol */
-+ CURLPROTO_TFTP, /* family */
-+ PROTOPT_NOTCPPROXY | PROTOPT_NOURLQUERY /* flags */
-+};
-+
- #endif
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 6475055e1e..26bf95df64 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -229,7 +229,7 @@ test1680 test1681 test1682 test1683 \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 test1711 \
- \
--test1800 test1801 test1802 \
-+test1800 test1801 test1802 test1850 \
- \
- test1900 test1901 test1902 test1903 test1904 test1905 test1906 test1907 \
- test1908 test1909 test1910 test1911 test1912 test1913 test1914 test1915 \
-diff --git a/tests/data/test1850 b/tests/data/test1850
-new file mode 100644
-index 0000000000..6a3e4d409b
---- /dev/null
-+++ b/tests/data/test1850
-@@ -0,0 +1,39 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+SMB
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+<data nocheck="yes">
-+Basic SMB test complete
-+</data>
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+smb
-+</server>
-+<features>
-+smb
-+</features>
-+<name>
-+Two SMB requests in the same command line
-+</name>
-+<command>
-+-u 'curltest:curltest' smb://%HOSTIP:%SMBPORT/TESTS/%TESTNUMBER smb://%HOSTIP:%SMBPORT/TESTS/%TESTNUMBER
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<stdout>
-+Basic SMB test complete
-+Basic SMB test complete
-+</stdout>
-+</verify>
-+</testcase>
---
-2.53.0
-
diff --git a/0007-CVE-2026-3805.patch b/0007-CVE-2026-3805.patch
new file mode 100644
index 0000000..63dc13b
--- /dev/null
+++ b/0007-CVE-2026-3805.patch
@@ -0,0 +1,2284 @@
+From ff0992185698f35c27fdb729b9ce0c1ef604a797 Mon Sep 17 00:00:00 2001
+From: Viktor Szakats <commit@vsz.me>
+Date: Sun, 21 Dec 2025 16:19:52 +0100
+Subject: [PATCH] CVE-2026-3805
+
+lib: reorder protocol functions to avoid forward declarations (misc)
+
+For protocols: dict, file, gopher, tftp, http, mqtt, smb.
+
+Move protocol hander table to the end of sources, rearrange static
+functions is reverse dependency order as necessary.
+
+Closes #20274
+
+(cherry picked from commit 07926b59828936117a7c6662f850bc09edb14357)
+
+smb: free the path in the request struct properly
+
+Closes #20854
+
+(cherry picked from commit e090be9f73a7a71459ef678c7cc4b1f75e3ea883)
+
+test1850: verify the SMB request path use for two transfers
+
+(cherry picked from commit 1f8cfa049d7a0ea595863abf0230198972873ad6)
+---
+ lib/dict.c | 64 ++--
+ lib/file.c | 97 +++---
+ lib/gopher.c | 125 ++++---
+ lib/http.c | 616 +++++++++++++++++------------------
+ lib/mqtt.c | 71 ++--
+ lib/smb.c | 219 ++++++-------
+ lib/tftp.c | 718 ++++++++++++++++++++---------------------
+ tests/data/Makefile.am | 2 +-
+ tests/data/test1850 | 39 +++
+ 9 files changed, 948 insertions(+), 1003 deletions(-)
+ create mode 100644 tests/data/test1850
+
+diff --git a/lib/dict.c b/lib/dict.c
+index 5839e804c2..54563b4e45 100644
+--- a/lib/dict.c
++++ b/lib/dict.c
+@@ -65,41 +65,6 @@
+ #define DICT_DEFINE3 "/LOOKUP:"
+
+
+-/*
+- * Forward declarations.
+- */
+-
+-static CURLcode dict_do(struct Curl_easy *data, bool *done);
+-
+-/*
+- * DICT protocol handler.
+- */
+-
+-const struct Curl_handler Curl_handler_dict = {
+- "dict", /* scheme */
+- ZERO_NULL, /* setup_connection */
+- dict_do, /* do_it */
+- ZERO_NULL, /* done */
+- ZERO_NULL, /* do_more */
+- ZERO_NULL, /* connect_it */
+- ZERO_NULL, /* connecting */
+- ZERO_NULL, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- ZERO_NULL, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_DICT, /* defport */
+- CURLPROTO_DICT, /* protocol */
+- CURLPROTO_DICT, /* family */
+- PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
+-};
+-
+ #define DYN_DICT_WORD 10000
+ static char *unescape_word(const char *input)
+ {
+@@ -306,4 +271,33 @@ error:
+ curlx_free(path);
+ return result;
+ }
++
++/*
++ * DICT protocol handler.
++ */
++const struct Curl_handler Curl_handler_dict = {
++ "dict", /* scheme */
++ ZERO_NULL, /* setup_connection */
++ dict_do, /* do_it */
++ ZERO_NULL, /* done */
++ ZERO_NULL, /* do_more */
++ ZERO_NULL, /* connect_it */
++ ZERO_NULL, /* connecting */
++ ZERO_NULL, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ ZERO_NULL, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_DICT, /* defport */
++ CURLPROTO_DICT, /* protocol */
++ CURLPROTO_DICT, /* family */
++ PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
++};
++
+ #endif /* CURL_DISABLE_DICT */
+diff --git a/lib/file.c b/lib/file.c
+index 982f254b2d..9ba536bf2e 100644
+--- a/lib/file.c
++++ b/lib/file.c
+@@ -82,49 +82,6 @@ struct FILEPROTO {
+ int fd; /* open file descriptor to read from! */
+ };
+
+-/*
+- * Forward declarations.
+- */
+-
+-static CURLcode file_do(struct Curl_easy *data, bool *done);
+-static CURLcode file_done(struct Curl_easy *data,
+- CURLcode status, bool premature);
+-static CURLcode file_connect(struct Curl_easy *data, bool *done);
+-static CURLcode file_disconnect(struct Curl_easy *data,
+- struct connectdata *conn,
+- bool dead_connection);
+-static CURLcode file_setup_connection(struct Curl_easy *data,
+- struct connectdata *conn);
+-
+-/*
+- * FILE scheme handler.
+- */
+-
+-const struct Curl_handler Curl_handler_file = {
+- "file", /* scheme */
+- file_setup_connection, /* setup_connection */
+- file_do, /* do_it */
+- file_done, /* done */
+- ZERO_NULL, /* do_more */
+- file_connect, /* connect_it */
+- ZERO_NULL, /* connecting */
+- ZERO_NULL, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- ZERO_NULL, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- file_disconnect, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- 0, /* defport */
+- CURLPROTO_FILE, /* protocol */
+- CURLPROTO_FILE, /* family */
+- PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
+-};
+-
+ static void file_cleanup(struct FILEPROTO *file)
+ {
+ Curl_safefree(file->freepath);
+@@ -158,6 +115,19 @@ static CURLcode file_setup_connection(struct Curl_easy *data,
+ return CURLE_OK;
+ }
+
++static CURLcode file_done(struct Curl_easy *data,
++ CURLcode status, bool premature)
++{
++ struct FILEPROTO *file = Curl_meta_get(data, CURL_META_FILE_EASY);
++ (void)status;
++ (void)premature;
++
++ if(file)
++ file_cleanup(file);
++
++ return CURLE_OK;
++}
++
+ /*
+ * file_connect() gets called from Curl_protocol_connect() to allow us to
+ * do protocol-specific actions at connect-time. We emulate a
+@@ -276,19 +246,6 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
+ return CURLE_OK;
+ }
+
+-static CURLcode file_done(struct Curl_easy *data,
+- CURLcode status, bool premature)
+-{
+- struct FILEPROTO *file = Curl_meta_get(data, CURL_META_FILE_EASY);
+- (void)status;
+- (void)premature;
+-
+- if(file)
+- file_cleanup(file);
+-
+- return CURLE_OK;
+-}
+-
+ static CURLcode file_disconnect(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool dead_connection)
+@@ -648,4 +605,32 @@ out:
+ return result;
+ }
+
++/*
++ * FILE scheme handler.
++ */
++const struct Curl_handler Curl_handler_file = {
++ "file", /* scheme */
++ file_setup_connection, /* setup_connection */
++ file_do, /* do_it */
++ file_done, /* done */
++ ZERO_NULL, /* do_more */
++ file_connect, /* connect_it */
++ ZERO_NULL, /* connecting */
++ ZERO_NULL, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ ZERO_NULL, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ file_disconnect, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ 0, /* defport */
++ CURLPROTO_FILE, /* protocol */
++ CURLPROTO_FILE, /* family */
++ PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
++};
++
+ #endif
+diff --git a/lib/gopher.c b/lib/gopher.c
+index 186530de9f..9d35c68f31 100644
+--- a/lib/gopher.c
++++ b/lib/gopher.c
+@@ -36,73 +36,7 @@
+ #include "url.h"
+ #include "escape.h"
+
+-/*
+- * Forward declarations.
+- */
+-
+-static CURLcode gopher_do(struct Curl_easy *data, bool *done);
+ #ifdef USE_SSL
+-static CURLcode gopher_connect(struct Curl_easy *data, bool *done);
+-static CURLcode gopher_connecting(struct Curl_easy *data, bool *done);
+-#endif
+-
+-/*
+- * Gopher protocol handler.
+- * This is also a nice simple template to build off for simple
+- * connect-command-download protocols.
+- */
+-
+-const struct Curl_handler Curl_handler_gopher = {
+- "gopher", /* scheme */
+- ZERO_NULL, /* setup_connection */
+- gopher_do, /* do_it */
+- ZERO_NULL, /* done */
+- ZERO_NULL, /* do_more */
+- ZERO_NULL, /* connect_it */
+- ZERO_NULL, /* connecting */
+- ZERO_NULL, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- ZERO_NULL, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_GOPHER, /* defport */
+- CURLPROTO_GOPHER, /* protocol */
+- CURLPROTO_GOPHER, /* family */
+- PROTOPT_NONE /* flags */
+-};
+-
+-#ifdef USE_SSL
+-const struct Curl_handler Curl_handler_gophers = {
+- "gophers", /* scheme */
+- ZERO_NULL, /* setup_connection */
+- gopher_do, /* do_it */
+- ZERO_NULL, /* done */
+- ZERO_NULL, /* do_more */
+- gopher_connect, /* connect_it */
+- gopher_connecting, /* connecting */
+- ZERO_NULL, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- ZERO_NULL, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_GOPHER, /* defport */
+- CURLPROTO_GOPHERS, /* protocol */
+- CURLPROTO_GOPHER, /* family */
+- PROTOPT_SSL /* flags */
+-};
+-
+ static CURLcode gopher_connect(struct Curl_easy *data, bool *done)
+ {
+ (void)data;
+@@ -231,4 +165,63 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
+ Curl_xfer_setup_recv(data, FIRSTSOCKET, -1);
+ return CURLE_OK;
+ }
++
++/*
++ * Gopher protocol handler.
++ * This is also a nice simple template to build off for simple
++ * connect-command-download protocols.
++ */
++
++const struct Curl_handler Curl_handler_gopher = {
++ "gopher", /* scheme */
++ ZERO_NULL, /* setup_connection */
++ gopher_do, /* do_it */
++ ZERO_NULL, /* done */
++ ZERO_NULL, /* do_more */
++ ZERO_NULL, /* connect_it */
++ ZERO_NULL, /* connecting */
++ ZERO_NULL, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ ZERO_NULL, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_GOPHER, /* defport */
++ CURLPROTO_GOPHER, /* protocol */
++ CURLPROTO_GOPHER, /* family */
++ PROTOPT_NONE /* flags */
++};
++
++#ifdef USE_SSL
++const struct Curl_handler Curl_handler_gophers = {
++ "gophers", /* scheme */
++ ZERO_NULL, /* setup_connection */
++ gopher_do, /* do_it */
++ ZERO_NULL, /* done */
++ ZERO_NULL, /* do_more */
++ gopher_connect, /* connect_it */
++ gopher_connecting, /* connecting */
++ ZERO_NULL, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ ZERO_NULL, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_GOPHER, /* defport */
++ CURLPROTO_GOPHERS, /* protocol */
++ CURLPROTO_GOPHER, /* family */
++ PROTOPT_SSL /* flags */
++};
++#endif
++
+ #endif /* CURL_DISABLE_GOPHER */
+diff --git a/lib/http.c b/lib/http.c
+index 5efa6a196e..e429e2eacf 100644
+--- a/lib/http.c
++++ b/lib/http.c
+@@ -85,94 +85,6 @@
+ #include "bufref.h"
+ #include "curlx/strparse.h"
+
+-/*
+- * Forward declarations.
+- */
+-
+-static bool http_should_fail(struct Curl_easy *data, int httpcode);
+-static bool http_exp100_is_waiting(struct Curl_easy *data);
+-static CURLcode http_exp100_add_reader(struct Curl_easy *data);
+-static void http_exp100_send_anyway(struct Curl_easy *data);
+-static bool http_exp100_is_selected(struct Curl_easy *data);
+-static void http_exp100_got100(struct Curl_easy *data);
+-static CURLcode http_firstwrite(struct Curl_easy *data);
+-static CURLcode http_header(struct Curl_easy *data,
+- const char *hd, size_t hdlen);
+-static CURLcode http_range(struct Curl_easy *data,
+- Curl_HttpReq httpreq);
+-static CURLcode http_req_set_TE(struct Curl_easy *data,
+- struct dynbuf *req,
+- int httpversion);
+-static CURLcode http_size(struct Curl_easy *data);
+-static CURLcode http_statusline(struct Curl_easy *data,
+- struct connectdata *conn);
+-static CURLcode http_target(struct Curl_easy *data, struct dynbuf *req);
+-static CURLcode http_useragent(struct Curl_easy *data);
+-static CURLcode http_write_header(struct Curl_easy *data,
+- const char *hd, size_t hdlen);
+-
+-/*
+- * HTTP handler interface.
+- */
+-const struct Curl_handler Curl_handler_http = {
+- "http", /* scheme */
+- Curl_http_setup_conn, /* setup_connection */
+- Curl_http, /* do_it */
+- Curl_http_done, /* done */
+- ZERO_NULL, /* do_more */
+- ZERO_NULL, /* connect_it */
+- ZERO_NULL, /* connecting */
+- ZERO_NULL, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- Curl_http_doing_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- Curl_http_perform_pollset, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- Curl_http_write_resp, /* write_resp */
+- Curl_http_write_resp_hd, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- Curl_http_follow, /* follow */
+- PORT_HTTP, /* defport */
+- CURLPROTO_HTTP, /* protocol */
+- CURLPROTO_HTTP, /* family */
+- PROTOPT_CREDSPERREQUEST | /* flags */
+- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+-
+-};
+-
+-#ifdef USE_SSL
+-/*
+- * HTTPS handler interface.
+- */
+-const struct Curl_handler Curl_handler_https = {
+- "https", /* scheme */
+- Curl_http_setup_conn, /* setup_connection */
+- Curl_http, /* do_it */
+- Curl_http_done, /* done */
+- ZERO_NULL, /* do_more */
+- ZERO_NULL, /* connect_it */
+- NULL, /* connecting */
+- ZERO_NULL, /* doing */
+- NULL, /* proto_pollset */
+- Curl_http_doing_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- Curl_http_perform_pollset, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- Curl_http_write_resp, /* write_resp */
+- Curl_http_write_resp_hd, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- Curl_http_follow, /* follow */
+- PORT_HTTPS, /* defport */
+- CURLPROTO_HTTPS, /* protocol */
+- CURLPROTO_HTTP, /* family */
+- PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
+- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+-};
+-
+-#endif
+-
+ void Curl_http_neg_init(struct Curl_easy *data, struct http_negotiation *neg)
+ {
+ memset(neg, 0, sizeof(*neg));
+@@ -547,13 +459,83 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data,
+ return CURLE_OK;
+ }
+
++/**
++ * http_should_fail() determines whether an HTTP response code has gotten us
++ * into an error state or not.
++ *
++ * @retval FALSE communications should continue
++ *
++ * @retval TRUE communications should not continue
++ */
++static bool http_should_fail(struct Curl_easy *data, int httpcode)
++{
++ DEBUGASSERT(data);
++ DEBUGASSERT(data->conn);
++
++ /*
++ ** If we have not been asked to fail on error,
++ ** do not fail.
++ */
++ if(!data->set.http_fail_on_error)
++ return FALSE;
++
++ /*
++ ** Any code < 400 is never terminal.
++ */
++ if(httpcode < 400)
++ return FALSE;
++
++ /*
++ ** A 416 response to a resume request is presumably because the file is
++ ** already completely downloaded and thus not actually a fail.
++ */
++ if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
++ httpcode == 416)
++ return FALSE;
++
++ /*
++ ** Any code >= 400 that is not 401 or 407 is always
++ ** a terminal error
++ */
++ if((httpcode != 401) && (httpcode != 407))
++ return TRUE;
++
++ /*
++ ** All we have left to deal with is 401 and 407
++ */
++ DEBUGASSERT((httpcode == 401) || (httpcode == 407));
++
++ /*
++ ** Examine the current authentication state to see if this is an error. The
++ ** idea is for this function to get called after processing all the headers
++ ** in a response message. So, if we have been to asked to authenticate a
++ ** particular stage, and we have done it, we are OK. If we are already
++ ** completely authenticated, it is not OK to get another 401 or 407.
++ **
++ ** It is possible for authentication to go stale such that the client needs
++ ** to reauthenticate. Once that info is available, use it here.
++ */
++
++ /*
++ ** Either we are not authenticating, or we are supposed to be authenticating
++ ** something else. This is an error.
++ */
++ if((httpcode == 401) && !data->state.aptr.user)
++ return TRUE;
++#ifndef CURL_DISABLE_PROXY
++ if((httpcode == 407) && !data->conn->bits.proxy_user_passwd)
++ return TRUE;
++#endif
++
++ return data->state.authproblem;
++}
++
+ /*
+ * Curl_http_auth_act() gets called when all HTTP headers have been received
+ * and it checks what authentication methods that are available and decides
+ * which one (if any) to use. It will set 'newurl' if an auth method was
+ * picked.
+ */
+-
+ CURLcode Curl_http_auth_act(struct Curl_easy *data)
+ {
+ struct connectdata *conn = data->conn;
+@@ -1117,77 +1099,6 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
+ #endif
+ }
+
+-/**
+- * http_should_fail() determines whether an HTTP response code has gotten us
+- * into an error state or not.
+- *
+- * @retval FALSE communications should continue
+- *
+- * @retval TRUE communications should not continue
+- */
+-static bool http_should_fail(struct Curl_easy *data, int httpcode)
+-{
+- DEBUGASSERT(data);
+- DEBUGASSERT(data->conn);
+-
+- /*
+- ** If we have not been asked to fail on error,
+- ** do not fail.
+- */
+- if(!data->set.http_fail_on_error)
+- return FALSE;
+-
+- /*
+- ** Any code < 400 is never terminal.
+- */
+- if(httpcode < 400)
+- return FALSE;
+-
+- /*
+- ** A 416 response to a resume request is presumably because the file is
+- ** already completely downloaded and thus not actually a fail.
+- */
+- if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
+- httpcode == 416)
+- return FALSE;
+-
+- /*
+- ** Any code >= 400 that is not 401 or 407 is always
+- ** a terminal error
+- */
+- if((httpcode != 401) && (httpcode != 407))
+- return TRUE;
+-
+- /*
+- ** All we have left to deal with is 401 and 407
+- */
+- DEBUGASSERT((httpcode == 401) || (httpcode == 407));
+-
+- /*
+- ** Examine the current authentication state to see if this is an error. The
+- ** idea is for this function to get called after processing all the headers
+- ** in a response message. So, if we have been to asked to authenticate a
+- ** particular stage, and we have done it, we are OK. If we are already
+- ** completely authenticated, it is not OK to get another 401 or 407.
+- **
+- ** It is possible for authentication to go stale such that the client needs
+- ** to reauthenticate. Once that info is available, use it here.
+- */
+-
+- /*
+- ** Either we are not authenticating, or we are supposed to be authenticating
+- ** something else. This is an error.
+- */
+- if((httpcode == 401) && !data->state.aptr.user)
+- return TRUE;
+-#ifndef CURL_DISABLE_PROXY
+- if((httpcode == 407) && !data->conn->bits.proxy_user_passwd)
+- return TRUE;
+-#endif
+-
+- return data->state.authproblem;
+-}
+-
+ static void http_switch_to_get(struct Curl_easy *data, int code)
+ {
+ const char *req = data->set.str[STRING_CUSTOMREQUEST];
+@@ -1533,6 +1444,145 @@ bool Curl_compareheader(const char *headerline, /* line to check */
+ return FALSE; /* no match */
+ }
+
++struct cr_exp100_ctx {
++ struct Curl_creader super;
++ struct curltime start; /* time started waiting */
++ enum expect100 state;
++};
++
++/* Expect: 100-continue client reader, blocking uploads */
++
++static void http_exp100_continue(struct Curl_easy *data,
++ struct Curl_creader *reader)
++{
++ struct cr_exp100_ctx *ctx = reader->ctx;
++ if(ctx->state > EXP100_SEND_DATA) {
++ ctx->state = EXP100_SEND_DATA;
++ Curl_expire_done(data, EXPIRE_100_TIMEOUT);
++ }
++}
++
++static CURLcode cr_exp100_read(struct Curl_easy *data,
++ struct Curl_creader *reader,
++ char *buf, size_t blen,
++ size_t *nread, bool *eos)
++{
++ struct cr_exp100_ctx *ctx = reader->ctx;
++ timediff_t ms;
++
++ switch(ctx->state) {
++ case EXP100_SENDING_REQUEST:
++ if(!Curl_req_sendbuf_empty(data)) {
++ /* The initial request data has not been fully sent yet. Do
++ * not start the timer yet. */
++ DEBUGF(infof(data, "cr_exp100_read, request not full sent yet"));
++ *nread = 0;
++ *eos = FALSE;
++ return CURLE_OK;
++ }
++ /* We are now waiting for a reply from the server or
++ * a timeout on our side IFF the request has been fully sent. */
++ DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, "
++ "timeout %dms", data->set.expect_100_timeout));
++ ctx->state = EXP100_AWAITING_CONTINUE;
++ ctx->start = *Curl_pgrs_now(data);
++ Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
++ *nread = 0;
++ *eos = FALSE;
++ return CURLE_OK;
++ case EXP100_FAILED:
++ DEBUGF(infof(data, "cr_exp100_read, expectation failed, error"));
++ *nread = 0;
++ *eos = FALSE;
++ return CURLE_READ_ERROR;
++ case EXP100_AWAITING_CONTINUE:
++ ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &ctx->start);
++ if(ms < data->set.expect_100_timeout) {
++ DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
++ *nread = 0;
++ *eos = FALSE;
++ return CURLE_OK;
++ }
++ /* we have waited long enough, continue anyway */
++ http_exp100_continue(data, reader);
++ infof(data, "Done waiting for 100-continue");
++ FALLTHROUGH();
++ default:
++ DEBUGF(infof(data, "cr_exp100_read, pass through"));
++ return Curl_creader_read(data, reader->next, buf, blen, nread, eos);
++ }
++}
++
++static void cr_exp100_done(struct Curl_easy *data,
++ struct Curl_creader *reader, int premature)
++{
++ struct cr_exp100_ctx *ctx = reader->ctx;
++ ctx->state = premature ? EXP100_FAILED : EXP100_SEND_DATA;
++ Curl_expire_done(data, EXPIRE_100_TIMEOUT);
++}
++
++static const struct Curl_crtype cr_exp100 = {
++ "cr-exp100",
++ Curl_creader_def_init,
++ cr_exp100_read,
++ Curl_creader_def_close,
++ Curl_creader_def_needs_rewind,
++ Curl_creader_def_total_length,
++ Curl_creader_def_resume_from,
++ Curl_creader_def_cntrl,
++ Curl_creader_def_is_paused,
++ cr_exp100_done,
++ sizeof(struct cr_exp100_ctx)
++};
++
++static CURLcode http_exp100_add_reader(struct Curl_easy *data)
++{
++ struct Curl_creader *reader = NULL;
++ CURLcode result;
++
++ result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
++ if(!result)
++ result = Curl_creader_add(data, reader);
++ if(!result) {
++ struct cr_exp100_ctx *ctx = reader->ctx;
++ ctx->state = EXP100_SENDING_REQUEST;
++ }
++
++ if(result && reader)
++ Curl_creader_free(data, reader);
++ return result;
++}
++
++static void http_exp100_got100(struct Curl_easy *data)
++{
++ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
++ if(r)
++ http_exp100_continue(data, r);
++}
++
++static bool http_exp100_is_waiting(struct Curl_easy *data)
++{
++ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
++ if(r) {
++ struct cr_exp100_ctx *ctx = r->ctx;
++ return ctx->state == EXP100_AWAITING_CONTINUE;
++ }
++ return FALSE;
++}
++
++static void http_exp100_send_anyway(struct Curl_easy *data)
++{
++ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
++ if(r)
++ http_exp100_continue(data, r);
++}
++
++static bool http_exp100_is_selected(struct Curl_easy *data)
++{
++ struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
++ return !!r;
++}
++
+ /* this returns the socket to wait for in the DO and DOING state for the multi
+ interface and then we are always _sending_ a request and thus we wait for
+ the single socket to become writable only */
+@@ -1560,6 +1610,33 @@ CURLcode Curl_http_perform_pollset(struct Curl_easy *data,
+ return result;
+ }
+
++static CURLcode http_write_header(struct Curl_easy *data,
++ const char *hd, size_t hdlen)
++{
++ CURLcode result;
++ int writetype;
++
++ /* now, only output this if the header AND body are requested:
++ */
++ Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
++
++ writetype = CLIENTWRITE_HEADER |
++ ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
++
++ result = Curl_client_write(data, writetype, hd, hdlen);
++ if(result)
++ return result;
++
++ result = Curl_bump_headersize(data, hdlen, FALSE);
++ if(result)
++ return result;
++
++ data->req.deductheadercount = (100 <= data->req.httpcode &&
++ 199 >= data->req.httpcode) ?
++ data->req.headerbytecount : 0;
++ return result;
++}
++
+ /*
+ * Curl_http_done() gets called after a single HTTP request has been
+ * performed.
+@@ -3801,33 +3878,6 @@ CURLcode Curl_bump_headersize(struct Curl_easy *data,
+ return CURLE_OK;
+ }
+
+-static CURLcode http_write_header(struct Curl_easy *data,
+- const char *hd, size_t hdlen)
+-{
+- CURLcode result;
+- int writetype;
+-
+- /* now, only output this if the header AND body are requested:
+- */
+- Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
+-
+- writetype = CLIENTWRITE_HEADER |
+- ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
+-
+- result = Curl_client_write(data, writetype, hd, hdlen);
+- if(result)
+- return result;
+-
+- result = Curl_bump_headersize(data, hdlen, FALSE);
+- if(result)
+- return result;
+-
+- data->req.deductheadercount = (100 <= data->req.httpcode &&
+- 199 >= data->req.httpcode) ?
+- data->req.headerbytecount : 0;
+- return result;
+-}
+-
+ static CURLcode http_on_response(struct Curl_easy *data,
+ const char *last_hd, size_t last_hd_len,
+ const char *buf, size_t blen,
+@@ -4932,143 +4982,65 @@ void Curl_http_resp_free(struct http_resp *resp)
+ }
+ }
+
+-struct cr_exp100_ctx {
+- struct Curl_creader super;
+- struct curltime start; /* time started waiting */
+- enum expect100 state;
+-};
+-
+-/* Expect: 100-continue client reader, blocking uploads */
+-
+-static void http_exp100_continue(struct Curl_easy *data,
+- struct Curl_creader *reader)
+-{
+- struct cr_exp100_ctx *ctx = reader->ctx;
+- if(ctx->state > EXP100_SEND_DATA) {
+- ctx->state = EXP100_SEND_DATA;
+- Curl_expire_done(data, EXPIRE_100_TIMEOUT);
+- }
+-}
+-
+-static CURLcode cr_exp100_read(struct Curl_easy *data,
+- struct Curl_creader *reader,
+- char *buf, size_t blen,
+- size_t *nread, bool *eos)
+-{
+- struct cr_exp100_ctx *ctx = reader->ctx;
+- timediff_t ms;
+-
+- switch(ctx->state) {
+- case EXP100_SENDING_REQUEST:
+- if(!Curl_req_sendbuf_empty(data)) {
+- /* The initial request data has not been fully sent yet. Do
+- * not start the timer yet. */
+- DEBUGF(infof(data, "cr_exp100_read, request not full sent yet"));
+- *nread = 0;
+- *eos = FALSE;
+- return CURLE_OK;
+- }
+- /* We are now waiting for a reply from the server or
+- * a timeout on our side IFF the request has been fully sent. */
+- DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, "
+- "timeout %dms", data->set.expect_100_timeout));
+- ctx->state = EXP100_AWAITING_CONTINUE;
+- ctx->start = *Curl_pgrs_now(data);
+- Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
+- *nread = 0;
+- *eos = FALSE;
+- return CURLE_OK;
+- case EXP100_FAILED:
+- DEBUGF(infof(data, "cr_exp100_read, expectation failed, error"));
+- *nread = 0;
+- *eos = FALSE;
+- return CURLE_READ_ERROR;
+- case EXP100_AWAITING_CONTINUE:
+- ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &ctx->start);
+- if(ms < data->set.expect_100_timeout) {
+- DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired"));
+- *nread = 0;
+- *eos = FALSE;
+- return CURLE_OK;
+- }
+- /* we have waited long enough, continue anyway */
+- http_exp100_continue(data, reader);
+- infof(data, "Done waiting for 100-continue");
+- FALLTHROUGH();
+- default:
+- DEBUGF(infof(data, "cr_exp100_read, pass through"));
+- return Curl_creader_read(data, reader->next, buf, blen, nread, eos);
+- }
+-}
+-
+-static void cr_exp100_done(struct Curl_easy *data,
+- struct Curl_creader *reader, int premature)
+-{
+- struct cr_exp100_ctx *ctx = reader->ctx;
+- ctx->state = premature ? EXP100_FAILED : EXP100_SEND_DATA;
+- Curl_expire_done(data, EXPIRE_100_TIMEOUT);
+-}
++/*
++ * HTTP handler interface.
++ */
++const struct Curl_handler Curl_handler_http = {
++ "http", /* scheme */
++ Curl_http_setup_conn, /* setup_connection */
++ Curl_http, /* do_it */
++ Curl_http_done, /* done */
++ ZERO_NULL, /* do_more */
++ ZERO_NULL, /* connect_it */
++ ZERO_NULL, /* connecting */
++ ZERO_NULL, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ Curl_http_doing_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ Curl_http_perform_pollset, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ Curl_http_write_resp, /* write_resp */
++ Curl_http_write_resp_hd, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ Curl_http_follow, /* follow */
++ PORT_HTTP, /* defport */
++ CURLPROTO_HTTP, /* protocol */
++ CURLPROTO_HTTP, /* family */
++ PROTOPT_CREDSPERREQUEST | /* flags */
++ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+
+-static const struct Curl_crtype cr_exp100 = {
+- "cr-exp100",
+- Curl_creader_def_init,
+- cr_exp100_read,
+- Curl_creader_def_close,
+- Curl_creader_def_needs_rewind,
+- Curl_creader_def_total_length,
+- Curl_creader_def_resume_from,
+- Curl_creader_def_cntrl,
+- Curl_creader_def_is_paused,
+- cr_exp100_done,
+- sizeof(struct cr_exp100_ctx)
+ };
+
+-static CURLcode http_exp100_add_reader(struct Curl_easy *data)
+-{
+- struct Curl_creader *reader = NULL;
+- CURLcode result;
+-
+- result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
+- if(!result)
+- result = Curl_creader_add(data, reader);
+- if(!result) {
+- struct cr_exp100_ctx *ctx = reader->ctx;
+- ctx->state = EXP100_SENDING_REQUEST;
+- }
+-
+- if(result && reader)
+- Curl_creader_free(data, reader);
+- return result;
+-}
+-
+-static void http_exp100_got100(struct Curl_easy *data)
+-{
+- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
+- if(r)
+- http_exp100_continue(data, r);
+-}
+-
+-static bool http_exp100_is_waiting(struct Curl_easy *data)
+-{
+- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
+- if(r) {
+- struct cr_exp100_ctx *ctx = r->ctx;
+- return ctx->state == EXP100_AWAITING_CONTINUE;
+- }
+- return FALSE;
+-}
+-
+-static void http_exp100_send_anyway(struct Curl_easy *data)
+-{
+- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
+- if(r)
+- http_exp100_continue(data, r);
+-}
+-
+-static bool http_exp100_is_selected(struct Curl_easy *data)
+-{
+- struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100);
+- return !!r;
+-}
++#ifdef USE_SSL
++/*
++ * HTTPS handler interface.
++ */
++const struct Curl_handler Curl_handler_https = {
++ "https", /* scheme */
++ Curl_http_setup_conn, /* setup_connection */
++ Curl_http, /* do_it */
++ Curl_http_done, /* done */
++ ZERO_NULL, /* do_more */
++ ZERO_NULL, /* connect_it */
++ NULL, /* connecting */
++ ZERO_NULL, /* doing */
++ NULL, /* proto_pollset */
++ Curl_http_doing_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ Curl_http_perform_pollset, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ Curl_http_write_resp, /* write_resp */
++ Curl_http_write_resp_hd, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ Curl_http_follow, /* follow */
++ PORT_HTTPS, /* defport */
++ CURLPROTO_HTTPS, /* protocol */
++ CURLPROTO_HTTP, /* family */
++ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
++ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
++};
++#endif
+
+ #endif /* CURL_DISABLE_HTTP */
+diff --git a/lib/mqtt.c b/lib/mqtt.c
+index 2ba1ca73e9..5f5c91a49a 100644
+--- a/lib/mqtt.c
++++ b/lib/mqtt.c
+@@ -89,48 +89,6 @@ struct MQTT {
+ BIT(pingsent); /* 1 while we wait for ping response */
+ };
+
+-/*
+- * Forward declarations.
+- */
+-
+-static CURLcode mqtt_do(struct Curl_easy *data, bool *done);
+-static CURLcode mqtt_done(struct Curl_easy *data,
+- CURLcode status, bool premature);
+-static CURLcode mqtt_doing(struct Curl_easy *data, bool *done);
+-static CURLcode mqtt_pollset(struct Curl_easy *data,
+- struct easy_pollset *ps);
+-static CURLcode mqtt_setup_conn(struct Curl_easy *data,
+- struct connectdata *conn);
+-
+-/*
+- * MQTT protocol handler.
+- */
+-
+-const struct Curl_handler Curl_handler_mqtt = {
+- "mqtt", /* scheme */
+- mqtt_setup_conn, /* setup_connection */
+- mqtt_do, /* do_it */
+- mqtt_done, /* done */
+- ZERO_NULL, /* do_more */
+- ZERO_NULL, /* connect_it */
+- ZERO_NULL, /* connecting */
+- mqtt_doing, /* doing */
+- ZERO_NULL, /* proto_pollset */
+- mqtt_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_MQTT, /* defport */
+- CURLPROTO_MQTT, /* protocol */
+- CURLPROTO_MQTT, /* family */
+- PROTOPT_NONE /* flags */
+-};
+-
+ static void mqtt_easy_dtor(void *key, size_t klen, void *entry)
+ {
+ struct MQTT *mq = entry;
+@@ -976,4 +934,33 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done)
+ return result;
+ }
+
++/*
++ * MQTT protocol handler.
++ */
++
++const struct Curl_handler Curl_handler_mqtt = {
++ "mqtt", /* scheme */
++ mqtt_setup_conn, /* setup_connection */
++ mqtt_do, /* do_it */
++ mqtt_done, /* done */
++ ZERO_NULL, /* do_more */
++ ZERO_NULL, /* connect_it */
++ ZERO_NULL, /* connecting */
++ mqtt_doing, /* doing */
++ ZERO_NULL, /* proto_pollset */
++ mqtt_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_MQTT, /* defport */
++ CURLPROTO_MQTT, /* protocol */
++ CURLPROTO_MQTT, /* family */
++ PROTOPT_NONE /* flags */
++};
++
+ #endif /* CURL_DISABLE_MQTT */
+diff --git a/lib/smb.c b/lib/smb.c
+index 003a38f19f..23fc4596dc 100644
+--- a/lib/smb.c
++++ b/lib/smb.c
+@@ -285,77 +285,6 @@ struct smb_tree_disconnect {
+ # pragma pack(pop)
+ #endif
+
+-/* Local API functions */
+-static CURLcode smb_setup_connection(struct Curl_easy *data,
+- struct connectdata *conn);
+-static CURLcode smb_connect(struct Curl_easy *data, bool *done);
+-static CURLcode smb_connection_state(struct Curl_easy *data, bool *done);
+-static CURLcode smb_do(struct Curl_easy *data, bool *done);
+-static CURLcode smb_request_state(struct Curl_easy *data, bool *done);
+-static CURLcode smb_pollset(struct Curl_easy *data,
+- struct easy_pollset *ps);
+-static CURLcode smb_parse_url_path(struct Curl_easy *data,
+- struct smb_conn *smbc,
+- struct smb_request *req);
+-
+-/*
+- * SMB handler interface
+- */
+-const struct Curl_handler Curl_handler_smb = {
+- "smb", /* scheme */
+- smb_setup_connection, /* setup_connection */
+- smb_do, /* do_it */
+- ZERO_NULL, /* done */
+- ZERO_NULL, /* do_more */
+- smb_connect, /* connect_it */
+- smb_connection_state, /* connecting */
+- smb_request_state, /* doing */
+- smb_pollset, /* proto_pollset */
+- smb_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_SMB, /* defport */
+- CURLPROTO_SMB, /* protocol */
+- CURLPROTO_SMB, /* family */
+- PROTOPT_CONN_REUSE /* flags */
+-};
+-
+-#ifdef USE_SSL
+-/*
+- * SMBS handler interface
+- */
+-const struct Curl_handler Curl_handler_smbs = {
+- "smbs", /* scheme */
+- smb_setup_connection, /* setup_connection */
+- smb_do, /* do_it */
+- ZERO_NULL, /* done */
+- ZERO_NULL, /* do_more */
+- smb_connect, /* connect_it */
+- smb_connection_state, /* connecting */
+- smb_request_state, /* doing */
+- smb_pollset, /* proto_pollset */
+- smb_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_SMBS, /* defport */
+- CURLPROTO_SMBS, /* protocol */
+- CURLPROTO_SMB, /* family */
+- PROTOPT_SSL | PROTOPT_CONN_REUSE /* flags */
+-};
+-#endif
+-
+ #define MAX_PAYLOAD_SIZE 0x8000
+ #define MAX_MESSAGE_SIZE (MAX_PAYLOAD_SIZE + 0x1000)
+ #define CLIENTNAME "curl"
+@@ -442,9 +371,7 @@ static void smb_easy_dtor(void *key, size_t klen, void *entry)
+ struct smb_request *req = entry;
+ (void)key;
+ (void)klen;
+- /* `req->path` points to somewhere in `struct smb_conn` which is
+- * kept at the connection meta. If the connection is destroyed first,
+- * req->path points to free'd memory. */
++ Curl_safefree(req->path);
+ curlx_free(req);
+ }
+
+@@ -460,6 +387,53 @@ static void smb_conn_dtor(void *key, size_t klen, void *entry)
+ curlx_free(smbc);
+ }
+
++static CURLcode smb_parse_url_path(struct Curl_easy *data,
++ struct smb_conn *smbc,
++ struct smb_request *req)
++{
++ char *path;
++ char *slash, *s;
++ CURLcode result;
++
++ /* URL decode the path */
++ result = Curl_urldecode(data->state.up.path, 0, &path, NULL, REJECT_CTRL);
++ if(result)
++ return result;
++
++ /* Parse the path for the share */
++ Curl_safefree(smbc->share);
++ smbc->share = curlx_strdup((*path == '/' || *path == '\\')
++ ? path + 1 : path);
++ curlx_free(path);
++ if(!smbc->share)
++ return CURLE_OUT_OF_MEMORY;
++
++ slash = strchr(smbc->share, '/');
++ if(!slash)
++ slash = strchr(smbc->share, '\\');
++
++ /* The share must be present */
++ if(!slash) {
++ Curl_safefree(smbc->share);
++ failf(data, "missing share in URL path for SMB");
++ return CURLE_URL_MALFORMAT;
++ }
++
++ /* Parse the path for the file path converting any forward slashes into
++ backslashes */
++ *slash++ = 0;
++ for(s = slash; *s; s++) {
++ if(*s == '/')
++ *s = '\\';
++ }
++ /* keep a copy at easy struct to not share this with connection state */
++ req->path = curlx_strdup(slash);
++ if(!req->path)
++ return CURLE_OUT_OF_MEMORY;
++
++ return CURLE_OK;
++}
++
+ /* this should setup things in the connection, not in the easy
+ handle */
+ static CURLcode smb_setup_connection(struct Curl_easy *data,
+@@ -1226,47 +1200,62 @@ static CURLcode smb_do(struct Curl_easy *data, bool *done)
+ return CURLE_URL_MALFORMAT;
+ }
+
+-static CURLcode smb_parse_url_path(struct Curl_easy *data,
+- struct smb_conn *smbc,
+- struct smb_request *req)
+-{
+- char *path;
+- char *slash;
+- CURLcode result;
+-
+- /* URL decode the path */
+- result = Curl_urldecode(data->state.up.path, 0, &path, NULL, REJECT_CTRL);
+- if(result)
+- return result;
+-
+- /* Parse the path for the share */
+- smbc->share = curlx_strdup((*path == '/' || *path == '\\')
+- ? path + 1 : path);
+- curlx_free(path);
+- if(!smbc->share)
+- return CURLE_OUT_OF_MEMORY;
+-
+- slash = strchr(smbc->share, '/');
+- if(!slash)
+- slash = strchr(smbc->share, '\\');
+-
+- /* The share must be present */
+- if(!slash) {
+- Curl_safefree(smbc->share);
+- failf(data, "missing share in URL path for SMB");
+- return CURLE_URL_MALFORMAT;
+- }
+-
+- /* Parse the path for the file path converting any forward slashes into
+- backslashes */
+- *slash++ = 0;
+- req->path = slash;
++/*
++ * SMB handler interface
++ */
++const struct Curl_handler Curl_handler_smb = {
++ "smb", /* scheme */
++ smb_setup_connection, /* setup_connection */
++ smb_do, /* do_it */
++ ZERO_NULL, /* done */
++ ZERO_NULL, /* do_more */
++ smb_connect, /* connect_it */
++ smb_connection_state, /* connecting */
++ smb_request_state, /* doing */
++ smb_pollset, /* proto_pollset */
++ smb_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_SMB, /* defport */
++ CURLPROTO_SMB, /* protocol */
++ CURLPROTO_SMB, /* family */
++ PROTOPT_CONN_REUSE /* flags */
++};
+
+- for(; *slash; slash++) {
+- if(*slash == '/')
+- *slash = '\\';
+- }
+- return CURLE_OK;
+-}
++#ifdef USE_SSL
++/*
++ * SMBS handler interface
++ */
++const struct Curl_handler Curl_handler_smbs = {
++ "smbs", /* scheme */
++ smb_setup_connection, /* setup_connection */
++ smb_do, /* do_it */
++ ZERO_NULL, /* done */
++ ZERO_NULL, /* do_more */
++ smb_connect, /* connect_it */
++ smb_connection_state, /* connecting */
++ smb_request_state, /* doing */
++ smb_pollset, /* proto_pollset */
++ smb_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_SMBS, /* defport */
++ CURLPROTO_SMBS, /* protocol */
++ CURLPROTO_SMB, /* family */
++ PROTOPT_SSL | PROTOPT_CONN_REUSE /* flags */
++};
++#endif
+
+ #endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE && SIZEOF_CURL_OFF_T > 4 */
+diff --git a/lib/tftp.c b/lib/tftp.c
+index 69571bbdde..0c65c57c59 100644
+--- a/lib/tftp.c
++++ b/lib/tftp.c
+@@ -142,49 +142,6 @@ struct tftp_conn {
+ BIT(remote_pinned);
+ };
+
+-/* Forward declarations */
+-static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event);
+-static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event);
+-static CURLcode tftp_connect(struct Curl_easy *data, bool *done);
+-static CURLcode tftp_do(struct Curl_easy *data, bool *done);
+-static CURLcode tftp_done(struct Curl_easy *data,
+- CURLcode, bool premature);
+-static CURLcode tftp_setup_connection(struct Curl_easy *data,
+- struct connectdata *conn);
+-static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done);
+-static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done);
+-static CURLcode tftp_pollset(struct Curl_easy *data,
+- struct easy_pollset *ps);
+-static CURLcode tftp_translate_code(tftp_error_t error);
+-
+-/*
+- * TFTP protocol handler.
+- */
+-const struct Curl_handler Curl_handler_tftp = {
+- "tftp", /* scheme */
+- tftp_setup_connection, /* setup_connection */
+- tftp_do, /* do_it */
+- tftp_done, /* done */
+- ZERO_NULL, /* do_more */
+- tftp_connect, /* connect_it */
+- tftp_multi_statemach, /* connecting */
+- tftp_doing, /* doing */
+- tftp_pollset, /* proto_pollset */
+- tftp_pollset, /* doing_pollset */
+- ZERO_NULL, /* domore_pollset */
+- ZERO_NULL, /* perform_pollset */
+- ZERO_NULL, /* disconnect */
+- ZERO_NULL, /* write_resp */
+- ZERO_NULL, /* write_resp_hd */
+- ZERO_NULL, /* connection_check */
+- ZERO_NULL, /* attach connection */
+- ZERO_NULL, /* follow */
+- PORT_TFTP, /* defport */
+- CURLPROTO_TFTP, /* protocol */
+- CURLPROTO_TFTP, /* family */
+- PROTOPT_NOTCPPROXY | PROTOPT_NOURLQUERY /* flags */
+-};
+-
+ /**********************************************************
+ *
+ * tftp_set_timeouts -
+@@ -383,185 +340,175 @@ static CURLcode tftp_option_add(struct tftp_conn *state, size_t *csize,
+ return CURLE_OK;
+ }
+
+-static CURLcode tftp_connect_for_tx(struct tftp_conn *state,
+- tftp_event_t event)
+-{
+- CURLcode result;
+-#ifndef CURL_DISABLE_VERBOSE_STRINGS
+- struct Curl_easy *data = state->data;
+-
+- infof(data, "%s", "Connected for transmit");
+-#endif
+- state->state = TFTP_STATE_TX;
+- result = tftp_set_timeouts(state);
+- if(result)
+- return result;
+- return tftp_tx(state, event);
+-}
+-
+-static CURLcode tftp_connect_for_rx(struct tftp_conn *state,
+- tftp_event_t event)
+-{
+- CURLcode result;
+-#ifndef CURL_DISABLE_VERBOSE_STRINGS
+- struct Curl_easy *data = state->data;
+-
+- infof(data, "%s", "Connected for receive");
+-#endif
+- state->state = TFTP_STATE_RX;
+- result = tftp_set_timeouts(state);
+- if(result)
+- return result;
+- return tftp_rx(state, event);
+-}
++/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
++ boundary */
++#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
+
+-static CURLcode tftp_send_first(struct tftp_conn *state,
+- tftp_event_t event)
++/**********************************************************
++ *
++ * tftp_tx
++ *
++ * Event handler for the TX state
++ *
++ **********************************************************/
++static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
+ {
+- size_t sbytes;
+- ssize_t senddata;
+- const char *mode = "octet";
+- char *filename;
+ struct Curl_easy *data = state->data;
+- const struct Curl_sockaddr_ex *remote_addr = NULL;
++ ssize_t sbytes;
+ CURLcode result = CURLE_OK;
+-
+- /* Set ASCII mode if -B flag was used */
+- if(data->state.prefer_ascii)
+- mode = "netascii";
++ struct SingleRequest *k = &data->req;
++ size_t cb; /* Bytes currently read */
++ char buffer[STRERROR_LEN];
++ char *bufptr;
++ bool eos;
+
+ switch(event) {
+
+- case TFTP_EVENT_INIT: /* Send the first packet out */
+- case TFTP_EVENT_TIMEOUT: /* Resend the first packet out */
+- /* Increment the retry counter, quit if over the limit */
+- state->retries++;
+- if(state->retries > state->retry_max) {
+- state->error = TFTP_ERR_NORESPONSE;
+- state->state = TFTP_STATE_FIN;
+- return result;
+- }
++ case TFTP_EVENT_ACK:
++ case TFTP_EVENT_OACK:
++ if(event == TFTP_EVENT_ACK) {
++ /* Ack the packet */
++ int rblock = getrpacketblock(&state->rpacket);
+
+- if(data->state.upload) {
+- /* If we are uploading, send an WRQ */
+- setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
+- if(data->state.infilesize != -1)
+- Curl_pgrsSetUploadSize(data, data->state.infilesize);
+- }
+- else {
+- /* If we are downloading, send an RRQ */
+- setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
+- }
+- /* As RFC3617 describes the separator slash is not actually part of the
+- filename so we skip the always-present first letter of the path
+- string. */
+- if(!state->data->state.up.path[1]) {
+- failf(data, "Missing filename");
+- return CURLE_TFTP_ILLEGAL;
+- }
+- result = Curl_urldecode(&state->data->state.up.path[1], 0,
+- &filename, NULL, REJECT_ZERO);
+- if(result)
+- return result;
++ if(rblock != state->block &&
++ /* There is a bug in tftpd-hpa that causes it to send us an ack for
++ * 65535 when the block number wraps to 0. So when we are expecting
++ * 0, also accept 65535. See
++ * https://www.syslinux.org/archives/2010-September/015612.html
++ * */
++ !(state->block == 0 && rblock == 65535)) {
++ /* This is not the expected block. Log it and up the retry counter */
++ infof(data, "Received ACK for block %d, expecting %d",
++ rblock, state->block);
++ state->retries++;
++ /* Bail out if over the maximum */
++ if(state->retries > state->retry_max) {
++ failf(data, "tftp_tx: giving up waiting for block %d ack",
++ state->block);
++ result = CURLE_SEND_ERROR;
++ }
++ else {
++ /* Re-send the data packet */
++ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
++ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ (struct sockaddr *)&state->remote_addr,
++ state->remote_addrlen);
++ /* Check all sbytes were sent */
++ if(sbytes < 0) {
++ failf(data, "%s",
++ curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ result = CURLE_SEND_ERROR;
++ }
++ }
+
+- if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
+- failf(data, "TFTP filename too long");
+- curlx_free(filename);
+- return CURLE_TFTP_ILLEGAL; /* too long filename field */
++ return result;
++ }
++ /* This is the expected packet. Reset the counters and send the next
++ block */
++ state->rx_time = time(NULL);
++ state->block++;
+ }
++ else
++ state->block = 1; /* first data block is 1 when using OACK */
+
+- curl_msnprintf((char *)state->spacket.data + 2,
+- state->blksize,
+- "%s%c%s%c", filename, '\0', mode, '\0');
+- sbytes = 4 + strlen(filename) + strlen(mode);
+- curlx_free(filename);
+-
+- /* optional addition of TFTP options */
+- if(!data->set.tftp_no_options) {
+- char buf[64];
+- /* add tsize option */
+- curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
+- data->state.upload && (data->state.infilesize != -1) ?
+- data->state.infilesize : 0);
+-
+- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_TSIZE);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes, sbytes, buf);
+-
+- /* add blksize option */
+- curl_msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_BLKSIZE);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes, sbytes, buf);
+-
+- /* add timeout option */
+- curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_INTERVAL);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes, sbytes, buf);
+-
+- if(result != CURLE_OK) {
+- failf(data, "TFTP buffer too small for options");
+- return CURLE_TFTP_ILLEGAL;
+- }
++ state->retries = 0;
++ setpacketevent(&state->spacket, TFTP_EVENT_DATA);
++ setpacketblock(&state->spacket, state->block);
++ if(state->block > 1 && state->sbytes < state->blksize) {
++ state->state = TFTP_STATE_FIN;
++ return CURLE_OK;
+ }
+
+- /* the typecase for the 3rd argument is mostly for systems that do
+- not have a size_t argument, like older unixes that want an 'int' */
+-#ifdef __AMIGA__
+-#define CURL_SENDTO_ARG5(x) CURL_UNCONST(x)
+-#else
+-#define CURL_SENDTO_ARG5(x) (x)
+-#endif
+- remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
+- if(!remote_addr)
+- return CURLE_FAILED_INIT;
++ /* TFTP considers data block size < 512 bytes as an end of session. So
++ * in some cases we must wait for additional data to build full (512 bytes)
++ * data block.
++ * */
++ state->sbytes = 0;
++ bufptr = (char *)state->spacket.data + 4;
++ do {
++ result = Curl_client_read(data, bufptr, state->blksize - state->sbytes,
++ &cb, &eos);
++ if(result)
++ return result;
++ state->sbytes += cb;
++ bufptr += cb;
++ } while(state->sbytes < state->blksize && cb);
+
+- senddata = sendto(state->sockfd, (void *)state->spacket.data,
+- (SEND_TYPE_ARG3)sbytes, 0,
+- CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
+- (curl_socklen_t)remote_addr->addrlen);
+- if(senddata != (ssize_t)sbytes) {
+- char buffer[STRERROR_LEN];
++ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
++ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ (struct sockaddr *)&state->remote_addr,
++ state->remote_addrlen);
++ /* Check all sbytes were sent */
++ if(sbytes < 0) {
+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ return CURLE_SEND_ERROR;
+ }
++ /* Update the progress meter */
++ k->writebytecount += state->sbytes;
++ Curl_pgrs_upload_inc(data, state->sbytes);
+ break;
+
+- case TFTP_EVENT_OACK:
+- if(data->state.upload) {
+- result = tftp_connect_for_tx(state, event);
++ case TFTP_EVENT_TIMEOUT:
++ /* Increment the retry counter and log the timeout */
++ state->retries++;
++ infof(data, "Timeout waiting for block %d ACK. "
++ " Retries = %d", NEXT_BLOCKNUM(state->block), state->retries);
++ /* Decide if we have had enough */
++ if(state->retries > state->retry_max) {
++ state->error = TFTP_ERR_TIMEOUT;
++ state->state = TFTP_STATE_FIN;
+ }
+ else {
+- result = tftp_connect_for_rx(state, event);
++ /* Re-send the data packet */
++ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
++ 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ (struct sockaddr *)&state->remote_addr,
++ state->remote_addrlen);
++ /* Check all sbytes were sent */
++ if(sbytes < 0) {
++ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ return CURLE_SEND_ERROR;
++ }
++ /* since this was a re-send, we remain at the still byte position */
++ Curl_pgrsSetUploadCounter(data, k->writebytecount);
+ }
+ break;
+
+- case TFTP_EVENT_ACK: /* Connected for transmit */
+- result = tftp_connect_for_tx(state, event);
+- break;
+-
+- case TFTP_EVENT_DATA: /* Connected for receive */
+- result = tftp_connect_for_rx(state, event);
+- break;
+-
+ case TFTP_EVENT_ERROR:
+ state->state = TFTP_STATE_FIN;
++ setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
++ setpacketblock(&state->spacket, state->block);
++ (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG,
++ (struct sockaddr *)&state->remote_addr,
++ state->remote_addrlen);
++ /* do not bother with the return code, but if the socket is still up we
++ * should be a good TFTP client and let the server know we are done */
++ state->state = TFTP_STATE_FIN;
+ break;
+
+ default:
+- failf(state->data, "tftp_send_first: internal error");
+- return CURLE_TFTP_ILLEGAL;
++ failf(data, "tftp_tx: internal error, event: %i", (int)(event));
++ break;
+ }
+
+ return result;
+ }
+
+-/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
+- boundary */
+-#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
++static CURLcode tftp_connect_for_tx(struct tftp_conn *state,
++ tftp_event_t event)
++{
++ CURLcode result;
++#ifndef CURL_DISABLE_VERBOSE_STRINGS
++ struct Curl_easy *data = state->data;
++
++ infof(data, "%s", "Connected for transmit");
++#endif
++ state->state = TFTP_STATE_TX;
++ result = tftp_set_timeouts(state);
++ if(result)
++ return result;
++ return tftp_tx(state, event);
++}
+
+ /**********************************************************
+ *
+@@ -609,217 +556,67 @@ static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
+ state->remote_addrlen);
+ if(sbytes < 0) {
+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+- return CURLE_SEND_ERROR;
+- }
+-
+- /* Check if completed (That is, a less than full packet is received) */
+- if(state->rbytes < (ssize_t)state->blksize + 4) {
+- state->state = TFTP_STATE_FIN;
+- }
+- else {
+- state->state = TFTP_STATE_RX;
+- }
+- state->rx_time = time(NULL);
+- break;
+-
+- case TFTP_EVENT_OACK:
+- /* ACK option acknowledgement so we can move on to data */
+- state->block = 0;
+- state->retries = 0;
+- setpacketevent(&state->spacket, TFTP_EVENT_ACK);
+- setpacketblock(&state->spacket, state->block);
+- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
+- 4, SEND_4TH_ARG,
+- (struct sockaddr *)&state->remote_addr,
+- state->remote_addrlen);
+- if(sbytes < 0) {
+- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+- return CURLE_SEND_ERROR;
+- }
+-
+- /* we are ready to RX data */
+- state->state = TFTP_STATE_RX;
+- state->rx_time = time(NULL);
+- break;
+-
+- case TFTP_EVENT_TIMEOUT:
+- /* Increment the retry count and fail if over the limit */
+- state->retries++;
+- infof(data,
+- "Timeout waiting for block %d ACK. Retries = %d",
+- NEXT_BLOCKNUM(state->block), state->retries);
+- if(state->retries > state->retry_max) {
+- state->error = TFTP_ERR_TIMEOUT;
+- state->state = TFTP_STATE_FIN;
+- }
+- else {
+- /* Resend the previous ACK */
+- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
+- 4, SEND_4TH_ARG,
+- (struct sockaddr *)&state->remote_addr,
+- state->remote_addrlen);
+- if(sbytes < 0) {
+- failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+- return CURLE_SEND_ERROR;
+- }
+- }
+- break;
+-
+- case TFTP_EVENT_ERROR:
+- setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
+- setpacketblock(&state->spacket, state->block);
+- (void)sendto(state->sockfd, (void *)state->spacket.data,
+- 4, SEND_4TH_ARG,
+- (struct sockaddr *)&state->remote_addr,
+- state->remote_addrlen);
+- /* do not bother with the return code, but if the socket is still up we
+- * should be a good TFTP client and let the server know we are done */
+- state->state = TFTP_STATE_FIN;
+- break;
+-
+- default:
+- failf(data, "%s", "tftp_rx: internal error");
+- return CURLE_TFTP_ILLEGAL; /* not really the perfect return code for
+- this */
+- }
+- return CURLE_OK;
+-}
+-
+-/**********************************************************
+- *
+- * tftp_tx
+- *
+- * Event handler for the TX state
+- *
+- **********************************************************/
+-static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
+-{
+- struct Curl_easy *data = state->data;
+- ssize_t sbytes;
+- CURLcode result = CURLE_OK;
+- struct SingleRequest *k = &data->req;
+- size_t cb; /* Bytes currently read */
+- char buffer[STRERROR_LEN];
+- char *bufptr;
+- bool eos;
+-
+- switch(event) {
+-
+- case TFTP_EVENT_ACK:
+- case TFTP_EVENT_OACK:
+- if(event == TFTP_EVENT_ACK) {
+- /* Ack the packet */
+- int rblock = getrpacketblock(&state->rpacket);
+-
+- if(rblock != state->block &&
+- /* There is a bug in tftpd-hpa that causes it to send us an ack for
+- * 65535 when the block number wraps to 0. So when we are expecting
+- * 0, also accept 65535. See
+- * https://www.syslinux.org/archives/2010-September/015612.html
+- * */
+- !(state->block == 0 && rblock == 65535)) {
+- /* This is not the expected block. Log it and up the retry counter */
+- infof(data, "Received ACK for block %d, expecting %d",
+- rblock, state->block);
+- state->retries++;
+- /* Bail out if over the maximum */
+- if(state->retries > state->retry_max) {
+- failf(data, "tftp_tx: giving up waiting for block %d ack",
+- state->block);
+- result = CURLE_SEND_ERROR;
+- }
+- else {
+- /* Re-send the data packet */
+- sbytes = sendto(state->sockfd, (void *)state->spacket.data,
+- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
+- (struct sockaddr *)&state->remote_addr,
+- state->remote_addrlen);
+- /* Check all sbytes were sent */
+- if(sbytes < 0) {
+- failf(data, "%s",
+- curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+- result = CURLE_SEND_ERROR;
+- }
+- }
+-
+- return result;
+- }
+- /* This is the expected packet. Reset the counters and send the next
+- block */
+- state->rx_time = time(NULL);
+- state->block++;
++ return CURLE_SEND_ERROR;
+ }
+- else
+- state->block = 1; /* first data block is 1 when using OACK */
+
+- state->retries = 0;
+- setpacketevent(&state->spacket, TFTP_EVENT_DATA);
+- setpacketblock(&state->spacket, state->block);
+- if(state->block > 1 && state->sbytes < state->blksize) {
++ /* Check if completed (That is, a less than full packet is received) */
++ if(state->rbytes < (ssize_t)state->blksize + 4) {
+ state->state = TFTP_STATE_FIN;
+- return CURLE_OK;
+ }
++ else {
++ state->state = TFTP_STATE_RX;
++ }
++ state->rx_time = time(NULL);
++ break;
+
+- /* TFTP considers data block size < 512 bytes as an end of session. So
+- * in some cases we must wait for additional data to build full (512 bytes)
+- * data block.
+- * */
+- state->sbytes = 0;
+- bufptr = (char *)state->spacket.data + 4;
+- do {
+- result = Curl_client_read(data, bufptr, state->blksize - state->sbytes,
+- &cb, &eos);
+- if(result)
+- return result;
+- state->sbytes += cb;
+- bufptr += cb;
+- } while(state->sbytes < state->blksize && cb);
+-
++ case TFTP_EVENT_OACK:
++ /* ACK option acknowledgement so we can move on to data */
++ state->block = 0;
++ state->retries = 0;
++ setpacketevent(&state->spacket, TFTP_EVENT_ACK);
++ setpacketblock(&state->spacket, state->block);
+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
+- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ 4, SEND_4TH_ARG,
+ (struct sockaddr *)&state->remote_addr,
+ state->remote_addrlen);
+- /* Check all sbytes were sent */
+ if(sbytes < 0) {
+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ return CURLE_SEND_ERROR;
+ }
+- /* Update the progress meter */
+- k->writebytecount += state->sbytes;
+- Curl_pgrs_upload_inc(data, state->sbytes);
++
++ /* we are ready to RX data */
++ state->state = TFTP_STATE_RX;
++ state->rx_time = time(NULL);
+ break;
+
+ case TFTP_EVENT_TIMEOUT:
+- /* Increment the retry counter and log the timeout */
++ /* Increment the retry count and fail if over the limit */
+ state->retries++;
+- infof(data, "Timeout waiting for block %d ACK. "
+- " Retries = %d", NEXT_BLOCKNUM(state->block), state->retries);
+- /* Decide if we have had enough */
++ infof(data,
++ "Timeout waiting for block %d ACK. Retries = %d",
++ NEXT_BLOCKNUM(state->block), state->retries);
+ if(state->retries > state->retry_max) {
+ state->error = TFTP_ERR_TIMEOUT;
+ state->state = TFTP_STATE_FIN;
+ }
+ else {
+- /* Re-send the data packet */
++ /* Resend the previous ACK */
+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
+- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ 4, SEND_4TH_ARG,
+ (struct sockaddr *)&state->remote_addr,
+ state->remote_addrlen);
+- /* Check all sbytes were sent */
+ if(sbytes < 0) {
+ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ return CURLE_SEND_ERROR;
+ }
+- /* since this was a re-send, we remain at the still byte position */
+- Curl_pgrsSetUploadCounter(data, k->writebytecount);
+ }
+ break;
+
+ case TFTP_EVENT_ERROR:
+- state->state = TFTP_STATE_FIN;
+ setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
+ setpacketblock(&state->spacket, state->block);
+- (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG,
++ (void)sendto(state->sockfd, (void *)state->spacket.data,
++ 4, SEND_4TH_ARG,
+ (struct sockaddr *)&state->remote_addr,
+ state->remote_addrlen);
+ /* do not bother with the return code, but if the socket is still up we
+@@ -828,8 +625,168 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
+ break;
+
+ default:
+- failf(data, "tftp_tx: internal error, event: %i", (int)(event));
++ failf(data, "%s", "tftp_rx: internal error");
++ return CURLE_TFTP_ILLEGAL; /* not really the perfect return code for
++ this */
++ }
++ return CURLE_OK;
++}
++
++static CURLcode tftp_connect_for_rx(struct tftp_conn *state,
++ tftp_event_t event)
++{
++ CURLcode result;
++#ifndef CURL_DISABLE_VERBOSE_STRINGS
++ struct Curl_easy *data = state->data;
++
++ infof(data, "%s", "Connected for receive");
++#endif
++ state->state = TFTP_STATE_RX;
++ result = tftp_set_timeouts(state);
++ if(result)
++ return result;
++ return tftp_rx(state, event);
++}
++
++static CURLcode tftp_send_first(struct tftp_conn *state,
++ tftp_event_t event)
++{
++ size_t sbytes;
++ ssize_t senddata;
++ const char *mode = "octet";
++ char *filename;
++ struct Curl_easy *data = state->data;
++ const struct Curl_sockaddr_ex *remote_addr = NULL;
++ CURLcode result = CURLE_OK;
++
++ /* Set ASCII mode if -B flag was used */
++ if(data->state.prefer_ascii)
++ mode = "netascii";
++
++ switch(event) {
++
++ case TFTP_EVENT_INIT: /* Send the first packet out */
++ case TFTP_EVENT_TIMEOUT: /* Resend the first packet out */
++ /* Increment the retry counter, quit if over the limit */
++ state->retries++;
++ if(state->retries > state->retry_max) {
++ state->error = TFTP_ERR_NORESPONSE;
++ state->state = TFTP_STATE_FIN;
++ return result;
++ }
++
++ if(data->state.upload) {
++ /* If we are uploading, send an WRQ */
++ setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
++ if(data->state.infilesize != -1)
++ Curl_pgrsSetUploadSize(data, data->state.infilesize);
++ }
++ else {
++ /* If we are downloading, send an RRQ */
++ setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
++ }
++ /* As RFC3617 describes the separator slash is not actually part of the
++ filename so we skip the always-present first letter of the path
++ string. */
++ if(!state->data->state.up.path[1]) {
++ failf(data, "Missing filename");
++ return CURLE_TFTP_ILLEGAL;
++ }
++ result = Curl_urldecode(&state->data->state.up.path[1], 0,
++ &filename, NULL, REJECT_ZERO);
++ if(result)
++ return result;
++
++ if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
++ failf(data, "TFTP filename too long");
++ curlx_free(filename);
++ return CURLE_TFTP_ILLEGAL; /* too long filename field */
++ }
++
++ curl_msnprintf((char *)state->spacket.data + 2,
++ state->blksize,
++ "%s%c%s%c", filename, '\0', mode, '\0');
++ sbytes = 4 + strlen(filename) + strlen(mode);
++ curlx_free(filename);
++
++ /* optional addition of TFTP options */
++ if(!data->set.tftp_no_options) {
++ char buf[64];
++ /* add tsize option */
++ curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
++ data->state.upload && (data->state.infilesize != -1) ?
++ data->state.infilesize : 0);
++
++ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_TSIZE);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes, sbytes, buf);
++
++ /* add blksize option */
++ curl_msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_BLKSIZE);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes, sbytes, buf);
++
++ /* add timeout option */
++ curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_INTERVAL);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes, sbytes, buf);
++
++ if(result != CURLE_OK) {
++ failf(data, "TFTP buffer too small for options");
++ return CURLE_TFTP_ILLEGAL;
++ }
++ }
++
++ /* the typecase for the 3rd argument is mostly for systems that do
++ not have a size_t argument, like older unixes that want an 'int' */
++#ifdef __AMIGA__
++#define CURL_SENDTO_ARG5(x) CURL_UNCONST(x)
++#else
++#define CURL_SENDTO_ARG5(x) (x)
++#endif
++ remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
++ if(!remote_addr)
++ return CURLE_FAILED_INIT;
++
++ senddata = sendto(state->sockfd, (void *)state->spacket.data,
++ (SEND_TYPE_ARG3)sbytes, 0,
++ CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
++ (curl_socklen_t)remote_addr->addrlen);
++ if(senddata != (ssize_t)sbytes) {
++ char buffer[STRERROR_LEN];
++ failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ return CURLE_SEND_ERROR;
++ }
++ break;
++
++ case TFTP_EVENT_OACK:
++ if(data->state.upload) {
++ result = tftp_connect_for_tx(state, event);
++ }
++ else {
++ result = tftp_connect_for_rx(state, event);
++ }
++ break;
++
++ case TFTP_EVENT_ACK: /* Connected for transmit */
++ result = tftp_connect_for_tx(state, event);
++ break;
++
++ case TFTP_EVENT_DATA: /* Connected for receive */
++ result = tftp_connect_for_rx(state, event);
++ break;
++
++ case TFTP_EVENT_ERROR:
++ state->state = TFTP_STATE_FIN;
+ break;
++
++ default:
++ failf(state->data, "tftp_send_first: internal error");
++ return CURLE_TFTP_ILLEGAL;
+ }
+
+ return result;
+@@ -1377,4 +1334,33 @@ static CURLcode tftp_setup_connection(struct Curl_easy *data,
+
+ return CURLE_OK;
+ }
++
++/*
++ * TFTP protocol handler.
++ */
++const struct Curl_handler Curl_handler_tftp = {
++ "tftp", /* scheme */
++ tftp_setup_connection, /* setup_connection */
++ tftp_do, /* do_it */
++ tftp_done, /* done */
++ ZERO_NULL, /* do_more */
++ tftp_connect, /* connect_it */
++ tftp_multi_statemach, /* connecting */
++ tftp_doing, /* doing */
++ tftp_pollset, /* proto_pollset */
++ tftp_pollset, /* doing_pollset */
++ ZERO_NULL, /* domore_pollset */
++ ZERO_NULL, /* perform_pollset */
++ ZERO_NULL, /* disconnect */
++ ZERO_NULL, /* write_resp */
++ ZERO_NULL, /* write_resp_hd */
++ ZERO_NULL, /* connection_check */
++ ZERO_NULL, /* attach connection */
++ ZERO_NULL, /* follow */
++ PORT_TFTP, /* defport */
++ CURLPROTO_TFTP, /* protocol */
++ CURLPROTO_TFTP, /* family */
++ PROTOPT_NOTCPPROXY | PROTOPT_NOURLQUERY /* flags */
++};
++
+ #endif
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index dce222c054..87977e64aa 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -229,7 +229,7 @@ test1680 test1681 test1682 test1683 \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 test1711 \
+ \
+-test1800 test1801 test1802 \
++test1800 test1801 test1802 test1850 \
+ \
+ test1900 test1901 test1902 test1903 test1904 test1905 test1906 test1907 \
+ test1908 test1909 test1910 test1911 test1912 test1913 test1914 test1915 \
+diff --git a/tests/data/test1850 b/tests/data/test1850
+new file mode 100644
+index 0000000000..6a3e4d409b
+--- /dev/null
++++ b/tests/data/test1850
+@@ -0,0 +1,39 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++SMB
++</keywords>
++</info>
++
++# Server-side
++<reply>
++<data nocheck="yes">
++Basic SMB test complete
++</data>
++</reply>
++
++# Client-side
++<client>
++<server>
++smb
++</server>
++<features>
++smb
++</features>
++<name>
++Two SMB requests in the same command line
++</name>
++<command>
++-u 'curltest:curltest' smb://%HOSTIP:%SMBPORT/TESTS/%TESTNUMBER smb://%HOSTIP:%SMBPORT/TESTS/%TESTNUMBER
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<stdout>
++Basic SMB test complete
++Basic SMB test complete
++</stdout>
++</verify>
++</testcase>
diff --git a/0007-curl-8.18.0-CVE-2026-8924.patch b/0007-curl-8.18.0-CVE-2026-8924.patch
deleted file mode 100644
index 86b06b4..0000000
--- a/0007-curl-8.18.0-CVE-2026-8924.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-From 606e40656c37e098cead21670ce1375f0e0ef129 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Sat, 16 May 2026 00:19:09 +0200
-Subject: [PATCH 1/2] cookie: trim trailing dots when checking PSL
-
-Verified with test 1629
-
-Closes #21636
-
-(cherry picked from commit 51beed175dbfc37da3113f6acce60c630c070ce8)
----
- lib/cookie.c | 13 +++++++++--
- tests/data/Makefile.am | 1 +
- tests/data/test1629 | 53 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 65 insertions(+), 2 deletions(-)
- create mode 100644 tests/data/test1629
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index c8072228b9..38edf4a860 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -790,12 +790,21 @@ static bool is_public_suffix(struct Curl_easy *data,
- char lcookie[256];
- size_t dlen = strlen(domain);
- size_t clen = strlen(co->domain);
-+
-+ /* trim trailing dots */
-+ if(dlen && (domain[dlen - 1] == '.'))
-+ dlen--;
-+ if(clen && (co->domain[clen - 1] == '.'))
-+ clen--;
-+
- if((dlen < sizeof(lcase)) && (clen < sizeof(lcookie))) {
- const psl_ctx_t *psl = Curl_psl_use(data);
- if(psl) {
- /* the PSL check requires lowercase domain name and pattern */
-- Curl_strntolower(lcase, domain, dlen + 1);
-- Curl_strntolower(lcookie, co->domain, clen + 1);
-+ Curl_strntolower(lcase, domain, dlen);
-+ lcase[dlen] = 0;
-+ Curl_strntolower(lcookie, co->domain, clen);
-+ lcookie[clen] = 0;
- acceptable = psl_is_cookie_domain_acceptable(psl, lcase, lcookie);
- Curl_psl_release(data);
- }
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 87977e64aa..bff118240c 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -209,6 +209,7 @@ test1556 test1557 test1558 test1559 test1560 test1561 test1562 test1563 \
- test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
- test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
- test1580 test1581 test1582 test1583 test1584 test1585 \
-+test1629 \
- \
- test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
- test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
-diff --git a/tests/data/test1629 b/tests/data/test1629
-new file mode 100644
-index 0000000000..6ee479ba31
---- /dev/null
-+++ b/tests/data/test1629
-@@ -0,0 +1,53 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+HTTP GET
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+<data crlf="headers">
-+HTTP/1.1 200 OK
-+Content-Length: 6
-+Set-Cookie: something=1; Domain=co.uk.; Path=/
-+
-+-foo-
-+</data>
-+</reply>
-+
-+# Client-side
-+<client>
-+<features>
-+PSL
-+cookies
-+</features>
-+<server>
-+http
-+</server>
-+<name>
-+cookies with trailing dot after PSL domain
-+</name>
-+<command>
-+http://foo.co.uk.:%HTTPPORT/ http://bar.co.uk.:%HTTPPORT/ -b "" --resolve foo.co.uk.:%HTTPPORT:%HOSTIP --resolve bar.co.uk.:%HTTPPORT:%HOSTIP
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET / HTTP/1.1
-+Host: foo.co.uk.:%HTTPPORT
-+User-Agent: curl/%VERSION
-+Accept: */*
-+
-+GET / HTTP/1.1
-+Host: bar.co.uk.:%HTTPPORT
-+User-Agent: curl/%VERSION
-+Accept: */*
-+
-+</protocol>
-+</verify>
-+</testcase>
---
-2.55.0
-
diff --git a/0008-cookie-trim-trailing-dots-when-checking-PSL.patch b/0008-cookie-trim-trailing-dots-when-checking-PSL.patch
new file mode 100644
index 0000000..cbdc7e4
--- /dev/null
+++ b/0008-cookie-trim-trailing-dots-when-checking-PSL.patch
@@ -0,0 +1,116 @@
+From 99c09c7e5d6c84beb2b2e4d82bc6f3d1f3180fd8 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Sat, 16 May 2026 00:19:09 +0200
+Subject: [PATCH] cookie: trim trailing dots when checking PSL
+
+Verified with test 1629
+
+Closes #21636
+
+(cherry picked from commit 51beed175dbfc37da3113f6acce60c630c070ce8)
+---
+ lib/cookie.c | 13 +++++++++--
+ tests/data/Makefile.am | 1 +
+ tests/data/test1629 | 53 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 65 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test1629
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index c8072228b9..38edf4a860 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -790,12 +790,21 @@ static bool is_public_suffix(struct Curl_easy *data,
+ char lcookie[256];
+ size_t dlen = strlen(domain);
+ size_t clen = strlen(co->domain);
++
++ /* trim trailing dots */
++ if(dlen && (domain[dlen - 1] == '.'))
++ dlen--;
++ if(clen && (co->domain[clen - 1] == '.'))
++ clen--;
++
+ if((dlen < sizeof(lcase)) && (clen < sizeof(lcookie))) {
+ const psl_ctx_t *psl = Curl_psl_use(data);
+ if(psl) {
+ /* the PSL check requires lowercase domain name and pattern */
+- Curl_strntolower(lcase, domain, dlen + 1);
+- Curl_strntolower(lcookie, co->domain, clen + 1);
++ Curl_strntolower(lcase, domain, dlen);
++ lcase[dlen] = 0;
++ Curl_strntolower(lcookie, co->domain, clen);
++ lcookie[clen] = 0;
+ acceptable = psl_is_cookie_domain_acceptable(psl, lcase, lcookie);
+ Curl_psl_release(data);
+ }
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 87977e64aa..bff118240c 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -209,6 +209,7 @@ test1556 test1557 test1558 test1559 test1560 test1561 test1562 test1563 \
+ test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
+ test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
+ test1580 test1581 test1582 test1583 test1584 test1585 \
++test1629 \
+ \
+ test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
+ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+diff --git a/tests/data/test1629 b/tests/data/test1629
+new file mode 100644
+index 0000000000..6ee479ba31
+--- /dev/null
++++ b/tests/data/test1629
+@@ -0,0 +1,53 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++</keywords>
++</info>
++
++# Server-side
++<reply>
++<data crlf="headers">
++HTTP/1.1 200 OK
++Content-Length: 6
++Set-Cookie: something=1; Domain=co.uk.; Path=/
++
++-foo-
++</data>
++</reply>
++
++# Client-side
++<client>
++<features>
++PSL
++cookies
++</features>
++<server>
++http
++</server>
++<name>
++cookies with trailing dot after PSL domain
++</name>
++<command>
++http://foo.co.uk.:%HTTPPORT/ http://bar.co.uk.:%HTTPPORT/ -b "" --resolve foo.co.uk.:%HTTPPORT:%HOSTIP --resolve bar.co.uk.:%HTTPPORT:%HOSTIP
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET / HTTP/1.1
++Host: foo.co.uk.:%HTTPPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++GET / HTTP/1.1
++Host: bar.co.uk.:%HTTPPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++</protocol>
++</verify>
++</testcase>
diff --git a/0008-curl-8.18.0-CVE-2026-9547.patch b/0008-curl-8.18.0-CVE-2026-9547.patch
deleted file mode 100644
index 5b4b6cc..0000000
--- a/0008-curl-8.18.0-CVE-2026-9547.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 21000729410df2d9ab105a05ee3759b25ede1f1d Mon Sep 17 00:00:00 2001
-From: Joshua Rogers <MegaManSec@users.noreply.github.com>
-Date: Fri, 22 May 2026 09:48:15 +0200
-Subject: [PATCH 2/2] libssh: map SSH_KNOWN_HOSTS_OTHER to CURLKHMATCH_MISMATCH
-
-Host key type mismatch from libssh was incorrectly reported as missing,
-causing key callbacks to accept instead of reject.
-
-Reported by: Joshua Rogers (Aisle Research)
-Closes #21724
-
-(cherry picked from commit 0b8dbbc63c98777e4584cb9fbd71df3464008ad1)
----
- lib/vssh/libssh.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
-index 3e6cb3a832..199e97bd3f 100644
---- a/lib/vssh/libssh.c
-+++ b/lib/vssh/libssh.c
-@@ -406,6 +406,8 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc)
- keymatch = CURLKHMATCH_OK;
- break;
- case SSH_KNOWN_HOSTS_OTHER:
-+ keymatch = CURLKHMATCH_MISMATCH;
-+ break;
- case SSH_KNOWN_HOSTS_NOT_FOUND:
- case SSH_KNOWN_HOSTS_UNKNOWN:
- case SSH_KNOWN_HOSTS_ERROR:
---
-2.55.0
-
diff --git a/0009-curl-8.18.0-CVE-2026-8926.patch b/0009-curl-8.18.0-CVE-2026-8926.patch
deleted file mode 100644
index 3d488c4..0000000
--- a/0009-curl-8.18.0-CVE-2026-8926.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-From 791cd6178164334f2709e14fec4445b41456802d Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 15 May 2026 11:45:49 +0200
-Subject: [PATCH] netrc: scanner refactor
-
-Refactor the netrc scanner. Add test case for checking that the last
-matched machine with unmatched login does not return the password as
-success (unit1304).
-
-Closes #21624
-
-(cherry picked from commit 4ae1d7cc2643e4773a136395f12bc02fc6867854)
-Co-authored-by: Cursor <cursoragent@cursor.com>
----
- lib/netrc.c | 15 ++++++++++++++-
- tests/unit/unit1304.c | 22 +++++++++++++++++++---
- 2 files changed, 33 insertions(+), 4 deletions(-)
-
-diff --git a/lib/netrc.c b/lib/netrc.c
-index 0678733d22..6b5f725054 100644
---- a/lib/netrc.c
-+++ b/lib/netrc.c
-@@ -121,6 +121,7 @@ static NETRCcode parsenetrc(struct store_netrc *store,
- unsigned char found = 0; /* login + password found bits, as they can come in
- any order */
- bool our_login = FALSE; /* found our login name */
-+ bool login_mismatch = FALSE; /* host matched but login did not */
- bool done = FALSE;
- char *netrcbuffer;
- struct dynbuf token;
-@@ -303,16 +304,23 @@ static NETRCcode parsenetrc(struct store_netrc *store,
- done = TRUE;
- break;
- }
-+ if(specific_login && !our_login && (found & FOUND_LOGIN))
-+ login_mismatch = TRUE;
- state = HOSTFOUND;
- keyword = NONE;
- found = 0;
-+ our_login = FALSE;
- Curl_safefree(password);
- if(!specific_login)
- Curl_safefree(login);
- }
- else if(curl_strequal("default", tok)) {
-+ if(specific_login && !our_login && (found & FOUND_LOGIN))
-+ login_mismatch = TRUE;
- state = HOSTVALID;
- retcode = NETRC_OK; /* we did find our host */
-+ found = 0;
-+ our_login = FALSE;
- Curl_safefree(password);
- if(!specific_login)
- Curl_safefree(login);
-@@ -339,7 +347,12 @@ static NETRCcode parsenetrc(struct store_netrc *store,
- out:
- curlx_dyn_free(&token);
- if(!retcode) {
-- if(!password && our_login) {
-+ if(specific_login && !our_login &&
-+ ((found & FOUND_LOGIN) || login_mismatch)) {
-+ /* host matched, a login was present but did not match the user */
-+ retcode = NETRC_NO_MATCH;
-+ }
-+ else if(!password && our_login) {
- /* success without a password, set a blank one */
- password = curlx_strdup("");
- if(!password)
-diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
-index 3438c97104..a7dd8a23d2 100644
---- a/tests/unit/unit1304.c
-+++ b/tests/unit/unit1304.c
-@@ -59,7 +59,7 @@ static CURLcode test_unit1304(const char *arg)
- login = (char *)CURL_UNCONST("me");
- Curl_netrc_init(&store);
- result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
-- fail_unless(result == 0, "Host should have been found");
-+ fail_unless(result == 1, "expected no match");
- abort_unless(password == NULL, "password is not NULL!");
- Curl_netrc_cleanup(&store);
-
-@@ -80,7 +80,7 @@ static CURLcode test_unit1304(const char *arg)
- login = (char *)CURL_UNCONST("admi"); /* spellchecker:disable-line */
- Curl_netrc_init(&store);
- result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
-- fail_unless(result == 0, "Host should have been found");
-+ fail_unless(result == 1, "expected no match");
- abort_unless(password == NULL, "password is not NULL!");
- Curl_netrc_cleanup(&store);
-
-@@ -91,7 +91,7 @@ static CURLcode test_unit1304(const char *arg)
- login = (char *)CURL_UNCONST("adminn");
- Curl_netrc_init(&store);
- result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
-- fail_unless(result == 0, "Host should have been found");
-+ fail_unless(result == 1, "expected no match");
- abort_unless(password == NULL, "password is not NULL!");
- Curl_netrc_cleanup(&store);
-
-@@ -162,6 +162,22 @@ static CURLcode test_unit1304(const char *arg)
- fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
- Curl_netrc_cleanup(&store);
-
-+ /*
-+ * Test for the last host where we do not want to see the password
-+ * if the login does not match.
-+ */
-+ curlx_free(password);
-+ password = NULL;
-+ curlx_free(login);
-+ login = (char *)CURL_UNCONST("hilarious");
-+ Curl_netrc_init(&store);
-+ result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg);
-+ fail_unless(result == 1, "expect no match");
-+ abort_unless(password == NULL, "password must be NULL");
-+ Curl_netrc_cleanup(&store);
-+
-+ login = NULL;
-+
- UNITTEST_END(t1304_stop(&password, &login))
- }
-
---
-2.55.0
-
diff --git a/0009-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch b/0009-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
new file mode 100644
index 0000000..6c4e579
--- /dev/null
+++ b/0009-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
@@ -0,0 +1,29 @@
+From 2b9678ef56d57c8bdf0ae6886752312a25ed21b6 Mon Sep 17 00:00:00 2001
+From: Joshua Rogers <MegaManSec@users.noreply.github.com>
+Date: Fri, 22 May 2026 09:48:15 +0200
+Subject: [PATCH] libssh: map SSH_KNOWN_HOSTS_OTHER to CURLKHMATCH_MISMATCH
+
+Host key type mismatch from libssh was incorrectly reported as missing,
+causing key callbacks to accept instead of reject.
+
+Reported by: Joshua Rogers (Aisle Research)
+Closes #21724
+
+(cherry picked from commit 0b8dbbc63c98777e4584cb9fbd71df3464008ad1)
+---
+ lib/vssh/libssh.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
+index 3e6cb3a832..199e97bd3f 100644
+--- a/lib/vssh/libssh.c
++++ b/lib/vssh/libssh.c
+@@ -406,6 +406,8 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc)
+ keymatch = CURLKHMATCH_OK;
+ break;
+ case SSH_KNOWN_HOSTS_OTHER:
++ keymatch = CURLKHMATCH_MISMATCH;
++ break;
+ case SSH_KNOWN_HOSTS_NOT_FOUND:
+ case SSH_KNOWN_HOSTS_UNKNOWN:
+ case SSH_KNOWN_HOSTS_ERROR:
diff --git a/0010-curl-8.18.0-CVE-2026-11856.patch b/0010-curl-8.18.0-CVE-2026-11856.patch
deleted file mode 100644
index c0e7985..0000000
--- a/0010-curl-8.18.0-CVE-2026-11856.patch
+++ /dev/null
@@ -1,337 +0,0 @@
-From 90e9bbda751edc052b04a53b7044ad7f037ffc5d Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Wed, 10 Jun 2026 10:27:50 +0200
-Subject: [PATCH] digest: flush state on origin or credential change
-
-Verified by test 1686
-
-Closes #21944
-
-(cherry picked from commit 5c6b4880357ab3e72967c1c45cae0f96ffabc535)
----
- lib/http_digest.c | 31 ++++++++++++
- lib/urldata.h | 8 ++--
- lib/vauth/digest.c | 4 ++
- lib/vauth/digest_sspi.c | 2 +
- tests/data/Makefile.am | 2 +-
- tests/data/test1686 | 84 +++++++++++++++++++++++++++++++++
- tests/libtest/Makefile.inc | 1 +
- tests/libtest/lib1686.c | 96 ++++++++++++++++++++++++++++++++++++++
- 8 files changed, 223 insertions(+), 5 deletions(-)
- create mode 100644 tests/data/test1686
- create mode 100644 tests/libtest/lib1686.c
-
-diff --git a/lib/http_digest.c b/lib/http_digest.c
-index ccc67f5efc..129c0d33f7 100644
---- a/lib/http_digest.c
-+++ b/lib/http_digest.c
-@@ -98,7 +98,38 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
- #endif
- }
- else {
-+ bool flush = FALSE;
- digest = &data->state.digest;
-+
-+ if(digest->origin_host &&
-+ (!curl_strequal(data->conn->host.name, digest->origin_host) ||
-+ data->conn->remote_port != digest->origin_port))
-+ flush = TRUE;
-+ else if(digest->user &&
-+ Curl_timestrcmp(data->state.aptr.user ?
-+ data->state.aptr.user : "",
-+ digest->user))
-+ flush = TRUE;
-+ else if(digest->passwd &&
-+ Curl_timestrcmp(data->state.aptr.passwd ?
-+ data->state.aptr.passwd : "",
-+ digest->passwd))
-+ flush = TRUE;
-+
-+ if(flush)
-+ /* flush host Digest state */
-+ Curl_auth_digest_cleanup(digest);
-+
-+ Curl_safefree(digest->origin_host);
-+ digest->origin_host = curlx_strdup(data->conn->host.name);
-+ digest->origin_port = data->conn->remote_port;
-+ Curl_safefree(digest->user);
-+ digest->user = curlx_strdup(data->state.aptr.user ?
-+ data->state.aptr.user : "");
-+ Curl_safefree(digest->passwd);
-+ digest->passwd = curlx_strdup(data->state.aptr.passwd ?
-+ data->state.aptr.passwd : "");
-+
- allocuserpwd = &data->state.aptr.userpwd;
- userp = data->state.aptr.user;
- passwdp = data->state.aptr.passwd;
-diff --git a/lib/urldata.h b/lib/urldata.h
-index aba1693ca7..221317e47e 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -291,14 +291,14 @@ struct ssl_general_config {
- #ifndef CURL_DISABLE_DIGEST_AUTH
- /* Struct used for Digest challenge-response authentication */
- struct digestdata {
-+ char *origin_host;
-+ int origin_port;
-+ char *user;
-+ char *passwd;
- #ifdef USE_WINDOWS_SSPI
- BYTE *input_token;
- size_t input_token_len;
- CtxtHandle *http_context;
-- /* copy of user/passwd used to make the identity for http_context.
-- either may be NULL. */
-- char *user;
-- char *passwd;
- #else
- char *nonce;
- char *cnonce;
-diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c
-index a1fd248617..1cd867cead 100644
---- a/lib/vauth/digest.c
-+++ b/lib/vauth/digest.c
-@@ -1013,6 +1013,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
- */
- void Curl_auth_digest_cleanup(struct digestdata *digest)
- {
-+ Curl_safefree(digest->origin_host);
-+ digest->origin_port = 0;
-+ Curl_safefree(digest->user);
-+ Curl_safefree(digest->passwd);
- Curl_safefree(digest->nonce);
- Curl_safefree(digest->cnonce);
- Curl_safefree(digest->realm);
-diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c
-index 615b4bc827..3fc75371b2 100644
---- a/lib/vauth/digest_sspi.c
-+++ b/lib/vauth/digest_sspi.c
-@@ -661,6 +661,8 @@ void Curl_auth_digest_cleanup(struct digestdata *digest)
- /* Free the copy of user/passwd used to make the identity for http_context */
- Curl_safefree(digest->user);
- Curl_safefree(digest->passwd);
-+ Curl_safefree(digest->origin_host);
-+ digest->origin_port = 0;
- }
-
- #endif /* USE_WINDOWS_SSPI && !CURL_DISABLE_DIGEST_AUTH */
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index bff118240c..9535861b18 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -225,7 +225,7 @@ test1660 test1661 test1662 test1663 test1664 test1665 \
- \
- test1670 test1671 \
- \
--test1680 test1681 test1682 test1683 \
-+test1680 test1681 test1682 test1683 test1686 \
- \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 test1711 \
-diff --git a/tests/data/test1686 b/tests/data/test1686
-new file mode 100644
-index 0000000000..2d419ad608
---- /dev/null
-+++ b/tests/data/test1686
-@@ -0,0 +1,84 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+Digest
-+</keywords>
-+</info>
-+
-+<reply>
-+<data crlf="headers" nocheck="yes">
-+HTTP/1.1 401 Authorization Required
-+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
-+WWW-Authenticate: Digest realm="my-backyard", nonce="314156295"
-+Content-Length: 26
-+
-+This is not the real page
-+</data>
-+
-+# This is supposed to be returned when the server gets a
-+# Authorization: Digest line passed-in from the client
-+<data1000 crlf="headers">
-+HTTP/1.1 200 OK
-+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
-+Content-Type: text/html; charset=iso-8859-1
-+Content-Length: 23
-+
-+This IS the real page!
-+</data1000>
-+
-+</reply>
-+
-+<client>
-+<features>
-+!SSPI
-+crypto
-+digest
-+</features>
-+<server>
-+http
-+</server>
-+<name>
-+HTTP Digest to different origins and switching credentials
-+</name>
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<command>
-+%HOSTIP %HTTPPORT
-+</command>
-+</client>
-+
-+<verify>
-+<protocol crlf="headers">
-+GET /api HTTP/1.1
-+Host: first.test:%HTTPPORT
-+Accept: */*
-+
-+GET /api HTTP/1.1
-+Host: first.test:%HTTPPORT
-+Authorization: Digest username="alice", realm="my-backyard", nonce="314156295", uri="/api", response="4ecc00e567c37a9d537727890c2e5b32"
-+Accept: */*
-+
-+GET /hook HTTP/1.1
-+Host: second.test:%HTTPPORT
-+Accept: */*
-+
-+GET /hook HTTP/1.1
-+Host: second.test:%HTTPPORT
-+Authorization: Digest username="alice", realm="my-backyard", nonce="314156295", uri="/hook", response="d3a7738fb6a23f5543fb8dacc0f0f253"
-+Accept: */*
-+
-+GET /hook HTTP/1.1
-+Host: second.test:%HTTPPORT
-+Accept: */*
-+
-+GET /hook HTTP/1.1
-+Host: second.test:%HTTPPORT
-+Authorization: Digest username="bob", realm="my-backyard", nonce="314156295", uri="/hook", response="777e68eddb77294d9cbd6134973cbbab"
-+Accept: */*
-+
-+</protocol>
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index e3202804a9..5c5660ffd8 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -101,6 +101,7 @@ TESTS_C = \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
- lib1662.c \
-+ lib1686.c \
- lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
- lib1908.c lib1910.c lib1911.c lib1912.c lib1913.c \
- lib1915.c lib1916.c lib1918.c lib1919.c lib1920.c \
-diff --git a/tests/libtest/lib1686.c b/tests/libtest/lib1686.c
-new file mode 100644
-index 0000000000..e457012bb9
---- /dev/null
-+++ b/tests/libtest/lib1686.c
-@@ -0,0 +1,96 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+#include "first.h"
-+
-+static size_t devnull_1686(char *p, size_t s, size_t n, void *u)
-+{
-+ (void)p;
-+ (void)u;
-+ return s * n;
-+}
-+
-+#define FIRSTHOST "first.test"
-+#define SECONDHOST "second.test"
-+
-+static CURLcode test_lib1686(const char *hostip)
-+{
-+ CURL *curl = NULL;
-+ CURLcode result = CURLE_OK;
-+ const char *httpport = libtest_arg2;
-+ char firsturl[100];
-+ char secondurl[100];
-+ char firstres[100];
-+ char secondres[100];
-+ struct curl_slist *host = NULL;
-+ struct curl_slist *host2 = NULL;
-+
-+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
-+ curl_mfprintf(stderr, "curl_global_init() failed\n");
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ /* create strings for CURLOPT_RESOLVE */
-+ curl_msnprintf(firstres, sizeof(firstres), "%s:%s:%s",
-+ FIRSTHOST, httpport, hostip);
-+ curl_msnprintf(secondres, sizeof(secondres), "%s:%s:%s",
-+ SECONDHOST, httpport, hostip);
-+
-+ /* create URLs */
-+ curl_msnprintf(firsturl, sizeof(firsturl), "http://%s:%s/api",
-+ FIRSTHOST, httpport);
-+ curl_msnprintf(secondurl, sizeof(secondurl), "http://%s:%s/hook",
-+ SECONDHOST, httpport);
-+
-+ host = curl_slist_append(NULL, firstres);
-+ if(!host)
-+ goto test_cleanup;
-+ host2 = curl_slist_append(host, secondres);
-+ if(!host2)
-+ goto test_cleanup;
-+ host = host2;
-+
-+ curl = curl_easy_init();
-+ if(curl) {
-+ easy_setopt(curl, CURLOPT_RESOLVE, host);
-+ easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
-+ easy_setopt(curl, CURLOPT_USERPWD, "alice:bond");
-+ easy_setopt(curl, CURLOPT_WRITEFUNCTION, devnull_1686);
-+
-+ easy_setopt(curl, CURLOPT_URL, firsturl);
-+ result = curl_easy_perform(curl);
-+
-+ easy_setopt(curl, CURLOPT_URL, secondurl);
-+ result = curl_easy_perform(curl);
-+
-+ easy_setopt(curl, CURLOPT_USERPWD, "bob:secret");
-+ easy_setopt(curl, CURLOPT_URL, secondurl);
-+ result = curl_easy_perform(curl);
-+ }
-+
-+test_cleanup:
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ curl_slist_free_all(host);
-+ return result;
-+}
---
-2.55.0
-
diff --git a/0010-netrc-scanner-refactor.patch b/0010-netrc-scanner-refactor.patch
new file mode 100644
index 0000000..bb49555
--- /dev/null
+++ b/0010-netrc-scanner-refactor.patch
@@ -0,0 +1,122 @@
+From 0406e9712e0062d5da4df6a0ed40805ad14a9b84 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Fri, 15 May 2026 11:45:49 +0200
+Subject: [PATCH] netrc: scanner refactor
+
+Refactor the netrc scanner. Add test case for checking that the last
+matched machine with unmatched login does not return the password as
+success (unit1304).
+
+Closes #21624
+
+(cherry picked from commit 4ae1d7cc2643e4773a136395f12bc02fc6867854)
+Co-authored-by: Cursor <cursoragent@cursor.com>
+---
+ lib/netrc.c | 15 ++++++++++++++-
+ tests/unit/unit1304.c | 22 +++++++++++++++++++---
+ 2 files changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/lib/netrc.c b/lib/netrc.c
+index 0678733d22..6b5f725054 100644
+--- a/lib/netrc.c
++++ b/lib/netrc.c
+@@ -121,6 +121,7 @@ static NETRCcode parsenetrc(struct store_netrc *store,
+ unsigned char found = 0; /* login + password found bits, as they can come in
+ any order */
+ bool our_login = FALSE; /* found our login name */
++ bool login_mismatch = FALSE; /* host matched but login did not */
+ bool done = FALSE;
+ char *netrcbuffer;
+ struct dynbuf token;
+@@ -303,16 +304,23 @@ static NETRCcode parsenetrc(struct store_netrc *store,
+ done = TRUE;
+ break;
+ }
++ if(specific_login && !our_login && (found & FOUND_LOGIN))
++ login_mismatch = TRUE;
+ state = HOSTFOUND;
+ keyword = NONE;
+ found = 0;
++ our_login = FALSE;
+ Curl_safefree(password);
+ if(!specific_login)
+ Curl_safefree(login);
+ }
+ else if(curl_strequal("default", tok)) {
++ if(specific_login && !our_login && (found & FOUND_LOGIN))
++ login_mismatch = TRUE;
+ state = HOSTVALID;
+ retcode = NETRC_OK; /* we did find our host */
++ found = 0;
++ our_login = FALSE;
+ Curl_safefree(password);
+ if(!specific_login)
+ Curl_safefree(login);
+@@ -339,7 +347,12 @@ static NETRCcode parsenetrc(struct store_netrc *store,
+ out:
+ curlx_dyn_free(&token);
+ if(!retcode) {
+- if(!password && our_login) {
++ if(specific_login && !our_login &&
++ ((found & FOUND_LOGIN) || login_mismatch)) {
++ /* host matched, a login was present but did not match the user */
++ retcode = NETRC_NO_MATCH;
++ }
++ else if(!password && our_login) {
+ /* success without a password, set a blank one */
+ password = curlx_strdup("");
+ if(!password)
+diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
+index 3438c97104..a7dd8a23d2 100644
+--- a/tests/unit/unit1304.c
++++ b/tests/unit/unit1304.c
+@@ -59,7 +59,7 @@ static CURLcode test_unit1304(const char *arg)
+ login = (char *)CURL_UNCONST("me");
+ Curl_netrc_init(&store);
+ result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
+- fail_unless(result == 0, "Host should have been found");
++ fail_unless(result == 1, "expected no match");
+ abort_unless(password == NULL, "password is not NULL!");
+ Curl_netrc_cleanup(&store);
+
+@@ -80,7 +80,7 @@ static CURLcode test_unit1304(const char *arg)
+ login = (char *)CURL_UNCONST("admi"); /* spellchecker:disable-line */
+ Curl_netrc_init(&store);
+ result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
+- fail_unless(result == 0, "Host should have been found");
++ fail_unless(result == 1, "expected no match");
+ abort_unless(password == NULL, "password is not NULL!");
+ Curl_netrc_cleanup(&store);
+
+@@ -91,7 +91,7 @@ static CURLcode test_unit1304(const char *arg)
+ login = (char *)CURL_UNCONST("adminn");
+ Curl_netrc_init(&store);
+ result = Curl_parsenetrc(&store, "example.com", &login, &password, arg);
+- fail_unless(result == 0, "Host should have been found");
++ fail_unless(result == 1, "expected no match");
+ abort_unless(password == NULL, "password is not NULL!");
+ Curl_netrc_cleanup(&store);
+
+@@ -162,6 +162,22 @@ static CURLcode test_unit1304(const char *arg)
+ fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
+ Curl_netrc_cleanup(&store);
+
++ /*
++ * Test for the last host where we do not want to see the password
++ * if the login does not match.
++ */
++ curlx_free(password);
++ password = NULL;
++ curlx_free(login);
++ login = (char *)CURL_UNCONST("hilarious");
++ Curl_netrc_init(&store);
++ result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg);
++ fail_unless(result == 1, "expect no match");
++ abort_unless(password == NULL, "password must be NULL");
++ Curl_netrc_cleanup(&store);
++
++ login = NULL;
++
+ UNITTEST_END(t1304_stop(&password, &login))
+ }
+
diff --git a/0011-curl-8.18.0-CVE-2026-7168.patch b/0011-curl-8.18.0-CVE-2026-7168.patch
deleted file mode 100644
index faae95e..0000000
--- a/0011-curl-8.18.0-CVE-2026-7168.patch
+++ /dev/null
@@ -1,372 +0,0 @@
-From 44e75b49e5b9e313df908270d14367f3e4ab4488 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 27 Apr 2026 09:14:51 +0200
-Subject: [PATCH] setopt: clear proxy auth properties when switching
-
-Verify with test 1588
-
-Closes #21453
-
-(cherry picked from commit c1cfdf59acbaf9504c4578d4cf56cdd7c8594507)
----
- lib/setopt.c | 18 ++++-
- lib/vauth/vauth.h | 1 +
- tests/data/Makefile.am | 1 +
- tests/data/test1588 | 106 ++++++++++++++++++++++++++
- tests/libtest/Makefile.inc | 2 +-
- tests/libtest/lib1588.c | 150 +++++++++++++++++++++++++++++++++++++
- 6 files changed, 276 insertions(+), 2 deletions(-)
- create mode 100644 tests/data/test1588
- create mode 100644 tests/libtest/lib1588.c
-
-diff --git a/lib/setopt.c b/lib/setopt.c
-index 0c1da5bc12..65c573cb9d 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -49,6 +49,7 @@
- #include "strdup.h"
- #include "escape.h"
- #include "bufref.h"
-+#include "vauth/vauth.h"
-
- static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
- {
-@@ -1614,6 +1615,21 @@ 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) &&
-+ !strcmp(data->set.str[STRING_PROXY], proxy))
-+ return CURLE_OK;
-+
-+ 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);
-+}
-+
-+#endif
-+
- static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
- char *ptr)
- {
-@@ -1821,7 +1837,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
- * Setting it to NULL, means no proxy but allows the environment variables
- * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
- */
-- return Curl_setstropt(&s->str[STRING_PROXY], ptr);
-+ return setproxy(data, ptr);
-
- case CURLOPT_PRE_PROXY:
- /*
-diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h
-index 312bd8da5a..15da62678c 100644
---- a/lib/vauth/vauth.h
-+++ b/lib/vauth/vauth.h
-@@ -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 */
-
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 9535861b18..b050f708eb 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -209,6 +209,7 @@ test1556 test1557 test1558 test1559 test1560 test1561 test1562 test1563 \
- test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
- test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
- test1580 test1581 test1582 test1583 test1584 test1585 \
-+test1588 \
- test1629 \
- \
- test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
-diff --git a/tests/data/test1588 b/tests/data/test1588
-new file mode 100644
-index 0000000000..753e98cd6b
---- /dev/null
-+++ b/tests/data/test1588
-@@ -0,0 +1,106 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+HTTP GET
-+HTTP proxy
-+HTTP proxy Digest auth
-+multi
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+
-+# this is returned first since we get no proxy-auth
-+<data crlf="headers">
-+HTTP/1.1 407 Authorization Required to proxy me my dear
-+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
-+Content-Length: 33
-+
-+And you should ignore this data.
-+</data>
-+
-+# then this is returned when we get proxy-auth
-+<data1000 crlf="headers">
-+HTTP/1.1 200 OK
-+Content-Length: 21
-+Server: no
-+
-+Nice proxy auth sir!
-+</data1000>
-+
-+<datacheck crlf="headers">
-+HTTP/1.1 407 Authorization Required to proxy me my dear
-+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
-+Content-Length: 33
-+
-+HTTP/1.1 200 OK
-+Content-Length: 21
-+Server: no
-+
-+Nice proxy auth sir!
-+HTTP/1.1 407 Authorization Required to proxy me my dear
-+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
-+Content-Length: 33
-+
-+HTTP/1.1 200 OK
-+Content-Length: 21
-+Server: no
-+
-+Nice proxy auth sir!
-+</datacheck>
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+# tool is what to use instead of 'curl'
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<features>
-+!SSPI
-+crypto
-+proxy
-+digest
-+</features>
-+<name>
-+HTTP proxy auth Digest, then change proxy and do it again
-+</name>
-+<command>
-+http://test.remote.example.com/path/%TESTNUMBER %HOSTIP %HTTPPORT silly:person custom.set.host.name
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET http://test.remote.example.com/path/1588 HTTP/1.1
-+Host: test.remote.example.com
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://test.remote.example.com/path/1588 HTTP/1.1
-+Host: test.remote.example.com
-+Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/1588", response="d0b2f000c7e3fca24452b5810713404a"
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://test.remote.example.com/path/1588 HTTP/1.1
-+Host: test.remote.example.com
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://test.remote.example.com/path/1588 HTTP/1.1
-+Host: test.remote.example.com
-+Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/1588", response="d0b2f000c7e3fca24452b5810713404a"
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+</protocol>
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index 5c5660ffd8..76014f926a 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -97,7 +97,7 @@ TESTS_C = \
- lib1559.c lib1560.c lib1564.c lib1565.c \
- lib1567.c lib1568.c lib1569.c lib1571.c \
- lib1576.c \
-- lib1582.c \
-+ lib1582.c lib1588.c \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
- lib1662.c \
-diff --git a/tests/libtest/lib1588.c b/tests/libtest/lib1588.c
-new file mode 100644
-index 0000000000..9b12f36bfe
---- /dev/null
-+++ b/tests/libtest/lib1588.c
-@@ -0,0 +1,150 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+/*
-+ * argv1 = URL
-+ * argv2 = proxy host
-+ * argv3 = proxy port
-+ * argv4 = proxyuser:password
-+ */
-+
-+#include "first.h"
-+
-+static CURLcode init1588(CURL *curl, const char *url,
-+ const char *userpwd, const char *proxy)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(result)
-+ goto init_failed;
-+#if 0
-+ res_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-+ if(result)
-+ goto init_failed;
-+#endif
-+
-+ res_easy_setopt(curl, CURLOPT_HEADER, 1L);
-+ if(result)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return result; /* failure */
-+}
-+
-+static CURLcode run1588(CURL *curl, const char *url, const char *userpwd,
-+ const char *proxy)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ result = init1588(curl, url, userpwd, proxy);
-+ if(result)
-+ return result;
-+
-+ return curl_easy_perform(curl);
-+}
-+
-+static CURLcode test_lib1588(const char *URL)
-+{
-+ CURLcode result = CURLE_OK;
-+ CURL *curl = NULL;
-+ const char *proxyuserpws = libtest_arg4;
-+ struct curl_slist *host = NULL;
-+ struct curl_slist *host2 = NULL;
-+ char proxy1_resolve[128];
-+ char proxy2_resolve[128];
-+ char proxy1_connect[128];
-+ char proxy2_connect[128];
-+
-+ if(test_argc < 3)
-+ return TEST_ERR_MAJOR_BAD;
-+
-+ curl_msnprintf(proxy1_resolve, sizeof(proxy1_resolve),
-+ "firstproxy:%s:%s", libtest_arg3, libtest_arg2);
-+ curl_msnprintf(proxy2_resolve, sizeof(proxy2_resolve),
-+ "secondproxy:%s:%s", libtest_arg3, libtest_arg2);
-+
-+ /* we connect to the fake host name but the right port number */
-+ curl_msnprintf(proxy1_connect, sizeof(proxy1_connect),
-+ "firstproxy:%s", libtest_arg3);
-+ curl_msnprintf(proxy2_connect, sizeof(proxy2_connect),
-+ "secondproxy:%s", libtest_arg3);
-+
-+ res_global_init(CURL_GLOBAL_ALL);
-+ if(result)
-+ return result;
-+
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
-+ curl_global_cleanup();
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ host = curl_slist_append(NULL, proxy1_resolve);
-+ if(!host)
-+ goto test_cleanup;
-+ host2 = curl_slist_append(host, proxy2_resolve);
-+ if(!host2)
-+ goto test_cleanup;
-+ host = host2;
-+
-+ start_test_timing();
-+
-+ easy_setopt(curl, CURLOPT_RESOLVE, host);
-+
-+ result = run1588(curl, URL, proxyuserpws, proxy1_connect);
-+ if(result)
-+ goto test_cleanup;
-+
-+ curl_mfprintf(stderr, "lib1588: now we do the request again\n");
-+
-+ result = run1588(curl, URL, proxyuserpws, proxy2_connect);
-+
-+test_cleanup:
-+
-+ /* proper cleanup sequence - type PB */
-+
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ curl_slist_free_all(host);
-+ return result;
-+}
---
-2.55.0
-
diff --git a/0011-digest-flush-state-on-origin-or-credential-change.patch b/0011-digest-flush-state-on-origin-or-credential-change.patch
new file mode 100644
index 0000000..4302186
--- /dev/null
+++ b/0011-digest-flush-state-on-origin-or-credential-change.patch
@@ -0,0 +1,334 @@
+From 5f7b5088378145d5bea0ff4e7f9c3feae1c70a67 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Wed, 10 Jun 2026 10:27:50 +0200
+Subject: [PATCH] digest: flush state on origin or credential change
+
+Verified by test 1686
+
+Closes #21944
+
+(cherry picked from commit 5c6b4880357ab3e72967c1c45cae0f96ffabc535)
+---
+ lib/http_digest.c | 31 ++++++++++++
+ lib/urldata.h | 8 ++--
+ lib/vauth/digest.c | 4 ++
+ lib/vauth/digest_sspi.c | 2 +
+ tests/data/Makefile.am | 2 +-
+ tests/data/test1686 | 84 +++++++++++++++++++++++++++++++++
+ tests/libtest/Makefile.inc | 1 +
+ tests/libtest/lib1686.c | 96 ++++++++++++++++++++++++++++++++++++++
+ 8 files changed, 223 insertions(+), 5 deletions(-)
+ create mode 100644 tests/data/test1686
+ create mode 100644 tests/libtest/lib1686.c
+
+diff --git a/lib/http_digest.c b/lib/http_digest.c
+index ccc67f5efc..129c0d33f7 100644
+--- a/lib/http_digest.c
++++ b/lib/http_digest.c
+@@ -98,7 +98,38 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
+ #endif
+ }
+ else {
++ bool flush = FALSE;
+ digest = &data->state.digest;
++
++ if(digest->origin_host &&
++ (!curl_strequal(data->conn->host.name, digest->origin_host) ||
++ data->conn->remote_port != digest->origin_port))
++ flush = TRUE;
++ else if(digest->user &&
++ Curl_timestrcmp(data->state.aptr.user ?
++ data->state.aptr.user : "",
++ digest->user))
++ flush = TRUE;
++ else if(digest->passwd &&
++ Curl_timestrcmp(data->state.aptr.passwd ?
++ data->state.aptr.passwd : "",
++ digest->passwd))
++ flush = TRUE;
++
++ if(flush)
++ /* flush host Digest state */
++ Curl_auth_digest_cleanup(digest);
++
++ Curl_safefree(digest->origin_host);
++ digest->origin_host = curlx_strdup(data->conn->host.name);
++ digest->origin_port = data->conn->remote_port;
++ Curl_safefree(digest->user);
++ digest->user = curlx_strdup(data->state.aptr.user ?
++ data->state.aptr.user : "");
++ Curl_safefree(digest->passwd);
++ digest->passwd = curlx_strdup(data->state.aptr.passwd ?
++ data->state.aptr.passwd : "");
++
+ allocuserpwd = &data->state.aptr.userpwd;
+ userp = data->state.aptr.user;
+ passwdp = data->state.aptr.passwd;
+diff --git a/lib/urldata.h b/lib/urldata.h
+index aba1693ca7..221317e47e 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -291,14 +291,14 @@ struct ssl_general_config {
+ #ifndef CURL_DISABLE_DIGEST_AUTH
+ /* Struct used for Digest challenge-response authentication */
+ struct digestdata {
++ char *origin_host;
++ int origin_port;
++ char *user;
++ char *passwd;
+ #ifdef USE_WINDOWS_SSPI
+ BYTE *input_token;
+ size_t input_token_len;
+ CtxtHandle *http_context;
+- /* copy of user/passwd used to make the identity for http_context.
+- either may be NULL. */
+- char *user;
+- char *passwd;
+ #else
+ char *nonce;
+ char *cnonce;
+diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c
+index a1fd248617..1cd867cead 100644
+--- a/lib/vauth/digest.c
++++ b/lib/vauth/digest.c
+@@ -1013,6 +1013,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
+ */
+ void Curl_auth_digest_cleanup(struct digestdata *digest)
+ {
++ Curl_safefree(digest->origin_host);
++ digest->origin_port = 0;
++ Curl_safefree(digest->user);
++ Curl_safefree(digest->passwd);
+ Curl_safefree(digest->nonce);
+ Curl_safefree(digest->cnonce);
+ Curl_safefree(digest->realm);
+diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c
+index 615b4bc827..3fc75371b2 100644
+--- a/lib/vauth/digest_sspi.c
++++ b/lib/vauth/digest_sspi.c
+@@ -661,6 +661,8 @@ void Curl_auth_digest_cleanup(struct digestdata *digest)
+ /* Free the copy of user/passwd used to make the identity for http_context */
+ Curl_safefree(digest->user);
+ Curl_safefree(digest->passwd);
++ Curl_safefree(digest->origin_host);
++ digest->origin_port = 0;
+ }
+
+ #endif /* USE_WINDOWS_SSPI && !CURL_DISABLE_DIGEST_AUTH */
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index bff118240c..9535861b18 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -225,7 +225,7 @@ test1660 test1661 test1662 test1663 test1664 test1665 \
+ \
+ test1670 test1671 \
+ \
+-test1680 test1681 test1682 test1683 \
++test1680 test1681 test1682 test1683 test1686 \
+ \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 test1711 \
+diff --git a/tests/data/test1686 b/tests/data/test1686
+new file mode 100644
+index 0000000000..2d419ad608
+--- /dev/null
++++ b/tests/data/test1686
+@@ -0,0 +1,84 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++Digest
++</keywords>
++</info>
++
++<reply>
++<data crlf="headers" nocheck="yes">
++HTTP/1.1 401 Authorization Required
++Server: Apache/1.3.27 (Darwin) PHP/4.1.2
++WWW-Authenticate: Digest realm="my-backyard", nonce="314156295"
++Content-Length: 26
++
++This is not the real page
++</data>
++
++# This is supposed to be returned when the server gets a
++# Authorization: Digest line passed-in from the client
++<data1000 crlf="headers">
++HTTP/1.1 200 OK
++Server: Apache/1.3.27 (Darwin) PHP/4.1.2
++Content-Type: text/html; charset=iso-8859-1
++Content-Length: 23
++
++This IS the real page!
++</data1000>
++
++</reply>
++
++<client>
++<features>
++!SSPI
++crypto
++digest
++</features>
++<server>
++http
++</server>
++<name>
++HTTP Digest to different origins and switching credentials
++</name>
++<tool>
++lib%TESTNUMBER
++</tool>
++<command>
++%HOSTIP %HTTPPORT
++</command>
++</client>
++
++<verify>
++<protocol crlf="headers">
++GET /api HTTP/1.1
++Host: first.test:%HTTPPORT
++Accept: */*
++
++GET /api HTTP/1.1
++Host: first.test:%HTTPPORT
++Authorization: Digest username="alice", realm="my-backyard", nonce="314156295", uri="/api", response="4ecc00e567c37a9d537727890c2e5b32"
++Accept: */*
++
++GET /hook HTTP/1.1
++Host: second.test:%HTTPPORT
++Accept: */*
++
++GET /hook HTTP/1.1
++Host: second.test:%HTTPPORT
++Authorization: Digest username="alice", realm="my-backyard", nonce="314156295", uri="/hook", response="d3a7738fb6a23f5543fb8dacc0f0f253"
++Accept: */*
++
++GET /hook HTTP/1.1
++Host: second.test:%HTTPPORT
++Accept: */*
++
++GET /hook HTTP/1.1
++Host: second.test:%HTTPPORT
++Authorization: Digest username="bob", realm="my-backyard", nonce="314156295", uri="/hook", response="777e68eddb77294d9cbd6134973cbbab"
++Accept: */*
++
++</protocol>
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index e3202804a9..5c5660ffd8 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -101,6 +101,7 @@ TESTS_C = \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
+ lib1662.c \
++ lib1686.c \
+ lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
+ lib1908.c lib1910.c lib1911.c lib1912.c lib1913.c \
+ lib1915.c lib1916.c lib1918.c lib1919.c lib1920.c \
+diff --git a/tests/libtest/lib1686.c b/tests/libtest/lib1686.c
+new file mode 100644
+index 0000000000..e457012bb9
+--- /dev/null
++++ b/tests/libtest/lib1686.c
+@@ -0,0 +1,96 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++#include "first.h"
++
++static size_t devnull_1686(char *p, size_t s, size_t n, void *u)
++{
++ (void)p;
++ (void)u;
++ return s * n;
++}
++
++#define FIRSTHOST "first.test"
++#define SECONDHOST "second.test"
++
++static CURLcode test_lib1686(const char *hostip)
++{
++ CURL *curl = NULL;
++ CURLcode result = CURLE_OK;
++ const char *httpport = libtest_arg2;
++ char firsturl[100];
++ char secondurl[100];
++ char firstres[100];
++ char secondres[100];
++ struct curl_slist *host = NULL;
++ struct curl_slist *host2 = NULL;
++
++ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
++ curl_mfprintf(stderr, "curl_global_init() failed\n");
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ /* create strings for CURLOPT_RESOLVE */
++ curl_msnprintf(firstres, sizeof(firstres), "%s:%s:%s",
++ FIRSTHOST, httpport, hostip);
++ curl_msnprintf(secondres, sizeof(secondres), "%s:%s:%s",
++ SECONDHOST, httpport, hostip);
++
++ /* create URLs */
++ curl_msnprintf(firsturl, sizeof(firsturl), "http://%s:%s/api",
++ FIRSTHOST, httpport);
++ curl_msnprintf(secondurl, sizeof(secondurl), "http://%s:%s/hook",
++ SECONDHOST, httpport);
++
++ host = curl_slist_append(NULL, firstres);
++ if(!host)
++ goto test_cleanup;
++ host2 = curl_slist_append(host, secondres);
++ if(!host2)
++ goto test_cleanup;
++ host = host2;
++
++ curl = curl_easy_init();
++ if(curl) {
++ easy_setopt(curl, CURLOPT_RESOLVE, host);
++ easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
++ easy_setopt(curl, CURLOPT_USERPWD, "alice:bond");
++ easy_setopt(curl, CURLOPT_WRITEFUNCTION, devnull_1686);
++
++ easy_setopt(curl, CURLOPT_URL, firsturl);
++ result = curl_easy_perform(curl);
++
++ easy_setopt(curl, CURLOPT_URL, secondurl);
++ result = curl_easy_perform(curl);
++
++ easy_setopt(curl, CURLOPT_USERPWD, "bob:secret");
++ easy_setopt(curl, CURLOPT_URL, secondurl);
++ result = curl_easy_perform(curl);
++ }
++
++test_cleanup:
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ curl_slist_free_all(host);
++ return result;
++}
diff --git a/0012-curl-8.18.0-CVE-2026-7009.patch b/0012-curl-8.18.0-CVE-2026-7009.patch
deleted file mode 100644
index d32d124..0000000
--- a/0012-curl-8.18.0-CVE-2026-7009.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 450e25e9ee7c679a1c782f31ed8085d01cfd0e6d Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Sat, 25 Apr 2026 10:34:06 +0200
-Subject: [PATCH] sectrust: fail on missing OCSP stapling
-
-When using Apple SecTrust, requiring the server to send
-an OCSP response and does not, fail correctly.
-
-Reported-by: Carlos Carrillo
-Closes #21444
-
-(cherry picked from commit 51905671e07f087e28e5741063646c379fe17d89)
----
- lib/vtls/openssl.c | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index ebe583154f..f044c10e14 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4708,16 +4708,26 @@ static CURLcode ossl_apple_verify(struct Curl_cfilter *cf,
- unsigned char *ocsp_data = NULL;
- #endif
- long ocsp_len = 0;
-+ bool ocsp_missing = FALSE;
- if(conn_config->verifystatus && !octx->reused_session)
- ocsp_len = (long)SSL_get_tlsext_status_ocsp_resp(octx->ssl, &ocsp_data);
-
- /* SSL_get_tlsext_status_ocsp_resp() returns the length of the OCSP
- response data or -1 if there is no OCSP response data. */
-- if(ocsp_len < 0)
-+ if(ocsp_len < 0) {
- ocsp_len = 0; /* no data available */
-+ ocsp_missing = TRUE;
-+ }
- result = Curl_vtls_apple_verify(cf, data, peer, chain.num_certs,
- ossl_chain_get_der, &chain,
- ocsp_data, ocsp_len);
-+ if(!result && ocsp_missing && conn_config->verifystatus &&
-+ !octx->reused_session) {
-+ /* verified, but OCSP stapling is required and server sent none */
-+ *pverified = TRUE;
-+ failf(data, "No OCSP response received");
-+ return CURLE_SSL_INVALIDCERTSTATUS;
-+ }
- }
- *pverified = !result;
- return result;
---
-2.55.0
-
diff --git a/0012-setopt-clear-proxy-auth-properties-when-switching.patch b/0012-setopt-clear-proxy-auth-properties-when-switching.patch
new file mode 100644
index 0000000..385d5d1
--- /dev/null
+++ b/0012-setopt-clear-proxy-auth-properties-when-switching.patch
@@ -0,0 +1,369 @@
+From 7cdfb2448c690f990567465e3e52ae90857fbaa4 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 27 Apr 2026 09:14:51 +0200
+Subject: [PATCH] setopt: clear proxy auth properties when switching
+
+Verify with test 1588
+
+Closes #21453
+
+(cherry picked from commit c1cfdf59acbaf9504c4578d4cf56cdd7c8594507)
+---
+ lib/setopt.c | 18 ++++-
+ lib/vauth/vauth.h | 1 +
+ tests/data/Makefile.am | 1 +
+ tests/data/test1588 | 106 ++++++++++++++++++++++++++
+ tests/libtest/Makefile.inc | 2 +-
+ tests/libtest/lib1588.c | 150 +++++++++++++++++++++++++++++++++++++
+ 6 files changed, 276 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test1588
+ create mode 100644 tests/libtest/lib1588.c
+
+diff --git a/lib/setopt.c b/lib/setopt.c
+index 0c1da5bc12..65c573cb9d 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -49,6 +49,7 @@
+ #include "strdup.h"
+ #include "escape.h"
+ #include "bufref.h"
++#include "vauth/vauth.h"
+
+ static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
+ {
+@@ -1614,6 +1615,21 @@ 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) &&
++ !strcmp(data->set.str[STRING_PROXY], proxy))
++ return CURLE_OK;
++
++ 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);
++}
++
++#endif
++
+ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
+ char *ptr)
+ {
+@@ -1821,7 +1837,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
+ * Setting it to NULL, means no proxy but allows the environment variables
+ * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
+ */
+- return Curl_setstropt(&s->str[STRING_PROXY], ptr);
++ return setproxy(data, ptr);
+
+ case CURLOPT_PRE_PROXY:
+ /*
+diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h
+index 312bd8da5a..15da62678c 100644
+--- a/lib/vauth/vauth.h
++++ b/lib/vauth/vauth.h
+@@ -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 */
+
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 9535861b18..b050f708eb 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -209,6 +209,7 @@ test1556 test1557 test1558 test1559 test1560 test1561 test1562 test1563 \
+ test1564 test1565 test1566 test1567 test1568 test1569 test1570 test1571 \
+ test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 \
+ test1580 test1581 test1582 test1583 test1584 test1585 \
++test1588 \
+ test1629 \
+ \
+ test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
+diff --git a/tests/data/test1588 b/tests/data/test1588
+new file mode 100644
+index 0000000000..753e98cd6b
+--- /dev/null
++++ b/tests/data/test1588
+@@ -0,0 +1,106 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++HTTP proxy
++HTTP proxy Digest auth
++multi
++</keywords>
++</info>
++
++# Server-side
++<reply>
++
++# this is returned first since we get no proxy-auth
++<data crlf="headers">
++HTTP/1.1 407 Authorization Required to proxy me my dear
++Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
++Content-Length: 33
++
++And you should ignore this data.
++</data>
++
++# then this is returned when we get proxy-auth
++<data1000 crlf="headers">
++HTTP/1.1 200 OK
++Content-Length: 21
++Server: no
++
++Nice proxy auth sir!
++</data1000>
++
++<datacheck crlf="headers">
++HTTP/1.1 407 Authorization Required to proxy me my dear
++Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
++Content-Length: 33
++
++HTTP/1.1 200 OK
++Content-Length: 21
++Server: no
++
++Nice proxy auth sir!
++HTTP/1.1 407 Authorization Required to proxy me my dear
++Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
++Content-Length: 33
++
++HTTP/1.1 200 OK
++Content-Length: 21
++Server: no
++
++Nice proxy auth sir!
++</datacheck>
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++# tool is what to use instead of 'curl'
++<tool>
++lib%TESTNUMBER
++</tool>
++<features>
++!SSPI
++crypto
++proxy
++digest
++</features>
++<name>
++HTTP proxy auth Digest, then change proxy and do it again
++</name>
++<command>
++http://test.remote.example.com/path/%TESTNUMBER %HOSTIP %HTTPPORT silly:person custom.set.host.name
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET http://test.remote.example.com/path/1588 HTTP/1.1
++Host: test.remote.example.com
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://test.remote.example.com/path/1588 HTTP/1.1
++Host: test.remote.example.com
++Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/1588", response="d0b2f000c7e3fca24452b5810713404a"
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://test.remote.example.com/path/1588 HTTP/1.1
++Host: test.remote.example.com
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://test.remote.example.com/path/1588 HTTP/1.1
++Host: test.remote.example.com
++Proxy-Authorization: Digest username="silly", realm="weirdorealm", nonce="12345", uri="/path/1588", response="d0b2f000c7e3fca24452b5810713404a"
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++</protocol>
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index 5c5660ffd8..76014f926a 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -97,7 +97,7 @@ TESTS_C = \
+ lib1559.c lib1560.c lib1564.c lib1565.c \
+ lib1567.c lib1568.c lib1569.c lib1571.c \
+ lib1576.c \
+- lib1582.c \
++ lib1582.c lib1588.c \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
+ lib1662.c \
+diff --git a/tests/libtest/lib1588.c b/tests/libtest/lib1588.c
+new file mode 100644
+index 0000000000..9b12f36bfe
+--- /dev/null
++++ b/tests/libtest/lib1588.c
+@@ -0,0 +1,150 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++/*
++ * argv1 = URL
++ * argv2 = proxy host
++ * argv3 = proxy port
++ * argv4 = proxyuser:password
++ */
++
++#include "first.h"
++
++static CURLcode init1588(CURL *curl, const char *url,
++ const char *userpwd, const char *proxy)
++{
++ CURLcode result = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(result)
++ goto init_failed;
++#if 0
++ res_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
++ if(result)
++ goto init_failed;
++#endif
++
++ res_easy_setopt(curl, CURLOPT_HEADER, 1L);
++ if(result)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return result; /* failure */
++}
++
++static CURLcode run1588(CURL *curl, const char *url, const char *userpwd,
++ const char *proxy)
++{
++ CURLcode result = CURLE_OK;
++
++ result = init1588(curl, url, userpwd, proxy);
++ if(result)
++ return result;
++
++ return curl_easy_perform(curl);
++}
++
++static CURLcode test_lib1588(const char *URL)
++{
++ CURLcode result = CURLE_OK;
++ CURL *curl = NULL;
++ const char *proxyuserpws = libtest_arg4;
++ struct curl_slist *host = NULL;
++ struct curl_slist *host2 = NULL;
++ char proxy1_resolve[128];
++ char proxy2_resolve[128];
++ char proxy1_connect[128];
++ char proxy2_connect[128];
++
++ if(test_argc < 3)
++ return TEST_ERR_MAJOR_BAD;
++
++ curl_msnprintf(proxy1_resolve, sizeof(proxy1_resolve),
++ "firstproxy:%s:%s", libtest_arg3, libtest_arg2);
++ curl_msnprintf(proxy2_resolve, sizeof(proxy2_resolve),
++ "secondproxy:%s:%s", libtest_arg3, libtest_arg2);
++
++ /* we connect to the fake host name but the right port number */
++ curl_msnprintf(proxy1_connect, sizeof(proxy1_connect),
++ "firstproxy:%s", libtest_arg3);
++ curl_msnprintf(proxy2_connect, sizeof(proxy2_connect),
++ "secondproxy:%s", libtest_arg3);
++
++ res_global_init(CURL_GLOBAL_ALL);
++ if(result)
++ return result;
++
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_mfprintf(stderr, "curl_easy_init() failed\n");
++ curl_global_cleanup();
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ host = curl_slist_append(NULL, proxy1_resolve);
++ if(!host)
++ goto test_cleanup;
++ host2 = curl_slist_append(host, proxy2_resolve);
++ if(!host2)
++ goto test_cleanup;
++ host = host2;
++
++ start_test_timing();
++
++ easy_setopt(curl, CURLOPT_RESOLVE, host);
++
++ result = run1588(curl, URL, proxyuserpws, proxy1_connect);
++ if(result)
++ goto test_cleanup;
++
++ curl_mfprintf(stderr, "lib1588: now we do the request again\n");
++
++ result = run1588(curl, URL, proxyuserpws, proxy2_connect);
++
++test_cleanup:
++
++ /* proper cleanup sequence - type PB */
++
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ curl_slist_free_all(host);
++ return result;
++}
diff --git a/0013-curl-8.18.0-CVE-2026-11352.patch b/0013-curl-8.18.0-CVE-2026-11352.patch
deleted file mode 100644
index 8622983..0000000
--- a/0013-curl-8.18.0-CVE-2026-11352.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From f6b3d1ae69385011555fd75a2a276ba6240d501f Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 5 Jun 2026 08:34:46 +0200
-Subject: [PATCH] quic: count zero length packets against max
-
-With a flood of zero lenght UDP packets to curl, the receive loop might
-run longer than intended to. Count such packets against the max to
-terminate the loop as intended.
-
-URL: https://hackerone.com/reports/3783438
-Reported-by: vectorqueue on hackerone
-Closes #21869
-
-(cherry picked from commit 56eca2afb4806f1032872fa97d1834b3c1385276)
----
- lib/vquic/vquic.c | 8 ++++++--
- 1 file changed, 6 insertions(+), 2 deletions(-)
-
-diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c
-index d7bfa99104..f455fe41f8 100644
---- a/lib/vquic/vquic.c
-+++ b/lib/vquic/vquic.c
-@@ -448,8 +448,10 @@ static CURLcode recvmmsg_packets(struct Curl_cfilter *cf,
- ++calls;
- for(i = 0; i < mcount; ++i) {
- /* A zero-length UDP packet is no QUIC packet. Ignore. */
-- if(!mmsg[i].msg_len)
-+ if(!mmsg[i].msg_len) {
-+ ++pkts;
- continue;
-+ }
- total_nread += mmsg[i].msg_len;
-
- gso_size = vquic_msghdr_get_udp_gro(&mmsg[i].msg_hdr);
-@@ -532,8 +534,10 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf,
- ++calls;
-
- /* A 0-length UDP packet is no QUIC packet */
-- if(!nread)
-+ if(!nread) {
-+ ++pkts;
- continue;
-+ }
-
- gso_size = vquic_msghdr_get_udp_gro(&msg);
- if(gso_size == 0)
---
-2.55.0
-
diff --git a/0013-sectrust-fail-on-missing-OCSP-stapling.patch b/0013-sectrust-fail-on-missing-OCSP-stapling.patch
new file mode 100644
index 0000000..6501c83
--- /dev/null
+++ b/0013-sectrust-fail-on-missing-OCSP-stapling.patch
@@ -0,0 +1,48 @@
+From caa25f8e9a4c8d06ac01a5596c693ffdece87685 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Sat, 25 Apr 2026 10:34:06 +0200
+Subject: [PATCH] sectrust: fail on missing OCSP stapling
+
+When using Apple SecTrust, requiring the server to send
+an OCSP response and does not, fail correctly.
+
+Reported-by: Carlos Carrillo
+Closes #21444
+
+(cherry picked from commit 51905671e07f087e28e5741063646c379fe17d89)
+---
+ lib/vtls/openssl.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index ebe583154f..f044c10e14 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4708,16 +4708,26 @@ static CURLcode ossl_apple_verify(struct Curl_cfilter *cf,
+ unsigned char *ocsp_data = NULL;
+ #endif
+ long ocsp_len = 0;
++ bool ocsp_missing = FALSE;
+ if(conn_config->verifystatus && !octx->reused_session)
+ ocsp_len = (long)SSL_get_tlsext_status_ocsp_resp(octx->ssl, &ocsp_data);
+
+ /* SSL_get_tlsext_status_ocsp_resp() returns the length of the OCSP
+ response data or -1 if there is no OCSP response data. */
+- if(ocsp_len < 0)
++ if(ocsp_len < 0) {
+ ocsp_len = 0; /* no data available */
++ ocsp_missing = TRUE;
++ }
+ result = Curl_vtls_apple_verify(cf, data, peer, chain.num_certs,
+ ossl_chain_get_der, &chain,
+ ocsp_data, ocsp_len);
++ if(!result && ocsp_missing && conn_config->verifystatus &&
++ !octx->reused_session) {
++ /* verified, but OCSP stapling is required and server sent none */
++ *pverified = TRUE;
++ failf(data, "No OCSP response received");
++ return CURLE_SSL_INVALIDCERTSTATUS;
++ }
+ }
+ *pverified = !result;
+ return result;
diff --git a/0014-curl-8.18.0-CVE-2026-11586.patch b/0014-curl-8.18.0-CVE-2026-11586.patch
deleted file mode 100644
index ce175ae..0000000
--- a/0014-curl-8.18.0-CVE-2026-11586.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-From 2c1a702de4d44681bab1db6691520442aec08804 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Mon, 8 Jun 2026 16:57:01 +0200
-Subject: [PATCH] ws: make pong sending lazy
-
-Do not send PONG frames unless there is sufficient space left in the
-websocket send buffer. A server might be lazy in reading our data and
-intermediary PONG frames can be skipped by a client (RFC 6455, ch.
-5.5.3).
-
-Add test case measuring no real RSS increase on a server blasting with
-PING frames.
-
-Closes #21911
-
-(cherry picked from commit 849317ff5c5a5e13f50ec3d001e46ddffa77d8a4)
----
- lib/ws.c | 33 +++++++++-----
- tests/http/test_20_websockets.py | 78 ++++++++++++++++++++++++++++++++
- 2 files changed, 99 insertions(+), 12 deletions(-)
-
-diff --git a/lib/ws.c b/lib/ws.c
-index 37cacae966..fcacef2079 100644
---- a/lib/ws.c
-+++ b/lib/ws.c
-@@ -624,6 +624,7 @@ static CURLcode ws_enc_add_cntrl(struct Curl_easy *data,
- size_t plen,
- unsigned int frame_type)
- {
-+ (void)data;
- DEBUGASSERT(plen <= WS_MAX_CNTRL_LEN);
- if(plen > WS_MAX_CNTRL_LEN)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-@@ -633,13 +634,6 @@ static CURLcode ws_enc_add_cntrl(struct Curl_easy *data,
- ws->pending.type = frame_type;
- ws->pending.payload_len = plen;
- memcpy(ws->pending.payload, payload, plen);
--
-- if(!ws->enc.payload_remain) { /* not in the middle of another frame */
-- CURLcode result = ws_enc_add_pending(data, ws);
-- if(!result)
-- (void)ws_flush(data, ws, Curl_is_in_callback(data));
-- return result;
-- }
- return CURLE_OK;
- }
-
-@@ -708,7 +702,7 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
- {
- struct ws_cw_ctx *ctx = writer->ctx;
- struct websocket *ws;
-- CURLcode result;
-+ CURLcode result = CURLE_OK;
-
- CURL_TRC_WRITE(data, "ws_cw_write(len=%zu, type=%d)", nbytes, type);
- if(!(type & CLIENTWRITE_BODY) || data->set.ws_raw_mode)
-@@ -741,7 +735,8 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
- if(result == CURLE_AGAIN) {
- /* insufficient amount of data, keep it for later.
- * we pretend to have written all since we have a copy */
-- return CURLE_OK;
-+ result = CURLE_OK;
-+ goto out;
- }
- else if(result) {
- failf(data, "[WS] decode payload error %d", (int)result);
-@@ -752,10 +747,16 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
- if((type & CLIENTWRITE_EOS) && !Curl_bufq_is_empty(&ctx->buf)) {
- failf(data, "[WS] decode ending with %zd frame bytes remaining",
- Curl_bufq_len(&ctx->buf));
-- return CURLE_RECV_ERROR;
-+ result = CURLE_RECV_ERROR;
- }
-
-- return CURLE_OK;
-+out:
-+ if(!result) {
-+ result = ws_flush(data, ws, Curl_is_in_callback(data));
-+ if(result == CURLE_AGAIN)
-+ result = CURLE_OK;
-+ }
-+ return result;
- }
-
- /* WebSocket payload decoding client writer. */
-@@ -1616,8 +1617,16 @@ CURLcode curl_ws_recv(CURL *d, void *buffer,
- static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws,
- bool blocking)
- {
-+ CURLcode result;
-+
-+ /* If there is space, add any pending control frame */
-+ if(Curl_bufq_len(&ws->sendbuf) < ws->sendbuf.chunk_size) {
-+ result = ws_enc_add_pending(data, ws);
-+ if(result && (result != CURLE_AGAIN))
-+ return result;
-+ }
-+
- if(!Curl_bufq_is_empty(&ws->sendbuf)) {
-- CURLcode result;
- const uint8_t *out;
- size_t outlen, n;
- #ifdef DEBUGBUILD
-diff --git a/tests/http/test_20_websockets.py b/tests/http/test_20_websockets.py
-index 2612b0afe1..b935ed9d67 100644
---- a/tests/http/test_20_websockets.py
-+++ b/tests/http/test_20_websockets.py
-@@ -24,11 +24,15 @@
- #
- ###########################################################################
- #
-+import base64
-+import hashlib
- import logging
- import os
-+import re
- import shutil
- import socket
- import subprocess
-+import threading
- import time
- from datetime import datetime, timedelta
- from typing import Dict
-@@ -207,3 +211,77 @@ class TestWebsockets:
- large = 0
- r = client.run(args=[f'-{model}', '-c', str(count), '-m', str(large), url])
- r.check_exit_code(0)
-+
-+ def test_20_11_crazy_pings(self, env: Env):
-+ st = {}
-+ send_rounds = 1
-+
-+ def srv():
-+ try:
-+ with socket.socket() as s:
-+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-+ s.bind(("127.0.0.1", 0))
-+ s.listen(1)
-+ st["p"] = s.getsockname()[1]
-+
-+ c, _ = s.accept()
-+ c.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 4096)
-+ c.settimeout(Env.SERVER_TIMEOUT)
-+ req = b""
-+ while b"\r\n\r\n" not in req:
-+ req += c.recv(4096)
-+
-+ k = re.search(rb"(?im)^Sec-WebSocket-Key:\s*(\S+)", req).group(1)
-+ a = base64.b64encode(
-+ hashlib.sha1(k + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest()
-+ ).decode()
-+ c.sendall(
-+ (
-+ "HTTP/1.1 101 Switching Protocols\r\n"
-+ "Upgrade: websocket\r\n"
-+ "Connection: Upgrade\r\n"
-+ f"Sec-WebSocket-Accept: {a}\r\n\r\n"
-+ ).encode()
-+ )
-+
-+ f = b"\x89\x00" * 65536 # PING frames, many
-+ try:
-+ for _ in range(send_rounds):
-+ c.sendall(f)
-+ f = b"\x88\x00" # CLOSE frame
-+ c.sendall(f)
-+ except OSError:
-+ pass
-+ time.sleep(1)
-+ c.close()
-+ except OSError as e:
-+ st["err"] = e
-+
-+ curl = CurlClient(env=env)
-+ send_rounds = 2
-+ threading.Thread(target=srv, daemon=True).start()
-+ while "p" not in st and "err" not in st:
-+ time.sleep(0.01)
-+ assert "err" not in st, f'ws-ping server failed to start: {st["err"]}'
-+
-+ url = f'ws://127.0.0.1:{st["p"]}/'
-+ r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
-+ with_profile=True)
-+ assert r.exit_code in [55, 56], f'{r.dump_logs()}' # SEND/RECV_ERROR
-+ assert r.profile, f'{r}'
-+ rss1 = r.profile.stats['rss'] / (1024 * 1024)
-+
-+ st.clear()
-+ send_rounds = 10
-+ threading.Thread(target=srv, daemon=True).start()
-+ while "p" not in st and "err" not in st:
-+ time.sleep(0.01)
-+ assert "err" not in st, f'ws-ping server failed to start: {st["err"]}'
-+
-+ url = f'ws://127.0.0.1:{st["p"]}/'
-+ r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
-+ with_profile=True)
-+ assert r.exit_code in [55, 56], f'{r.dump_logs()}' # SEND/RECV_ERROR
-+ assert r.profile, f'{r}'
-+ rss2 = r.profile.stats['rss'] / (1024 * 1024)
-+ assert (rss1 * 1.1) >= rss2, 'bad memory increase'
---
-2.55.0
-
diff --git a/0014-quic-count-zero-length-packets-against-max.patch b/0014-quic-count-zero-length-packets-against-max.patch
new file mode 100644
index 0000000..a36b881
--- /dev/null
+++ b/0014-quic-count-zero-length-packets-against-max.patch
@@ -0,0 +1,46 @@
+From 0f051f258e3b28672e8b4b74e49e4e0fd439d33b Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Fri, 5 Jun 2026 08:34:46 +0200
+Subject: [PATCH] quic: count zero length packets against max
+
+With a flood of zero lenght UDP packets to curl, the receive loop might
+run longer than intended to. Count such packets against the max to
+terminate the loop as intended.
+
+URL: https://hackerone.com/reports/3783438
+Reported-by: vectorqueue on hackerone
+Closes #21869
+
+(cherry picked from commit 56eca2afb4806f1032872fa97d1834b3c1385276)
+---
+ lib/vquic/vquic.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c
+index d7bfa99104..f455fe41f8 100644
+--- a/lib/vquic/vquic.c
++++ b/lib/vquic/vquic.c
+@@ -448,8 +448,10 @@ static CURLcode recvmmsg_packets(struct Curl_cfilter *cf,
+ ++calls;
+ for(i = 0; i < mcount; ++i) {
+ /* A zero-length UDP packet is no QUIC packet. Ignore. */
+- if(!mmsg[i].msg_len)
++ if(!mmsg[i].msg_len) {
++ ++pkts;
+ continue;
++ }
+ total_nread += mmsg[i].msg_len;
+
+ gso_size = vquic_msghdr_get_udp_gro(&mmsg[i].msg_hdr);
+@@ -532,8 +534,10 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf,
+ ++calls;
+
+ /* A 0-length UDP packet is no QUIC packet */
+- if(!nread)
++ if(!nread) {
++ ++pkts;
+ continue;
++ }
+
+ gso_size = vquic_msghdr_get_udp_gro(&msg);
+ if(gso_size == 0)
diff --git a/0015-curl-8.18.0-CVE-2026-12064.patch b/0015-curl-8.18.0-CVE-2026-12064.patch
deleted file mode 100644
index 8c349c9..0000000
--- a/0015-curl-8.18.0-CVE-2026-12064.patch
+++ /dev/null
@@ -1,258 +0,0 @@
-From bbb2fed4fb5b8526a07607cc5899cdf4f0e16efd Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Fri, 12 Jun 2026 09:01:22 +0200
-Subject: [PATCH] config2setopts: use default protocol properly
-
-Verified by test 1724, 1725 and 2036
-
-Closes #21983
-
-(cherry picked from commit ab3bb8cd8be8f9d4acb97da0418abc279182041e)
----
- docs/cmdline-opts/proto-default.md | 6 +++-
- src/config2setopts.c | 51 +++++++++++++++++-----------
- tests/data/Makefile.am | 3 +-
- tests/data/test1724 | 53 ++++++++++++++++++++++++++++++
- tests/data/test1725 | 29 ++++++++++++++++
- tests/data/test2036 | 26 +++++++++++++++
- 6 files changed, 146 insertions(+), 22 deletions(-)
- create mode 100644 tests/data/test1724
- create mode 100644 tests/data/test1725
- create mode 100644 tests/data/test2036
-
-diff --git a/docs/cmdline-opts/proto-default.md b/docs/cmdline-opts/proto-default.md
-index 209e5cdc83..903fac73a5 100644
---- a/docs/cmdline-opts/proto-default.md
-+++ b/docs/cmdline-opts/proto-default.md
-@@ -16,7 +16,8 @@ Example:
-
- # `--proto-default`
-
--Use *protocol* for any provided URL missing a scheme.
-+Use *protocol* for any provided URL missing a scheme. The case-insensitive
-+name should be given without any `://` suffix.
-
- An unknown or unsupported protocol causes error *CURLE_UNSUPPORTED_PROTOCOL*.
-
-@@ -24,3 +25,6 @@ This option does not change the default proxy protocol (http).
-
- Without this option set, curl guesses protocol based on the hostname, see
- --url for details.
-+
-+The default protocol cannot be set to `ipfs` or `ipns`. Those schemes need to
-+be used explicitly in the URL.
-diff --git a/src/config2setopts.c b/src/config2setopts.c
-index d462e8cd54..a69f3adb20 100644
---- a/src/config2setopts.c
-+++ b/src/config2setopts.c
-@@ -143,29 +143,40 @@ static CURLcode url_proto_and_rewrite(char **url,
- curl_url_set(uh, CURLUPART_URL, *url,
- CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME);
- if(!uc) {
-- uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, CURLU_DEFAULT_SCHEME);
-- if(!uc) {
--#ifdef CURL_DISABLE_IPFS
-- (void)config;
--#else
-- if(curl_strequal(schemep, proto_ipfs) ||
-- curl_strequal(schemep, proto_ipns)) {
-- result = ipfs_url_rewrite(uh, schemep, url, config);
-- /* short-circuit proto_token, we know it is ipfs or ipns */
-- if(curl_strequal(schemep, proto_ipfs))
-- proto = proto_ipfs;
-- else if(curl_strequal(schemep, proto_ipns))
-- proto = proto_ipns;
-- if(result)
-- config->synthetic_error = TRUE;
-+ if(config->proto_default) {
-+ /* when a default proto is requested, do not guess */
-+ uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep,
-+ CURLU_NO_GUESS_SCHEME);
-+ if(uc == CURLUE_NO_SCHEME) {
-+ /* use the default */
-+ proto = proto_token(config->proto_default);
-+ if(proto)
-+ uc = CURLUE_OK;
- }
-- else
--#endif /* !CURL_DISABLE_IPFS */
-- proto = proto_token(schemep);
-- curl_free(schemep);
- }
-- else if(uc == CURLUE_OUT_OF_MEMORY)
-+ else {
-+ uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep,
-+ CURLU_DEFAULT_SCHEME);
-+ }
-+ if(schemep)
-+ proto = proto_token(schemep);
-+#ifndef CURL_DISABLE_IPFS
-+ if(!uc &&
-+ (curl_strequal(schemep, proto_ipfs) ||
-+ curl_strequal(schemep, proto_ipns))) {
-+ result = ipfs_url_rewrite(uh, schemep, url, config);
-+ /* short-circuit proto_token, we know it is ipfs or ipns */
-+ if(curl_strequal(schemep, proto_ipfs))
-+ proto = proto_ipfs;
-+ else if(curl_strequal(schemep, proto_ipns))
-+ proto = proto_ipns;
-+ if(result)
-+ config->synthetic_error = TRUE;
-+ }
-+#endif /* !CURL_DISABLE_IPFS */
-+ if(uc == CURLUE_OUT_OF_MEMORY)
- result = CURLE_OUT_OF_MEMORY;
-+ curl_free(schemep);
- }
- else if(uc == CURLUE_OUT_OF_MEMORY)
- result = CURLE_OUT_OF_MEMORY;
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index b050f708eb..57e7508751 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -230,6 +230,7 @@ test1680 test1681 test1682 test1683 test1686 \
- \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 test1711 \
-+test1724 test1725 \
- \
- test1800 test1801 test1802 test1850 \
- \
-@@ -247,7 +248,7 @@ test2000 test2001 test2002 test2003 test2004 test2005 test2006 \
- \
- test2023 \
- test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
--test2032 test2033 test2034 test2035 test2037 test2038 test2039 \
-+test2032 test2033 test2034 test2035 test2036 test2037 test2038 test2039 \
- test2040 test2041 test2042 test2043 test2044 test2045 test2046 test2047 \
- test2048 test2049 test2050 test2051 test2052 test2053 test2054 test2055 \
- test2056 test2057 test2058 test2059 test2060 test2061 test2062 test2063 \
-diff --git a/tests/data/test1724 b/tests/data/test1724
-new file mode 100644
-index 0000000000..3cd328e39c
---- /dev/null
-+++ b/tests/data/test1724
-@@ -0,0 +1,53 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+IPFS
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+<data nocheck="yes">
-+HTTP/1.1 200 OK
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: test-server/fake
-+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-+ETag: "21025-dc7-39462498"
-+Accept-Ranges: bytes
-+Content-Length: 21
-+Connection: close
-+Content-Type: text/plain
-+Funny-head: yesyes
-+
-+Hello curl from IPFS
-+</data>
-+</reply>
-+
-+# Client-side
-+<client>
-+<features>
-+ipfs
-+</features>
-+<server>
-+http
-+</server>
-+<name>
-+IPFS with --proto-default HTTP
-+</name>
-+<command>
-+--ipfs-gateway http://%HOSTIP:%HTTPPORT ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u --proto-default http
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET /ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+User-Agent: curl/%VERSION
-+Accept: */*
-+
-+</protocol>
-+</verify>
-+</testcase>
-diff --git a/tests/data/test1725 b/tests/data/test1725
-new file mode 100644
-index 0000000000..2a882c791d
---- /dev/null
-+++ b/tests/data/test1725
-@@ -0,0 +1,29 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+SCP
-+server key check
-+</keywords>
-+</info>
-+
-+# Client-side
-+<client>
-+<server>
-+scp
-+</server>
-+<name>
-+SCP incorrect host key with --proto-default SCP
-+</name>
-+<command>
-+--hostpubmd5 00000000000000000000000000000000 --key %LOGDIR/server/curl_client_key --pubkey %LOGDIR/server/curl_client_key.pub -u %USER: %HOSTIP:%SSHPORT%SCP_PWD/%LOGDIR/irrelevant-file --insecure --proto-default SCP
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<errorcode>
-+60
-+</errorcode>
-+</verify>
-+</testcase>
-diff --git a/tests/data/test2036 b/tests/data/test2036
-new file mode 100644
-index 0000000000..b017a71abc
---- /dev/null
-+++ b/tests/data/test2036
-@@ -0,0 +1,26 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+--proto-default
-+</keywords>
-+</info>
-+
-+# Client-side
-+<client>
-+<name>
-+Attempt to set a default protocol with :// suffix
-+</name>
-+<command>
-+--proto-default https://
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+# CURLE_UNSUPPORTED_PROTOCOL is error code 1
-+<errorcode>
-+1
-+</errorcode>
-+</verify>
-+</testcase>
---
-2.55.0
-
diff --git a/0015-ws-make-pong-sending-lazy.patch b/0015-ws-make-pong-sending-lazy.patch
new file mode 100644
index 0000000..bb8ea37
--- /dev/null
+++ b/0015-ws-make-pong-sending-lazy.patch
@@ -0,0 +1,201 @@
+From 27e66ea7e5df13a393c7fbd9fad306c4c456fa47 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 8 Jun 2026 16:57:01 +0200
+Subject: [PATCH] ws: make pong sending lazy
+
+Do not send PONG frames unless there is sufficient space left in the
+websocket send buffer. A server might be lazy in reading our data and
+intermediary PONG frames can be skipped by a client (RFC 6455, ch.
+5.5.3).
+
+Add test case measuring no real RSS increase on a server blasting with
+PING frames.
+
+Closes #21911
+
+(cherry picked from commit 849317ff5c5a5e13f50ec3d001e46ddffa77d8a4)
+---
+ lib/ws.c | 33 +++++++++-----
+ tests/http/test_20_websockets.py | 78 ++++++++++++++++++++++++++++++++
+ 2 files changed, 99 insertions(+), 12 deletions(-)
+
+diff --git a/lib/ws.c b/lib/ws.c
+index 37cacae966..fcacef2079 100644
+--- a/lib/ws.c
++++ b/lib/ws.c
+@@ -624,6 +624,7 @@ static CURLcode ws_enc_add_cntrl(struct Curl_easy *data,
+ size_t plen,
+ unsigned int frame_type)
+ {
++ (void)data;
+ DEBUGASSERT(plen <= WS_MAX_CNTRL_LEN);
+ if(plen > WS_MAX_CNTRL_LEN)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+@@ -633,13 +634,6 @@ static CURLcode ws_enc_add_cntrl(struct Curl_easy *data,
+ ws->pending.type = frame_type;
+ ws->pending.payload_len = plen;
+ memcpy(ws->pending.payload, payload, plen);
+-
+- if(!ws->enc.payload_remain) { /* not in the middle of another frame */
+- CURLcode result = ws_enc_add_pending(data, ws);
+- if(!result)
+- (void)ws_flush(data, ws, Curl_is_in_callback(data));
+- return result;
+- }
+ return CURLE_OK;
+ }
+
+@@ -708,7 +702,7 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
+ {
+ struct ws_cw_ctx *ctx = writer->ctx;
+ struct websocket *ws;
+- CURLcode result;
++ CURLcode result = CURLE_OK;
+
+ CURL_TRC_WRITE(data, "ws_cw_write(len=%zu, type=%d)", nbytes, type);
+ if(!(type & CLIENTWRITE_BODY) || data->set.ws_raw_mode)
+@@ -741,7 +735,8 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
+ if(result == CURLE_AGAIN) {
+ /* insufficient amount of data, keep it for later.
+ * we pretend to have written all since we have a copy */
+- return CURLE_OK;
++ result = CURLE_OK;
++ goto out;
+ }
+ else if(result) {
+ failf(data, "[WS] decode payload error %d", (int)result);
+@@ -752,10 +747,16 @@ static CURLcode ws_cw_write(struct Curl_easy *data,
+ if((type & CLIENTWRITE_EOS) && !Curl_bufq_is_empty(&ctx->buf)) {
+ failf(data, "[WS] decode ending with %zd frame bytes remaining",
+ Curl_bufq_len(&ctx->buf));
+- return CURLE_RECV_ERROR;
++ result = CURLE_RECV_ERROR;
+ }
+
+- return CURLE_OK;
++out:
++ if(!result) {
++ result = ws_flush(data, ws, Curl_is_in_callback(data));
++ if(result == CURLE_AGAIN)
++ result = CURLE_OK;
++ }
++ return result;
+ }
+
+ /* WebSocket payload decoding client writer. */
+@@ -1616,8 +1617,16 @@ CURLcode curl_ws_recv(CURL *d, void *buffer,
+ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws,
+ bool blocking)
+ {
++ CURLcode result;
++
++ /* If there is space, add any pending control frame */
++ if(Curl_bufq_len(&ws->sendbuf) < ws->sendbuf.chunk_size) {
++ result = ws_enc_add_pending(data, ws);
++ if(result && (result != CURLE_AGAIN))
++ return result;
++ }
++
+ if(!Curl_bufq_is_empty(&ws->sendbuf)) {
+- CURLcode result;
+ const uint8_t *out;
+ size_t outlen, n;
+ #ifdef DEBUGBUILD
+diff --git a/tests/http/test_20_websockets.py b/tests/http/test_20_websockets.py
+index 2612b0afe1..b935ed9d67 100644
+--- a/tests/http/test_20_websockets.py
++++ b/tests/http/test_20_websockets.py
+@@ -24,11 +24,15 @@
+ #
+ ###########################################################################
+ #
++import base64
++import hashlib
+ import logging
+ import os
++import re
+ import shutil
+ import socket
+ import subprocess
++import threading
+ import time
+ from datetime import datetime, timedelta
+ from typing import Dict
+@@ -207,3 +211,77 @@ class TestWebsockets:
+ large = 0
+ r = client.run(args=[f'-{model}', '-c', str(count), '-m', str(large), url])
+ r.check_exit_code(0)
++
++ def test_20_11_crazy_pings(self, env: Env):
++ st = {}
++ send_rounds = 1
++
++ def srv():
++ try:
++ with socket.socket() as s:
++ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
++ s.bind(("127.0.0.1", 0))
++ s.listen(1)
++ st["p"] = s.getsockname()[1]
++
++ c, _ = s.accept()
++ c.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 4096)
++ c.settimeout(Env.SERVER_TIMEOUT)
++ req = b""
++ while b"\r\n\r\n" not in req:
++ req += c.recv(4096)
++
++ k = re.search(rb"(?im)^Sec-WebSocket-Key:\s*(\S+)", req).group(1)
++ a = base64.b64encode(
++ hashlib.sha1(k + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest()
++ ).decode()
++ c.sendall(
++ (
++ "HTTP/1.1 101 Switching Protocols\r\n"
++ "Upgrade: websocket\r\n"
++ "Connection: Upgrade\r\n"
++ f"Sec-WebSocket-Accept: {a}\r\n\r\n"
++ ).encode()
++ )
++
++ f = b"\x89\x00" * 65536 # PING frames, many
++ try:
++ for _ in range(send_rounds):
++ c.sendall(f)
++ f = b"\x88\x00" # CLOSE frame
++ c.sendall(f)
++ except OSError:
++ pass
++ time.sleep(1)
++ c.close()
++ except OSError as e:
++ st["err"] = e
++
++ curl = CurlClient(env=env)
++ send_rounds = 2
++ threading.Thread(target=srv, daemon=True).start()
++ while "p" not in st and "err" not in st:
++ time.sleep(0.01)
++ assert "err" not in st, f'ws-ping server failed to start: {st["err"]}'
++
++ url = f'ws://127.0.0.1:{st["p"]}/'
++ r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
++ with_profile=True)
++ assert r.exit_code in [55, 56], f'{r.dump_logs()}' # SEND/RECV_ERROR
++ assert r.profile, f'{r}'
++ rss1 = r.profile.stats['rss'] / (1024 * 1024)
++
++ st.clear()
++ send_rounds = 10
++ threading.Thread(target=srv, daemon=True).start()
++ while "p" not in st and "err" not in st:
++ time.sleep(0.01)
++ assert "err" not in st, f'ws-ping server failed to start: {st["err"]}'
++
++ url = f'ws://127.0.0.1:{st["p"]}/'
++ r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
++ with_profile=True)
++ assert r.exit_code in [55, 56], f'{r.dump_logs()}' # SEND/RECV_ERROR
++ assert r.profile, f'{r}'
++ rss2 = r.profile.stats['rss'] / (1024 * 1024)
++ assert (rss1 * 1.1) >= rss2, 'bad memory increase'
diff --git a/0016-config2setopts-use-default-protocol-properly.patch b/0016-config2setopts-use-default-protocol-properly.patch
new file mode 100644
index 0000000..7fd861d
--- /dev/null
+++ b/0016-config2setopts-use-default-protocol-properly.patch
@@ -0,0 +1,255 @@
+From 576c0d70cffac3dcfb50529b53c3c957e4227969 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Fri, 12 Jun 2026 09:01:22 +0200
+Subject: [PATCH] config2setopts: use default protocol properly
+
+Verified by test 1724, 1725 and 2036
+
+Closes #21983
+
+(cherry picked from commit ab3bb8cd8be8f9d4acb97da0418abc279182041e)
+---
+ docs/cmdline-opts/proto-default.md | 6 +++-
+ src/config2setopts.c | 51 +++++++++++++++++-----------
+ tests/data/Makefile.am | 3 +-
+ tests/data/test1724 | 53 ++++++++++++++++++++++++++++++
+ tests/data/test1725 | 29 ++++++++++++++++
+ tests/data/test2036 | 26 +++++++++++++++
+ 6 files changed, 146 insertions(+), 22 deletions(-)
+ create mode 100644 tests/data/test1724
+ create mode 100644 tests/data/test1725
+ create mode 100644 tests/data/test2036
+
+diff --git a/docs/cmdline-opts/proto-default.md b/docs/cmdline-opts/proto-default.md
+index 209e5cdc83..903fac73a5 100644
+--- a/docs/cmdline-opts/proto-default.md
++++ b/docs/cmdline-opts/proto-default.md
+@@ -16,7 +16,8 @@ Example:
+
+ # `--proto-default`
+
+-Use *protocol* for any provided URL missing a scheme.
++Use *protocol* for any provided URL missing a scheme. The case-insensitive
++name should be given without any `://` suffix.
+
+ An unknown or unsupported protocol causes error *CURLE_UNSUPPORTED_PROTOCOL*.
+
+@@ -24,3 +25,6 @@ This option does not change the default proxy protocol (http).
+
+ Without this option set, curl guesses protocol based on the hostname, see
+ --url for details.
++
++The default protocol cannot be set to `ipfs` or `ipns`. Those schemes need to
++be used explicitly in the URL.
+diff --git a/src/config2setopts.c b/src/config2setopts.c
+index d462e8cd54..a69f3adb20 100644
+--- a/src/config2setopts.c
++++ b/src/config2setopts.c
+@@ -143,29 +143,40 @@ static CURLcode url_proto_and_rewrite(char **url,
+ curl_url_set(uh, CURLUPART_URL, *url,
+ CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME);
+ if(!uc) {
+- uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, CURLU_DEFAULT_SCHEME);
+- if(!uc) {
+-#ifdef CURL_DISABLE_IPFS
+- (void)config;
+-#else
+- if(curl_strequal(schemep, proto_ipfs) ||
+- curl_strequal(schemep, proto_ipns)) {
+- result = ipfs_url_rewrite(uh, schemep, url, config);
+- /* short-circuit proto_token, we know it is ipfs or ipns */
+- if(curl_strequal(schemep, proto_ipfs))
+- proto = proto_ipfs;
+- else if(curl_strequal(schemep, proto_ipns))
+- proto = proto_ipns;
+- if(result)
+- config->synthetic_error = TRUE;
++ if(config->proto_default) {
++ /* when a default proto is requested, do not guess */
++ uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep,
++ CURLU_NO_GUESS_SCHEME);
++ if(uc == CURLUE_NO_SCHEME) {
++ /* use the default */
++ proto = proto_token(config->proto_default);
++ if(proto)
++ uc = CURLUE_OK;
+ }
+- else
+-#endif /* !CURL_DISABLE_IPFS */
+- proto = proto_token(schemep);
+- curl_free(schemep);
+ }
+- else if(uc == CURLUE_OUT_OF_MEMORY)
++ else {
++ uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep,
++ CURLU_DEFAULT_SCHEME);
++ }
++ if(schemep)
++ proto = proto_token(schemep);
++#ifndef CURL_DISABLE_IPFS
++ if(!uc &&
++ (curl_strequal(schemep, proto_ipfs) ||
++ curl_strequal(schemep, proto_ipns))) {
++ result = ipfs_url_rewrite(uh, schemep, url, config);
++ /* short-circuit proto_token, we know it is ipfs or ipns */
++ if(curl_strequal(schemep, proto_ipfs))
++ proto = proto_ipfs;
++ else if(curl_strequal(schemep, proto_ipns))
++ proto = proto_ipns;
++ if(result)
++ config->synthetic_error = TRUE;
++ }
++#endif /* !CURL_DISABLE_IPFS */
++ if(uc == CURLUE_OUT_OF_MEMORY)
+ result = CURLE_OUT_OF_MEMORY;
++ curl_free(schemep);
+ }
+ else if(uc == CURLUE_OUT_OF_MEMORY)
+ result = CURLE_OUT_OF_MEMORY;
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index b050f708eb..57e7508751 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -230,6 +230,7 @@ test1680 test1681 test1682 test1683 test1686 \
+ \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 test1711 \
++test1724 test1725 \
+ \
+ test1800 test1801 test1802 test1850 \
+ \
+@@ -247,7 +248,7 @@ test2000 test2001 test2002 test2003 test2004 test2005 test2006 \
+ \
+ test2023 \
+ test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
+-test2032 test2033 test2034 test2035 test2037 test2038 test2039 \
++test2032 test2033 test2034 test2035 test2036 test2037 test2038 test2039 \
+ test2040 test2041 test2042 test2043 test2044 test2045 test2046 test2047 \
+ test2048 test2049 test2050 test2051 test2052 test2053 test2054 test2055 \
+ test2056 test2057 test2058 test2059 test2060 test2061 test2062 test2063 \
+diff --git a/tests/data/test1724 b/tests/data/test1724
+new file mode 100644
+index 0000000000..3cd328e39c
+--- /dev/null
++++ b/tests/data/test1724
+@@ -0,0 +1,53 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++IPFS
++</keywords>
++</info>
++
++# Server-side
++<reply>
++<data nocheck="yes">
++HTTP/1.1 200 OK
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: test-server/fake
++Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
++ETag: "21025-dc7-39462498"
++Accept-Ranges: bytes
++Content-Length: 21
++Connection: close
++Content-Type: text/plain
++Funny-head: yesyes
++
++Hello curl from IPFS
++</data>
++</reply>
++
++# Client-side
++<client>
++<features>
++ipfs
++</features>
++<server>
++http
++</server>
++<name>
++IPFS with --proto-default HTTP
++</name>
++<command>
++--ipfs-gateway http://%HOSTIP:%HTTPPORT ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u --proto-default http
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET /ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++</protocol>
++</verify>
++</testcase>
+diff --git a/tests/data/test1725 b/tests/data/test1725
+new file mode 100644
+index 0000000000..2a882c791d
+--- /dev/null
++++ b/tests/data/test1725
+@@ -0,0 +1,29 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++SCP
++server key check
++</keywords>
++</info>
++
++# Client-side
++<client>
++<server>
++scp
++</server>
++<name>
++SCP incorrect host key with --proto-default SCP
++</name>
++<command>
++--hostpubmd5 00000000000000000000000000000000 --key %LOGDIR/server/curl_client_key --pubkey %LOGDIR/server/curl_client_key.pub -u %USER: %HOSTIP:%SSHPORT%SCP_PWD/%LOGDIR/irrelevant-file --insecure --proto-default SCP
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<errorcode>
++60
++</errorcode>
++</verify>
++</testcase>
+diff --git a/tests/data/test2036 b/tests/data/test2036
+new file mode 100644
+index 0000000000..b017a71abc
+--- /dev/null
++++ b/tests/data/test2036
+@@ -0,0 +1,26 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++--proto-default
++</keywords>
++</info>
++
++# Client-side
++<client>
++<name>
++Attempt to set a default protocol with :// suffix
++</name>
++<command>
++--proto-default https://
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++# CURLE_UNSUPPORTED_PROTOCOL is error code 1
++<errorcode>
++1
++</errorcode>
++</verify>
++</testcase>
diff --git a/0016-curl-8.18.0-CVE-2026-8286.patch b/0016-curl-8.18.0-CVE-2026-8286.patch
deleted file mode 100644
index 2eb0bc9..0000000
--- a/0016-curl-8.18.0-CVE-2026-8286.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 923ac48aa01d59577211d3fa617acb5a150685ba Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Tue, 24 Mar 2026 08:35:08 +0100
-Subject: [PATCH] CVE-2026-8286
-
-url: do not reuse a non-tls starttls connection if new requires TLS
-
-Reported-by: Arkadi Vainbrand
-
-Closes #21082
-
-(cherry picked from commit 507e7be573b0a76fca597b75ff7cb27a66e7d865)
-
-url: fix connection reuse for starttls protocols
-
-When a connection is tested for reuse in a transfer that *may* upgrade
-to TLS (commonly via STARTTLS), the SSL configuration must match the
-existing connection.
-
-Reported-by: Andrew Nesbit
-Closes #21522
-
-(cherry picked from commit a86efdd7ca5433de9231e650f18247de8319ad16)
----
- lib/url.c | 15 ++++++++++++---
- 1 file changed, 12 insertions(+), 3 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index 5a75fe71da..603fec68b6 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -746,7 +746,11 @@ struct url_conn_match {
- BIT(want_proxy_ntlm_http);
- BIT(want_nego_http);
- BIT(want_proxy_nego_http);
--
-+ BIT(may_tls); /* May upgrade clear-text connection to TLS, can only reuse
-+ * connections that have matching TLS configuration.
-+ * Always TRUE if `req_tls` is TRUE. */
-+ BIT(require_tls); /* Requires TLS use from a clear-text start, can only
-+ * reuse connections that have TLS. */
- BIT(wait_pipe);
- BIT(force_reuse);
- BIT(seen_pending_conn);
-@@ -898,6 +902,9 @@ static bool url_match_ssl_use(struct connectdata *conn,
- (get_protocol_family(conn->handler) != m->needle->handler->protocol))
- return FALSE;
- }
-+ else if(m->require_tls)
-+ /* a clear-text STARTTLS protocol with required TLS */
-+ return FALSE;
- return TRUE;
- }
-
-@@ -1088,8 +1095,8 @@ static bool url_match_destination(struct connectdata *conn,
- static bool url_match_ssl_config(struct connectdata *conn,
- struct url_conn_match *m)
- {
-- /* If talking TLS, conn needs to use the same SSL options. */
-- if((m->needle->handler->flags & PROTOPT_SSL) &&
-+ /* If talking/upgrading to TLS, conn needs to use the same SSL options. */
-+ if(((m->needle->handler->flags & PROTOPT_SSL) || m->may_tls) &&
- !Curl_ssl_conn_config_match(m->data, conn, FALSE)) {
- DEBUGF(infof(m->data,
- "Connection #%" FMT_OFF_T
-@@ -1360,6 +1367,8 @@ static bool ConnectionExists(struct Curl_easy *data,
- (needle->handler->protocol & PROTO_FAMILY_HTTP);
- #endif
- #endif
-+ match.require_tls = data->set.use_ssl >= CURLUSESSL_CONTROL;
-+ match.may_tls = data->set.use_ssl > CURLUSESSL_NONE;
-
- /* Find a connection in the pool that matches what "data + needle"
- * requires. If a suitable candidate is found, it is attached to "data". */
---
-2.55.0
-
diff --git a/0017-CVE-2026-8286.patch b/0017-CVE-2026-8286.patch
new file mode 100644
index 0000000..81df6bf
--- /dev/null
+++ b/0017-CVE-2026-8286.patch
@@ -0,0 +1,74 @@
+From 41f78e1a31ea961c6ed4b3c25a598dda15481637 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 24 Mar 2026 08:35:08 +0100
+Subject: [PATCH] CVE-2026-8286
+
+url: do not reuse a non-tls starttls connection if new requires TLS
+
+Reported-by: Arkadi Vainbrand
+
+Closes #21082
+
+(cherry picked from commit 507e7be573b0a76fca597b75ff7cb27a66e7d865)
+
+url: fix connection reuse for starttls protocols
+
+When a connection is tested for reuse in a transfer that *may* upgrade
+to TLS (commonly via STARTTLS), the SSL configuration must match the
+existing connection.
+
+Reported-by: Andrew Nesbit
+Closes #21522
+
+(cherry picked from commit a86efdd7ca5433de9231e650f18247de8319ad16)
+---
+ lib/url.c | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 5a75fe71da..603fec68b6 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -746,7 +746,11 @@ struct url_conn_match {
+ BIT(want_proxy_ntlm_http);
+ BIT(want_nego_http);
+ BIT(want_proxy_nego_http);
+-
++ BIT(may_tls); /* May upgrade clear-text connection to TLS, can only reuse
++ * connections that have matching TLS configuration.
++ * Always TRUE if `req_tls` is TRUE. */
++ BIT(require_tls); /* Requires TLS use from a clear-text start, can only
++ * reuse connections that have TLS. */
+ BIT(wait_pipe);
+ BIT(force_reuse);
+ BIT(seen_pending_conn);
+@@ -898,6 +902,9 @@ static bool url_match_ssl_use(struct connectdata *conn,
+ (get_protocol_family(conn->handler) != m->needle->handler->protocol))
+ return FALSE;
+ }
++ else if(m->require_tls)
++ /* a clear-text STARTTLS protocol with required TLS */
++ return FALSE;
+ return TRUE;
+ }
+
+@@ -1088,8 +1095,8 @@ static bool url_match_destination(struct connectdata *conn,
+ static bool url_match_ssl_config(struct connectdata *conn,
+ struct url_conn_match *m)
+ {
+- /* If talking TLS, conn needs to use the same SSL options. */
+- if((m->needle->handler->flags & PROTOPT_SSL) &&
++ /* If talking/upgrading to TLS, conn needs to use the same SSL options. */
++ if(((m->needle->handler->flags & PROTOPT_SSL) || m->may_tls) &&
+ !Curl_ssl_conn_config_match(m->data, conn, FALSE)) {
+ DEBUGF(infof(m->data,
+ "Connection #%" FMT_OFF_T
+@@ -1360,6 +1367,8 @@ static bool ConnectionExists(struct Curl_easy *data,
+ (needle->handler->protocol & PROTO_FAMILY_HTTP);
+ #endif
+ #endif
++ match.require_tls = data->set.use_ssl >= CURLUSESSL_CONTROL;
++ match.may_tls = data->set.use_ssl > CURLUSESSL_NONE;
+
+ /* Find a connection in the pool that matches what "data + needle"
+ * requires. If a suitable candidate is found, it is attached to "data". */
diff --git a/0017-curl-8.18.0-CVE-2026-8925.patch b/0017-curl-8.18.0-CVE-2026-8925.patch
deleted file mode 100644
index 4ec1b83..0000000
--- a/0017-curl-8.18.0-CVE-2026-8925.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From c3b833dc0daba1ee9c398410821849815594fb84 Mon Sep 17 00:00:00 2001
-From: Viktor Szakats <commit@vsz.me>
-Date: Thu, 14 May 2026 14:35:21 +0200
-Subject: [PATCH] gsasl: fix potential double free
-
-Also:
-- require libgsasl 1.6.0+ (2010-12-14) for a `gsasl_finish()` that
- handles a NULL argument.
- Ref: https://gitlab.com/gsasl/gsasl/-/commit/b550032df8488a9ceaa3cfd4c634947d8f219717
-
-Reported-by: Joshua Rogers (Aisle Research)
-
-Closes #21609
-
-(cherry picked from commit 3da249e1f0716c06644ed3522a37a8bf81808012)
----
- docs/INTERNALS.md | 1 +
- lib/vauth/gsasl.c | 5 +++++
- 2 files changed, 6 insertions(+)
-
-diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md
-index 222d9ab5ed..9ddb4ef8ba 100644
---- a/docs/INTERNALS.md
-+++ b/docs/INTERNALS.md
-@@ -28,6 +28,7 @@ versions of libs and build tools.
- - c-ares 1.6.0 (2008-12-09)
- - GnuTLS 3.6.5 (2018-12-01)
- - libidn2 2.0.0 (2017-03-29)
-+ - libgsasl 1.6.0 (2010-12-14)
- - LibreSSL 2.9.1 (2019-04-22)
- - libssh 0.9.0 (2019-06-28)
- - libssh2 1.9.0 (2019-06-20)
-diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c
-index b95d6e3f0a..60f1c56c2c 100644
---- a/lib/vauth/gsasl.c
-+++ b/lib/vauth/gsasl.c
-@@ -32,6 +32,10 @@
-
- #include <gsasl.h>
-
-+#if GSASL_VERSION_NUMBER < 0x010600
-+#error "requires libgsasl 1.6.0+"
-+#endif
-+
- bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
- const char *mech,
- struct gsasldata *gsasl)
-@@ -47,6 +51,7 @@ bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
- res = gsasl_client_start(gsasl->ctx, mech, &gsasl->client);
- if(res != GSASL_OK) {
- gsasl_done(gsasl->ctx);
-+ gsasl->ctx = NULL;
- return FALSE;
- }
-
---
-2.55.0
-
diff --git a/0018-curl-8.18.0-CVE-2026-8927.patch b/0018-curl-8.18.0-CVE-2026-8927.patch
deleted file mode 100644
index fb9e5c8..0000000
--- a/0018-curl-8.18.0-CVE-2026-8927.patch
+++ /dev/null
@@ -1,337 +0,0 @@
-From 0c19379d6c470c2dda708d70bc68a0ed80757737 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 18 May 2026 23:47:11 +0200
-Subject: [PATCH] url: detect proxy changes read from environment
-
-When a proxy is set from an environment variable, detect if that proxy
-is not the same as previously and flush state.
-
-Verified by test1647: verify changing proxy with env variables and make
-sure Digest state is flushed in the second use
-
-Closes #21666
-
-(cherry picked from commit 5c225384b8d52c67ce8259c6e4203bc57aacb567)
----
- lib/url.c | 11 ++++
- lib/urldata.h | 1 +
- tests/data/Makefile.am | 2 +
- tests/data/test1647 | 103 +++++++++++++++++++++++++++++++
- tests/libtest/Makefile.inc | 1 +
- tests/libtest/lib1647.c | 120 +++++++++++++++++++++++++++++++++++++
- 6 files changed, 238 insertions(+)
- create mode 100644 tests/data/test1647
- create mode 100644 tests/libtest/lib1647.c
-
-diff --git a/lib/url.c b/lib/url.c
-index 603fec68b6..033e65369a 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -80,6 +80,7 @@
- #include "escape.h"
- #include "curl_share.h"
- #include "http_digest.h"
-+#include "vauth/vauth.h"
- #include "multiif.h"
- #include "getinfo.h"
- #include "pop3.h"
-@@ -323,6 +324,9 @@ CURLcode Curl_close(struct Curl_easy **datap)
- Curl_freeset(data);
- Curl_headers_cleanup(data);
- Curl_netrc_cleanup(&data->state.netrc);
-+#ifndef CURL_DISABLE_DIGEST_AUTH
-+ curlx_free(data->state.envproxy);
-+#endif
- curlx_free(data);
- return CURLE_OK;
- }
-@@ -2532,6 +2536,14 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
- result = CURLE_UNSUPPORTED_PROTOCOL;
- goto out;
- #else
-+#ifndef CURL_DISABLE_DIGEST_AUTH
-+ if(!Curl_safecmp(data->state.envproxy, proxy)) {
-+ /* proxy changed */
-+ Curl_auth_digest_cleanup(&data->state.proxydigest);
-+ curlx_free(data->state.envproxy);
-+ data->state.envproxy = curlx_strdup(proxy);
-+ }
-+#endif
- /* force this connection's protocol to become HTTP if compatible */
- if(!(conn->handler->protocol & PROTO_FAMILY_HTTP)) {
- if((conn->handler->flags & PROTOPT_PROXY_AS_HTTP) &&
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 221317e47e..1de8c4bfb1 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -967,6 +967,7 @@ struct UrlState {
- void (*prev_signal)(int sig);
- #endif
- #ifndef CURL_DISABLE_DIGEST_AUTH
-+ char *envproxy; /* last proxy string used for proxy-related state */
- struct digestdata digest; /* state data for host Digest auth */
- struct digestdata proxydigest; /* state data for proxy Digest auth */
- #endif
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 57e7508751..2a1c87ddc3 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -212,6 +212,8 @@ test1580 test1581 test1582 test1583 test1584 test1585 \
- test1588 \
- test1629 \
- \
-+test1647 \
-+\
- test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
- test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
- test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
-diff --git a/tests/data/test1647 b/tests/data/test1647
-new file mode 100644
-index 0000000000..a87487fa9f
---- /dev/null
-+++ b/tests/data/test1647
-@@ -0,0 +1,103 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+HTTP GET
-+HTTP proxy
-+HTTP proxy Digest auth
-+multi
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+
-+# this is returned first since we get no proxy-auth
-+<data crlf="headers" nocheck="yes">
-+HTTP/1.1 407 Authorization Required to proxy me my dear
-+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
-+Content-Length: 33
-+
-+And you should ignore this data.
-+</data>
-+
-+# then this is returned when we get proxy-auth
-+<data1000 crlf="headers">
-+HTTP/1.1 200 OK
-+Content-Length: 21
-+Server: no
-+
-+Nice proxy auth sir!
-+</data1000>
-+
-+<connect crlf="headers">
-+HTTP/1.1 401 OK
-+Content-Length: 21
-+Server: no
-+
-+Denied access. Leave
-+</connect>
-+
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+https-proxy
-+https
-+</server>
-+# tool is what to use instead of 'curl'
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<features>
-+!SSPI
-+crypto
-+proxy
-+digest
-+Debug
-+</features>
-+<setenv>
-+http_proxy=%HOSTIP:%HTTPPORT
-+https_proxy=https://%HOSTIP:%HTTPSPROXYPORT
-+CURL_ENTROPY=99376
-+</setenv>
-+<name>
-+HTTP proxy auth Digest, then change proxy with env var and do it again
-+</name>
-+<command>
-+http://test.remote.example.com/path/%TESTNUMBER https://another.example.com:%HTTPSPORT/ daniel:monkey123 another:bump456
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
-+Host: test.remote.example.com
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
-+Host: test.remote.example.com
-+Proxy-Authorization: Digest username="daniel", realm="weirdorealm", nonce="12345", uri="/path/%TESTNUMBER", response="7a1672891aff03248887b1a6674b8096"
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+</protocol>
-+
-+<proxy crlf="headers">
-+CONNECT another.example.com:%HTTPSPORT HTTP/1.1
-+Host: another.example.com:%HTTPSPORT
-+Proxy-Connection: Keep-Alive
-+
-+</proxy>
-+
-+# CONNECT fails
-+<errorcode>
-+7
-+</errorcode>
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index 76014f926a..0f8a2ea506 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -100,6 +100,7 @@ TESTS_C = \
- lib1582.c lib1588.c \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
-+ lib1647.c \
- lib1662.c \
- lib1686.c \
- lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
-diff --git a/tests/libtest/lib1647.c b/tests/libtest/lib1647.c
-new file mode 100644
-index 0000000000..8060e1bfe9
---- /dev/null
-+++ b/tests/libtest/lib1647.c
-@@ -0,0 +1,120 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+/*
-+ * argv1 = the first URL
-+ * argv2 = URL2
-+ * argv3 = credentials 1
-+ * argv4 = credentials 2
-+ */
-+
-+#include "first.h"
-+
-+/* this is meant to pick up the proxy from the environment variable */
-+static CURLcode init1647(CURL *curl, const char *url, const char *userpwd)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 0L);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 0L);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(result)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return result; /* failure */
-+}
-+
-+static CURLcode run1647(CURL *curl, const char *url, const char *userpwd)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ result = init1647(curl, url, userpwd);
-+ if(result)
-+ return result;
-+
-+ return curl_easy_perform(curl);
-+}
-+
-+static CURLcode test_lib1647(const char *URL)
-+{
-+ CURLcode result = CURLE_OK;
-+ CURL *curl = NULL;
-+
-+ res_global_init(CURL_GLOBAL_ALL);
-+ if(result)
-+ return result;
-+
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
-+ curl_global_cleanup();
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ start_test_timing();
-+
-+ curl_mprintf("--- First get '%s'\n", URL);
-+ result = run1647(curl, URL, libtest_arg3);
-+ if(result)
-+ goto test_cleanup;
-+
-+ curl_mprintf("--- Then get '%s'\n", libtest_arg2);
-+ result = run1647(curl, libtest_arg2, libtest_arg4);
-+
-+test_cleanup:
-+
-+ /* proper cleanup sequence - type PB */
-+
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ return result;
-+}
---
-2.55.0
-
diff --git a/0018-gsasl-fix-potential-double-free.patch b/0018-gsasl-fix-potential-double-free.patch
new file mode 100644
index 0000000..708ea44
--- /dev/null
+++ b/0018-gsasl-fix-potential-double-free.patch
@@ -0,0 +1,55 @@
+From 4948b543e6e3c58d7626e09e4f72a32ea8036439 Mon Sep 17 00:00:00 2001
+From: Viktor Szakats <commit@vsz.me>
+Date: Thu, 14 May 2026 14:35:21 +0200
+Subject: [PATCH] gsasl: fix potential double free
+
+Also:
+- require libgsasl 1.6.0+ (2010-12-14) for a `gsasl_finish()` that
+ handles a NULL argument.
+ Ref: https://gitlab.com/gsasl/gsasl/-/commit/b550032df8488a9ceaa3cfd4c634947d8f219717
+
+Reported-by: Joshua Rogers (Aisle Research)
+
+Closes #21609
+
+(cherry picked from commit 3da249e1f0716c06644ed3522a37a8bf81808012)
+---
+ docs/INTERNALS.md | 1 +
+ lib/vauth/gsasl.c | 5 +++++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md
+index 222d9ab5ed..9ddb4ef8ba 100644
+--- a/docs/INTERNALS.md
++++ b/docs/INTERNALS.md
+@@ -28,6 +28,7 @@ versions of libs and build tools.
+ - c-ares 1.6.0 (2008-12-09)
+ - GnuTLS 3.6.5 (2018-12-01)
+ - libidn2 2.0.0 (2017-03-29)
++ - libgsasl 1.6.0 (2010-12-14)
+ - LibreSSL 2.9.1 (2019-04-22)
+ - libssh 0.9.0 (2019-06-28)
+ - libssh2 1.9.0 (2019-06-20)
+diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c
+index b95d6e3f0a..60f1c56c2c 100644
+--- a/lib/vauth/gsasl.c
++++ b/lib/vauth/gsasl.c
+@@ -32,6 +32,10 @@
+
+ #include <gsasl.h>
+
++#if GSASL_VERSION_NUMBER < 0x010600
++#error "requires libgsasl 1.6.0+"
++#endif
++
+ bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
+ const char *mech,
+ struct gsasldata *gsasl)
+@@ -47,6 +51,7 @@ bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
+ res = gsasl_client_start(gsasl->ctx, mech, &gsasl->client);
+ if(res != GSASL_OK) {
+ gsasl_done(gsasl->ctx);
++ gsasl->ctx = NULL;
+ return FALSE;
+ }
+
diff --git a/0019-curl-8.18.0-CVE-2026-9546.patch b/0019-curl-8.18.0-CVE-2026-9546.patch
deleted file mode 100644
index 33d4b72..0000000
--- a/0019-curl-8.18.0-CVE-2026-9546.patch
+++ /dev/null
@@ -1,418 +0,0 @@
-From 64a79efd7cc2f06804b47947edafa69d21ab1fdd Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Wed, 15 Apr 2026 08:11:33 +0200
-Subject: [PATCH] CVE-2026-9546
-
-transfer: clear the old autoreferer
-
-Verify in test 2505
-
-Closes #21322
-
-(cherry picked from commit fa057ea3dedb04f93672ec95ee964f1f02ec0ecf)
-
-transfer: clear referer when set to NULL
-
-Verify in test 1649
-
-Closes #21741
-
-(cherry picked from commit 862e8a74a84478d82973471b4f49dc2746c1780e)
----
- lib/setopt.c | 1 -
- lib/transfer.c | 7 +++
- tests/data/Makefile.am | 3 +-
- tests/data/test1649 | 55 +++++++++++++++++++++++
- tests/data/test2505 | 67 ++++++++++++++++++++++++++++
- tests/libtest/Makefile.inc | 4 +-
- tests/libtest/lib1649.c | 90 ++++++++++++++++++++++++++++++++++++++
- tests/libtest/lib2505.c | 71 ++++++++++++++++++++++++++++++
- 8 files changed, 294 insertions(+), 4 deletions(-)
- create mode 100644 tests/data/test1649
- create mode 100644 tests/data/test2505
- create mode 100644 tests/libtest/lib1649.c
- create mode 100644 tests/libtest/lib2505.c
-
-diff --git a/lib/setopt.c b/lib/setopt.c
-index 65c573cb9d..a74ca5e8f3 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -1770,7 +1770,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
- * String to set in the HTTP Referer: field.
- */
- result = Curl_setstropt(&s->str[STRING_SET_REFERER], ptr);
-- Curl_bufref_set(&data->state.referer, s->str[STRING_SET_REFERER], 0, NULL);
- break;
-
- case CURLOPT_USERAGENT:
-diff --git a/lib/transfer.c b/lib/transfer.c
-index fed6a1786e..8050f8a7b1 100644
---- a/lib/transfer.c
-+++ b/lib/transfer.c
-@@ -503,6 +503,13 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
- data->state.authproxy.want = data->set.proxyauth;
- Curl_safefree(data->info.wouldredirect);
- Curl_data_priority_clear_state(data);
-+ if(data->set.http_auto_referer)
-+ Curl_bufref_free(&data->state.referer);
-+ if(data->set.str[STRING_SET_REFERER])
-+ Curl_bufref_set(&data->state.referer, data->set.str[STRING_SET_REFERER],
-+ 0, NULL);
-+ else
-+ Curl_bufref_free(&data->state.referer);
-
- if(data->state.httpreq == HTTPREQ_PUT)
- data->state.infilesize = data->set.filesize;
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 2a1c87ddc3..e326ff7eff 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -221,6 +221,7 @@ test1614 test1615 test1616 test1617 \
- test1620 test1621 test1622 \
- \
- test1630 test1631 test1632 test1633 test1634 test1635 test1636 \
-+test1649 \
- \
- test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
- test1658 \
-@@ -267,7 +268,7 @@ test2309 \
- \
- test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
- \
--test2500 test2501 test2502 test2503 \
-+test2500 test2501 test2502 test2503 test2505 \
- \
- test2600 test2601 test2602 test2603 test2604 test2605 \
- \
-diff --git a/tests/data/test1649 b/tests/data/test1649
-new file mode 100644
-index 0000000000..d2fd7799bd
---- /dev/null
-+++ b/tests/data/test1649
-@@ -0,0 +1,55 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+Referer
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+
-+# this is returned first since we get no proxy-auth
-+<data crlf="headers" nocheck="yes">
-+HTTP/1.1 200 OK
-+Content-Length: 6
-+
-+hello
-+</data>
-+
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<name>
-+Set referer first then NULL it
-+</name>
-+<command>
-+http://%HOSTIP:%HTTPPORT
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET / HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+Accept: */*
-+Referer: https://secret.example.com/
-+
-+GET / HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+Accept: */*
-+
-+</protocol>
-+
-+</verify>
-+</testcase>
-diff --git a/tests/data/test2505 b/tests/data/test2505
-new file mode 100644
-index 0000000000..8fac590b37
---- /dev/null
-+++ b/tests/data/test2505
-@@ -0,0 +1,67 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+referer
-+autoreferer
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+<data crlf="headers" nocheck="yes">
-+HTTP/1.1 301 redirect
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: server.example.com
-+Content-Length: 47
-+Location: %TESTNUMBER0002
-+
-+file contents should appear once for each file
-+</data>
-+
-+<data2 crlf="headers" nocheck="yes">
-+HTTP/1.1 200 OK
-+Date: Tue, 09 Nov 2010 14:49:00 GMT
-+Server: server.example.com
-+Content-Length: 47
-+
-+file contents should appear once for each file
-+</data2>
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<name>
-+verify CURLOPT_AUTOREFERER switched off
-+</name>
-+<command>
-+http://%HOSTIP:%HTTPPORT
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET / HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+Accept: */*
-+
-+GET /%TESTNUMBER0002 HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+Accept: */*
-+Referer: http://%HOSTIP:%HTTPPORT/
-+
-+GET / HTTP/1.1
-+Host: %HOSTIP:%HTTPPORT
-+Accept: */*
-+
-+</protocol>
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index 0f8a2ea506..82740ef1b0 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -100,7 +100,7 @@ TESTS_C = \
- lib1582.c lib1588.c \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
-- lib1647.c \
-+ lib1647.c lib1649.c \
- lib1662.c \
- lib1686.c \
- lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
-@@ -115,7 +115,7 @@ TESTS_C = \
- lib2023.c lib2032.c lib2082.c \
- lib2301.c lib2302.c lib2304.c lib2306.c lib2308.c lib2309.c \
- lib2402.c lib2404.c lib2405.c \
-- lib2502.c \
-+ lib2502.c lib2505.c \
- lib2700.c \
- lib3010.c lib3025.c lib3026.c lib3027.c lib3033.c lib3034.c \
- lib3100.c lib3101.c lib3102.c lib3103.c lib3104.c lib3105.c \
-diff --git a/tests/libtest/lib1649.c b/tests/libtest/lib1649.c
-new file mode 100644
-index 0000000000..2dd66c0231
---- /dev/null
-+++ b/tests/libtest/lib1649.c
-@@ -0,0 +1,90 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+
-+#include "first.h"
-+
-+/* this is meant to pick up the proxy from the environment variable */
-+static CURLcode init1649(CURL *curl, const char *url)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(result)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return result; /* failure */
-+}
-+
-+static CURLcode run1649(CURL *curl, const char *url)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ result = init1649(curl, url);
-+ if(result)
-+ return result;
-+
-+ return curl_easy_perform(curl);
-+}
-+
-+static CURLcode test_lib1649(const char *URL)
-+{
-+ CURLcode result = CURLE_OK;
-+ CURL *curl = NULL;
-+
-+ res_global_init(CURL_GLOBAL_ALL);
-+ if(result)
-+ return result;
-+
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
-+ curl_global_cleanup();
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ start_test_timing();
-+
-+ easy_setopt(curl, CURLOPT_REFERER, "https://secret.example.com/");
-+
-+ result = run1649(curl, URL);
-+ if(result)
-+ goto test_cleanup;
-+
-+ /* reset it */
-+ easy_setopt(curl, CURLOPT_REFERER, NULL);
-+
-+ result = run1649(curl, URL);
-+
-+test_cleanup:
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ return result;
-+}
-diff --git a/tests/libtest/lib2505.c b/tests/libtest/lib2505.c
-new file mode 100644
-index 0000000000..c170259874
---- /dev/null
-+++ b/tests/libtest/lib2505.c
-@@ -0,0 +1,71 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Linus Nielsen Feltzing <linus@haxx.se>
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+#include "first.h"
-+
-+#include "testtrace.h"
-+
-+static size_t sink2505(char *ptr, size_t size, size_t nmemb, void *ud)
-+{
-+ (void)ptr;
-+ (void)ud;
-+ return size * nmemb;
-+}
-+
-+static CURLcode test_lib2505(const char *URL)
-+{
-+ CURL *curl;
-+ CURLcode result = CURLE_OUT_OF_MEMORY;
-+
-+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
-+ curl_mfprintf(stderr, "curl_global_init() failed\n");
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
-+ curl_global_cleanup();
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ test_setopt(curl, CURLOPT_WRITEFUNCTION, sink2505);
-+ test_setopt(curl, CURLOPT_AUTOREFERER, 1L);
-+ test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-+ test_setopt(curl, CURLOPT_URL, URL);
-+
-+ result = curl_easy_perform(curl);
-+ curl_mprintf("req1=%d\n", (int)result);
-+
-+ test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
-+ test_setopt(curl, CURLOPT_URL, URL);
-+
-+ result = curl_easy_perform(curl);
-+ curl_mprintf("req2=%d\n", (int)result);
-+
-+test_cleanup:
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+
-+ return result;
-+}
---
-2.55.0
-
diff --git a/0019-url-detect-proxy-changes-read-from-environment.patch b/0019-url-detect-proxy-changes-read-from-environment.patch
new file mode 100644
index 0000000..b2a964f
--- /dev/null
+++ b/0019-url-detect-proxy-changes-read-from-environment.patch
@@ -0,0 +1,334 @@
+From 8e190f64c8040e1ee189db7a4d60a1a8994a461c Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 18 May 2026 23:47:11 +0200
+Subject: [PATCH] url: detect proxy changes read from environment
+
+When a proxy is set from an environment variable, detect if that proxy
+is not the same as previously and flush state.
+
+Verified by test1647: verify changing proxy with env variables and make
+sure Digest state is flushed in the second use
+
+Closes #21666
+
+(cherry picked from commit 5c225384b8d52c67ce8259c6e4203bc57aacb567)
+---
+ lib/url.c | 12 ++++
+ lib/urldata.h | 1 +
+ tests/data/Makefile.am | 2 +
+ tests/data/test1647 | 103 +++++++++++++++++++++++++++++++
+ tests/libtest/Makefile.inc | 1 +
+ tests/libtest/lib1647.c | 120 +++++++++++++++++++++++++++++++++++++
+ 6 files changed, 239 insertions(+)
+ create mode 100644 tests/data/test1647
+ create mode 100644 tests/libtest/lib1647.c
+
+diff --git a/lib/url.c b/lib/url.c
+index 603fec68b6..fefc1a0518 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -80,6 +80,7 @@
+ #include "escape.h"
+ #include "curl_share.h"
+ #include "http_digest.h"
++#include "vauth/vauth.h"
+ #include "multiif.h"
+ #include "getinfo.h"
+ #include "pop3.h"
+@@ -323,6 +324,9 @@ CURLcode Curl_close(struct Curl_easy **datap)
+ Curl_freeset(data);
+ Curl_headers_cleanup(data);
+ Curl_netrc_cleanup(&data->state.netrc);
++#ifndef CURL_DISABLE_DIGEST_AUTH
++ curlx_free(data->state.envproxy);
++#endif
+ curlx_free(data);
+ return CURLE_OK;
+ }
+@@ -2532,6 +2536,14 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data,
+ result = CURLE_UNSUPPORTED_PROTOCOL;
+ goto out;
+ #else
++#ifndef CURL_DISABLE_DIGEST_AUTH
++ if(!Curl_safecmp(data->state.envproxy, proxy)) {
++ /* proxy changed */
++ Curl_auth_digest_cleanup(&data->state.proxydigest);
++ curlx_free(data->state.envproxy);
++ data->state.envproxy = curlx_strdup(proxy);
++ }
++#endif
+ /* force this connection's protocol to become HTTP if compatible */
+ if(!(conn->handler->protocol & PROTO_FAMILY_HTTP)) {
+ if((conn->handler->flags & PROTOPT_PROXY_AS_HTTP) &&
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 221317e47e..1de8c4bfb1 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -967,6 +967,7 @@ struct UrlState {
+ void (*prev_signal)(int sig);
+ #endif
+ #ifndef CURL_DISABLE_DIGEST_AUTH
++ char *envproxy; /* last proxy string used for proxy-related state */
+ struct digestdata digest; /* state data for host Digest auth */
+ struct digestdata proxydigest; /* state data for proxy Digest auth */
+ #endif
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 57e7508751..2a1c87ddc3 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -212,6 +212,8 @@ test1580 test1581 test1582 test1583 test1584 test1585 \
+ test1588 \
+ test1629 \
+ \
++test1647 \
++\
+ test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
+ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+ test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
+diff --git a/tests/data/test1647 b/tests/data/test1647
+new file mode 100644
+index 0000000000..a87487fa9f
+--- /dev/null
++++ b/tests/data/test1647
+@@ -0,0 +1,103 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++HTTP proxy
++HTTP proxy Digest auth
++multi
++</keywords>
++</info>
++
++# Server-side
++<reply>
++
++# this is returned first since we get no proxy-auth
++<data crlf="headers" nocheck="yes">
++HTTP/1.1 407 Authorization Required to proxy me my dear
++Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
++Content-Length: 33
++
++And you should ignore this data.
++</data>
++
++# then this is returned when we get proxy-auth
++<data1000 crlf="headers">
++HTTP/1.1 200 OK
++Content-Length: 21
++Server: no
++
++Nice proxy auth sir!
++</data1000>
++
++<connect crlf="headers">
++HTTP/1.1 401 OK
++Content-Length: 21
++Server: no
++
++Denied access. Leave
++</connect>
++
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++https-proxy
++https
++</server>
++# tool is what to use instead of 'curl'
++<tool>
++lib%TESTNUMBER
++</tool>
++<features>
++!SSPI
++crypto
++proxy
++digest
++Debug
++</features>
++<setenv>
++http_proxy=%HOSTIP:%HTTPPORT
++https_proxy=https://%HOSTIP:%HTTPSPROXYPORT
++CURL_ENTROPY=99376
++</setenv>
++<name>
++HTTP proxy auth Digest, then change proxy with env var and do it again
++</name>
++<command>
++http://test.remote.example.com/path/%TESTNUMBER https://another.example.com:%HTTPSPORT/ daniel:monkey123 another:bump456
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
++Host: test.remote.example.com
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://test.remote.example.com/path/%TESTNUMBER HTTP/1.1
++Host: test.remote.example.com
++Proxy-Authorization: Digest username="daniel", realm="weirdorealm", nonce="12345", uri="/path/%TESTNUMBER", response="7a1672891aff03248887b1a6674b8096"
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++</protocol>
++
++<proxy crlf="headers">
++CONNECT another.example.com:%HTTPSPORT HTTP/1.1
++Host: another.example.com:%HTTPSPORT
++Proxy-Connection: Keep-Alive
++
++</proxy>
++
++# CONNECT fails
++<errorcode>
++7
++</errorcode>
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index 76014f926a..0f8a2ea506 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -100,6 +100,7 @@ TESTS_C = \
+ lib1582.c lib1588.c \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
++ lib1647.c \
+ lib1662.c \
+ lib1686.c \
+ lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
+diff --git a/tests/libtest/lib1647.c b/tests/libtest/lib1647.c
+new file mode 100644
+index 0000000000..8060e1bfe9
+--- /dev/null
++++ b/tests/libtest/lib1647.c
+@@ -0,0 +1,120 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++/*
++ * argv1 = the first URL
++ * argv2 = URL2
++ * argv3 = credentials 1
++ * argv4 = credentials 2
++ */
++
++#include "first.h"
++
++/* this is meant to pick up the proxy from the environment variable */
++static CURLcode init1647(CURL *curl, const char *url, const char *userpwd)
++{
++ CURLcode result = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 0L);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 0L);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(result)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return result; /* failure */
++}
++
++static CURLcode run1647(CURL *curl, const char *url, const char *userpwd)
++{
++ CURLcode result = CURLE_OK;
++
++ result = init1647(curl, url, userpwd);
++ if(result)
++ return result;
++
++ return curl_easy_perform(curl);
++}
++
++static CURLcode test_lib1647(const char *URL)
++{
++ CURLcode result = CURLE_OK;
++ CURL *curl = NULL;
++
++ res_global_init(CURL_GLOBAL_ALL);
++ if(result)
++ return result;
++
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_mfprintf(stderr, "curl_easy_init() failed\n");
++ curl_global_cleanup();
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ start_test_timing();
++
++ curl_mprintf("--- First get '%s'\n", URL);
++ result = run1647(curl, URL, libtest_arg3);
++ if(result)
++ goto test_cleanup;
++
++ curl_mprintf("--- Then get '%s'\n", libtest_arg2);
++ result = run1647(curl, libtest_arg2, libtest_arg4);
++
++test_cleanup:
++
++ /* proper cleanup sequence - type PB */
++
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ return result;
++}
diff --git a/0020-CVE-2026-9546.patch b/0020-CVE-2026-9546.patch
new file mode 100644
index 0000000..98cbc9b
--- /dev/null
+++ b/0020-CVE-2026-9546.patch
@@ -0,0 +1,415 @@
+From d8d6a9627610927c18a2f7bef2ef1614fb30a3f3 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Wed, 15 Apr 2026 08:11:33 +0200
+Subject: [PATCH] CVE-2026-9546
+
+transfer: clear the old autoreferer
+
+Verify in test 2505
+
+Closes #21322
+
+(cherry picked from commit fa057ea3dedb04f93672ec95ee964f1f02ec0ecf)
+
+transfer: clear referer when set to NULL
+
+Verify in test 1649
+
+Closes #21741
+
+(cherry picked from commit 862e8a74a84478d82973471b4f49dc2746c1780e)
+---
+ lib/setopt.c | 1 -
+ lib/transfer.c | 7 +++
+ tests/data/Makefile.am | 3 +-
+ tests/data/test1649 | 55 +++++++++++++++++++++++
+ tests/data/test2505 | 67 ++++++++++++++++++++++++++++
+ tests/libtest/Makefile.inc | 4 +-
+ tests/libtest/lib1649.c | 90 ++++++++++++++++++++++++++++++++++++++
+ tests/libtest/lib2505.c | 71 ++++++++++++++++++++++++++++++
+ 8 files changed, 294 insertions(+), 4 deletions(-)
+ create mode 100644 tests/data/test1649
+ create mode 100644 tests/data/test2505
+ create mode 100644 tests/libtest/lib1649.c
+ create mode 100644 tests/libtest/lib2505.c
+
+diff --git a/lib/setopt.c b/lib/setopt.c
+index 65c573cb9d..a74ca5e8f3 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -1770,7 +1770,6 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
+ * String to set in the HTTP Referer: field.
+ */
+ result = Curl_setstropt(&s->str[STRING_SET_REFERER], ptr);
+- Curl_bufref_set(&data->state.referer, s->str[STRING_SET_REFERER], 0, NULL);
+ break;
+
+ case CURLOPT_USERAGENT:
+diff --git a/lib/transfer.c b/lib/transfer.c
+index fed6a1786e..8050f8a7b1 100644
+--- a/lib/transfer.c
++++ b/lib/transfer.c
+@@ -503,6 +503,13 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
+ data->state.authproxy.want = data->set.proxyauth;
+ Curl_safefree(data->info.wouldredirect);
+ Curl_data_priority_clear_state(data);
++ if(data->set.http_auto_referer)
++ Curl_bufref_free(&data->state.referer);
++ if(data->set.str[STRING_SET_REFERER])
++ Curl_bufref_set(&data->state.referer, data->set.str[STRING_SET_REFERER],
++ 0, NULL);
++ else
++ Curl_bufref_free(&data->state.referer);
+
+ if(data->state.httpreq == HTTPREQ_PUT)
+ data->state.infilesize = data->set.filesize;
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 2a1c87ddc3..e326ff7eff 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -221,6 +221,7 @@ test1614 test1615 test1616 test1617 \
+ test1620 test1621 test1622 \
+ \
+ test1630 test1631 test1632 test1633 test1634 test1635 test1636 \
++test1649 \
+ \
+ test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
+ test1658 \
+@@ -267,7 +268,7 @@ test2309 \
+ \
+ test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
+ \
+-test2500 test2501 test2502 test2503 \
++test2500 test2501 test2502 test2503 test2505 \
+ \
+ test2600 test2601 test2602 test2603 test2604 test2605 \
+ \
+diff --git a/tests/data/test1649 b/tests/data/test1649
+new file mode 100644
+index 0000000000..d2fd7799bd
+--- /dev/null
++++ b/tests/data/test1649
+@@ -0,0 +1,55 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++Referer
++</keywords>
++</info>
++
++# Server-side
++<reply>
++
++# this is returned first since we get no proxy-auth
++<data crlf="headers" nocheck="yes">
++HTTP/1.1 200 OK
++Content-Length: 6
++
++hello
++</data>
++
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++
++<tool>
++lib%TESTNUMBER
++</tool>
++<name>
++Set referer first then NULL it
++</name>
++<command>
++http://%HOSTIP:%HTTPPORT
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET / HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++Accept: */*
++Referer: https://secret.example.com/
++
++GET / HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++Accept: */*
++
++</protocol>
++
++</verify>
++</testcase>
+diff --git a/tests/data/test2505 b/tests/data/test2505
+new file mode 100644
+index 0000000000..8fac590b37
+--- /dev/null
++++ b/tests/data/test2505
+@@ -0,0 +1,67 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++referer
++autoreferer
++</keywords>
++</info>
++
++# Server-side
++<reply>
++<data crlf="headers" nocheck="yes">
++HTTP/1.1 301 redirect
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: server.example.com
++Content-Length: 47
++Location: %TESTNUMBER0002
++
++file contents should appear once for each file
++</data>
++
++<data2 crlf="headers" nocheck="yes">
++HTTP/1.1 200 OK
++Date: Tue, 09 Nov 2010 14:49:00 GMT
++Server: server.example.com
++Content-Length: 47
++
++file contents should appear once for each file
++</data2>
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++<tool>
++lib%TESTNUMBER
++</tool>
++<name>
++verify CURLOPT_AUTOREFERER switched off
++</name>
++<command>
++http://%HOSTIP:%HTTPPORT
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET / HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++Accept: */*
++
++GET /%TESTNUMBER0002 HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++Accept: */*
++Referer: http://%HOSTIP:%HTTPPORT/
++
++GET / HTTP/1.1
++Host: %HOSTIP:%HTTPPORT
++Accept: */*
++
++</protocol>
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index 0f8a2ea506..82740ef1b0 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -100,7 +100,7 @@ TESTS_C = \
+ lib1582.c lib1588.c \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
+- lib1647.c \
++ lib1647.c lib1649.c \
+ lib1662.c \
+ lib1686.c \
+ lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
+@@ -115,7 +115,7 @@ TESTS_C = \
+ lib2023.c lib2032.c lib2082.c \
+ lib2301.c lib2302.c lib2304.c lib2306.c lib2308.c lib2309.c \
+ lib2402.c lib2404.c lib2405.c \
+- lib2502.c \
++ lib2502.c lib2505.c \
+ lib2700.c \
+ lib3010.c lib3025.c lib3026.c lib3027.c lib3033.c lib3034.c \
+ lib3100.c lib3101.c lib3102.c lib3103.c lib3104.c lib3105.c \
+diff --git a/tests/libtest/lib1649.c b/tests/libtest/lib1649.c
+new file mode 100644
+index 0000000000..2dd66c0231
+--- /dev/null
++++ b/tests/libtest/lib1649.c
+@@ -0,0 +1,90 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++
++#include "first.h"
++
++/* this is meant to pick up the proxy from the environment variable */
++static CURLcode init1649(CURL *curl, const char *url)
++{
++ CURLcode result = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(result)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return result; /* failure */
++}
++
++static CURLcode run1649(CURL *curl, const char *url)
++{
++ CURLcode result = CURLE_OK;
++
++ result = init1649(curl, url);
++ if(result)
++ return result;
++
++ return curl_easy_perform(curl);
++}
++
++static CURLcode test_lib1649(const char *URL)
++{
++ CURLcode result = CURLE_OK;
++ CURL *curl = NULL;
++
++ res_global_init(CURL_GLOBAL_ALL);
++ if(result)
++ return result;
++
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_mfprintf(stderr, "curl_easy_init() failed\n");
++ curl_global_cleanup();
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ start_test_timing();
++
++ easy_setopt(curl, CURLOPT_REFERER, "https://secret.example.com/");
++
++ result = run1649(curl, URL);
++ if(result)
++ goto test_cleanup;
++
++ /* reset it */
++ easy_setopt(curl, CURLOPT_REFERER, NULL);
++
++ result = run1649(curl, URL);
++
++test_cleanup:
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ return result;
++}
+diff --git a/tests/libtest/lib2505.c b/tests/libtest/lib2505.c
+new file mode 100644
+index 0000000000..c170259874
+--- /dev/null
++++ b/tests/libtest/lib2505.c
+@@ -0,0 +1,71 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Linus Nielsen Feltzing <linus@haxx.se>
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++#include "first.h"
++
++#include "testtrace.h"
++
++static size_t sink2505(char *ptr, size_t size, size_t nmemb, void *ud)
++{
++ (void)ptr;
++ (void)ud;
++ return size * nmemb;
++}
++
++static CURLcode test_lib2505(const char *URL)
++{
++ CURL *curl;
++ CURLcode result = CURLE_OUT_OF_MEMORY;
++
++ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
++ curl_mfprintf(stderr, "curl_global_init() failed\n");
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_mfprintf(stderr, "curl_easy_init() failed\n");
++ curl_global_cleanup();
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ test_setopt(curl, CURLOPT_WRITEFUNCTION, sink2505);
++ test_setopt(curl, CURLOPT_AUTOREFERER, 1L);
++ test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
++ test_setopt(curl, CURLOPT_URL, URL);
++
++ result = curl_easy_perform(curl);
++ curl_mprintf("req1=%d\n", (int)result);
++
++ test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
++ test_setopt(curl, CURLOPT_URL, URL);
++
++ result = curl_easy_perform(curl);
++ curl_mprintf("req2=%d\n", (int)result);
++
++test_cleanup:
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++
++ return result;
++}
diff --git a/0020-curl-8.18.0-CVE-2026-9545.patch b/0020-curl-8.18.0-CVE-2026-9545.patch
deleted file mode 100644
index 06c7f14..0000000
--- a/0020-curl-8.18.0-CVE-2026-9545.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From 025362685336921d13e48ace1fbdc3aee80743a9 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Thu, 21 May 2026 14:21:59 +0200
-Subject: [PATCH] ngtcp2: fail handshake directly
-
-When certificate verification fails, error out of the handshake
-callback, forcing ngtcp2 to stop processing the connection any further.
-
-Closes #21712
-
-(cherry picked from commit 7b9613fa9b1a5e04301a3920eef58e8138dad05e)
----
- lib/vquic/curl_ngtcp2.c | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c
-index 97ef98b971..233287dc7e 100644
---- a/lib/vquic/curl_ngtcp2.c
-+++ b/lib/vquic/curl_ngtcp2.c
-@@ -503,7 +503,7 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data)
- data = CF_DATA_CURRENT(cf);
- DEBUGASSERT(data);
- if(!ctx || !data)
-- return NGHTTP3_ERR_CALLBACK_FAILURE;
-+ return NGTCP2_ERR_CALLBACK_FAILURE;
-
- ctx->handshake_at = *Curl_pgrs_now(data);
- ctx->tls_handshake_complete = TRUE;
-@@ -511,6 +511,9 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data)
-
- ctx->tls_vrfy_result = Curl_vquic_tls_verify_peer(&ctx->tls, cf,
- data, &ctx->peer);
-+ if(ctx->tls_vrfy_result)
-+ return NGTCP2_ERR_CALLBACK_FAILURE;
-+
- #ifndef CURL_DISABLE_VERBOSE_STRINGS
- if(Curl_trc_is_verbose(data)) {
- const ngtcp2_transport_params *rp;
-@@ -1440,6 +1443,8 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
- out:
- result = Curl_1st_err(result, cf_progress_egress(cf, data, &pktx));
- result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx));
-+ if(ctx->tls_vrfy_result)
-+ result = ctx->tls_vrfy_result;
- denied:
- CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv(blen=%zu) -> %d, %zu",
- stream ? stream->id : -1, blen, result, *pnread);
-@@ -1767,6 +1772,8 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
-
- out:
- result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx));
-+ if(ctx->tls_vrfy_result)
-+ result = ctx->tls_vrfy_result;
- denied:
- CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu) -> %d, %zu",
- stream ? stream->id : -1, len, result, *pnwritten);
-@@ -2694,6 +2701,8 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf,
- }
-
- out:
-+ if(ctx->tls_vrfy_result)
-+ result = ctx->tls_vrfy_result;
- if(ctx->qconn &&
- ((result == CURLE_RECV_ERROR) || (result == CURLE_SEND_ERROR)) &&
- ngtcp2_conn_in_draining_period(ctx->qconn)) {
---
-2.55.0
-
diff --git a/0021-curl-8.18.0-CVE-2026-9080.patch b/0021-curl-8.18.0-CVE-2026-9080.patch
deleted file mode 100644
index 08d1286..0000000
--- a/0021-curl-8.18.0-CVE-2026-9080.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From b443308bfaebea79d7355f2edf50df2a903c3dc8 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Tue, 26 May 2026 09:52:19 +0200
-Subject: [PATCH] multi: handle pause in multi socket callback
-
-The mev_sh_entry object might be removed if curl_easy_pause() is called
-from within the socket callback.
-
-Introduced a 'magic' struct field to to 'mev_sh_entry' to make it easier
-to programmatically detect/assert if the pointer is bad - in debug
-builds.
-
-Reported-by: Joshua Rogers
-Closes #21748
-
-(cherry picked from commit 5ab34cba42e4ee4282fe8bab43f311d51b9bf9bd)
----
- lib/multi_ev.c | 23 ++++++++++++++++++++---
- 1 file changed, 20 insertions(+), 3 deletions(-)
-
-diff --git a/lib/multi_ev.c b/lib/multi_ev.c
-index 0c89721f35..e0566e9ff5 100644
---- a/lib/multi_ev.c
-+++ b/lib/multi_ev.c
-@@ -40,6 +40,8 @@ static void mev_in_callback(struct Curl_multi *multi, bool value)
- multi->in_callback = value;
- }
-
-+#define SH_ENTRY_MAGIC 0x570091d
-+
- /* Information about a socket for which we inform the libcurl application
- * what to supervise (CURL_POLL_IN/CURL_POLL_OUT/CURL_POLL_REMOVE)
- */
-@@ -51,6 +53,9 @@ struct mev_sh_entry {
- * libcurl application to watch out for */
- unsigned int readers; /* this many transfers want to read */
- unsigned int writers; /* this many transfers want to write */
-+#ifdef DEBUGBUILD
-+ unsigned int magic;
-+#endif
- BIT(announced); /* this socket has been passed to the socket
- callback at least once */
- };
-@@ -75,6 +80,9 @@ static void mev_sh_entry_dtor(void *freethis)
- {
- struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
- Curl_uint32_spbset_destroy(&entry->xfers);
-+#ifdef DEBUGBUILD
-+ entry->magic = 0;
-+#endif
- curlx_free(entry);
- }
-
-@@ -113,7 +121,9 @@ static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh,
- mev_sh_entry_dtor(check);
- return NULL; /* major failure */
- }
--
-+#ifdef DEBUGBUILD
-+ check->magic = SH_ENTRY_MAGIC;
-+#endif
- return check; /* things are good in sockhash land */
- }
-
-@@ -222,6 +232,7 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
-
- /* we should only be called when the callback exists */
- DEBUGASSERT(multi->socket_cb);
-+ DEBUGASSERT(entry->magic == SH_ENTRY_MAGIC);
- if(!multi->socket_cb)
- return CURLM_OK;
-
-@@ -271,12 +282,18 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
- rc = multi->socket_cb(data, s, comboaction, multi->socket_userp,
- entry->user_data);
- mev_in_callback(multi, FALSE);
-- entry->announced = TRUE;
- if(rc == -1) {
- multi->dead = TRUE;
- return CURLM_ABORTED_BY_CALLBACK;
- }
-- entry->action = (unsigned int)comboaction;
-+ /* curl_easy_pause() is documented as callable from any callback; it
-+ * re-enters mev_assess() which may free this 'entry'. Re-fetch. */
-+ entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
-+ if(entry) {
-+ DEBUGASSERT(entry->magic == SH_ENTRY_MAGIC);
-+ entry->announced = TRUE;
-+ entry->action = (unsigned int)comboaction;
-+ }
- return CURLM_OK;
- }
-
---
-2.55.0
-
diff --git a/0021-ngtcp2-fail-handshake-directly.patch b/0021-ngtcp2-fail-handshake-directly.patch
new file mode 100644
index 0000000..47d8b47
--- /dev/null
+++ b/0021-ngtcp2-fail-handshake-directly.patch
@@ -0,0 +1,65 @@
+From 9e6eae01ff428a9cfd2a33929a87c2e28c1380f7 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Thu, 21 May 2026 14:21:59 +0200
+Subject: [PATCH] ngtcp2: fail handshake directly
+
+When certificate verification fails, error out of the handshake
+callback, forcing ngtcp2 to stop processing the connection any further.
+
+Closes #21712
+
+(cherry picked from commit 7b9613fa9b1a5e04301a3920eef58e8138dad05e)
+---
+ lib/vquic/curl_ngtcp2.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c
+index 97ef98b971..233287dc7e 100644
+--- a/lib/vquic/curl_ngtcp2.c
++++ b/lib/vquic/curl_ngtcp2.c
+@@ -503,7 +503,7 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data)
+ data = CF_DATA_CURRENT(cf);
+ DEBUGASSERT(data);
+ if(!ctx || !data)
+- return NGHTTP3_ERR_CALLBACK_FAILURE;
++ return NGTCP2_ERR_CALLBACK_FAILURE;
+
+ ctx->handshake_at = *Curl_pgrs_now(data);
+ ctx->tls_handshake_complete = TRUE;
+@@ -511,6 +511,9 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data)
+
+ ctx->tls_vrfy_result = Curl_vquic_tls_verify_peer(&ctx->tls, cf,
+ data, &ctx->peer);
++ if(ctx->tls_vrfy_result)
++ return NGTCP2_ERR_CALLBACK_FAILURE;
++
+ #ifndef CURL_DISABLE_VERBOSE_STRINGS
+ if(Curl_trc_is_verbose(data)) {
+ const ngtcp2_transport_params *rp;
+@@ -1440,6 +1443,8 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
+ out:
+ result = Curl_1st_err(result, cf_progress_egress(cf, data, &pktx));
+ result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx));
++ if(ctx->tls_vrfy_result)
++ result = ctx->tls_vrfy_result;
+ denied:
+ CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv(blen=%zu) -> %d, %zu",
+ stream ? stream->id : -1, blen, result, *pnread);
+@@ -1767,6 +1772,8 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
+
+ out:
+ result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx));
++ if(ctx->tls_vrfy_result)
++ result = ctx->tls_vrfy_result;
+ denied:
+ CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu) -> %d, %zu",
+ stream ? stream->id : -1, len, result, *pnwritten);
+@@ -2694,6 +2701,8 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf,
+ }
+
+ out:
++ if(ctx->tls_vrfy_result)
++ result = ctx->tls_vrfy_result;
+ if(ctx->qconn &&
+ ((result == CURLE_RECV_ERROR) || (result == CURLE_SEND_ERROR)) &&
+ ngtcp2_conn_in_draining_period(ctx->qconn)) {
diff --git a/0022-curl-8.18.0-CVE-2026-10536.patch b/0022-curl-8.18.0-CVE-2026-10536.patch
deleted file mode 100644
index c04e728..0000000
--- a/0022-curl-8.18.0-CVE-2026-10536.patch
+++ /dev/null
@@ -1,375 +0,0 @@
-From a83cc30ca7d11833a34bb3ca7366dbf762e189f6 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 22 May 2026 09:11:41 +0200
-Subject: [PATCH] http2: remove stream dependency tracking
-
-The HTTP/2 feature is deprecated, few servers implement it and our
-implementation is complicated by its state management. Make the two
-CURLOPT_* involved a nop and deprecate them.
-
-Closes #21723
-
-(cherry picked from commit bfbff7852f050232edd3e5ca5c6bf2021c340f5a)
----
- docs/libcurl/curl_easy_setopt.md | 5 +-
- docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md | 8 ++
- docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md | 8 ++
- docs/libcurl/symbols-in-versions | 4 +-
- include/curl/curl.h | 6 +-
- lib/http2.c | 18 ++--
- lib/setopt.c | 9 +-
- lib/url.c | 98 -------------------
- lib/url.h | 8 --
- lib/urldata.h | 15 ---
- 10 files changed, 34 insertions(+), 145 deletions(-)
-
-diff --git a/docs/libcurl/curl_easy_setopt.md b/docs/libcurl/curl_easy_setopt.md
-index 771442b185..71ea9a5251 100644
---- a/docs/libcurl/curl_easy_setopt.md
-+++ b/docs/libcurl/curl_easy_setopt.md
-@@ -1162,11 +1162,12 @@ Redirect stderr to another stream. See CURLOPT_STDERR(3)
-
- ## CURLOPT_STREAM_DEPENDS
-
--This HTTP/2 stream depends on another. See CURLOPT_STREAM_DEPENDS(3)
-+**Deprecated option** This HTTP/2 stream depends on another. See
-+CURLOPT_STREAM_DEPENDS(3)
-
- ## CURLOPT_STREAM_DEPENDS_E
-
--This HTTP/2 stream depends on another exclusively. See
-+**Deprecated option** This HTTP/2 stream depends on another exclusively. See
- CURLOPT_STREAM_DEPENDS_E(3)
-
- ## CURLOPT_STREAM_WEIGHT
-diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
-index 5e3e177dce..e0e8ef0c53 100644
---- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
-+++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
-@@ -44,6 +44,10 @@ an error. It must be another easy handle, and it also needs to be a handle of
- a transfer that is about to be sent over the same HTTP/2 connection for this
- option to have an actual effect.
-
-+Since version 8.21.0 setting this option no longer has an effect. HTTP/2
-+stream dependencies were introduced in RFC 7540 and then later deprecated
-+in RFC 9113.
-+
- # DEFAULT
-
- NULL
-@@ -69,6 +73,10 @@ int main(void)
- }
- ~~~
-
-+# DEPRECATED
-+
-+Deprecated since 8.21.0.
-+
- # %AVAILABILITY%
-
- # RETURN VALUE
-diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
-index fe95ae8d71..fe8f97f950 100644
---- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
-+++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
-@@ -47,6 +47,10 @@ an error. It must be another easy handle, and it also needs to be a handle of
- a transfer that is about to be sent over the same HTTP/2 connection for this
- option to have an actual effect.
-
-+Since version 8.21.0 setting this option no longer has an effect. HTTP/2
-+stream dependencies were introduced in RFC 7540 and then later deprecated
-+in RFC 9113.
-+
- # DEFAULT
-
- NULL
-@@ -72,6 +76,10 @@ int main(void)
- }
- ~~~
-
-+# DEPRECATED
-+
-+Deprecated since 8.21.0.
-+
- # %AVAILABILITY%
-
- # RETURN VALUE
-diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
-index e0e0a8e63a..2a045a82ed 100644
---- a/docs/libcurl/symbols-in-versions
-+++ b/docs/libcurl/symbols-in-versions
-@@ -878,8 +878,8 @@ CURLOPT_SSLKEYPASSWD 7.9.3 7.17.0
- CURLOPT_SSLKEYTYPE 7.9.3
- CURLOPT_SSLVERSION 7.1
- CURLOPT_STDERR 7.1
--CURLOPT_STREAM_DEPENDS 7.46.0
--CURLOPT_STREAM_DEPENDS_E 7.46.0
-+CURLOPT_STREAM_DEPENDS 7.46.0 8.21.0
-+CURLOPT_STREAM_DEPENDS_E 7.46.0 8.21.0
- CURLOPT_STREAM_WEIGHT 7.46.0
- CURLOPT_SUPPRESS_CONNECT_HEADERS 7.54.0
- CURLOPT_TCP_FASTOPEN 7.49.0
-diff --git a/include/curl/curl.h b/include/curl/curl.h
-index e755f098f2..d9ce7307e2 100644
---- a/include/curl/curl.h
-+++ b/include/curl/curl.h
-@@ -1980,10 +1980,12 @@ typedef enum {
- CURLOPT(CURLOPT_STREAM_WEIGHT, CURLOPTTYPE_LONG, 239),
-
- /* Set stream dependency on another curl handle */
-- CURLOPT(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240),
-+ CURLOPTDEPRECATED(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240,
-+ 8.21.0, "Has no function"),
-
- /* Set E-xclusive stream dependency on another curl handle */
-- CURLOPT(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241),
-+ CURLOPTDEPRECATED(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241,
-+ 8.21.0, "Has no function"),
-
- /* Do not send any tftp option requests to the server */
- CURLOPT(CURLOPT_TFTP_NO_OPTIONS, CURLOPTTYPE_LONG, 242),
-diff --git a/lib/http2.c b/lib/http2.c
-index a8b8d5c52f..c3177b9294 100644
---- a/lib/http2.c
-+++ b/lib/http2.c
-@@ -1933,16 +1933,12 @@ static int sweight_in_effect(const struct Curl_easy *data)
- * struct.
- */
-
--static void h2_pri_spec(struct cf_h2_ctx *ctx,
-- struct Curl_easy *data,
-+static void h2_pri_spec(struct Curl_easy *data,
- nghttp2_priority_spec *pri_spec)
- {
- struct Curl_data_priority *prio = &data->set.priority;
-- struct h2_stream_ctx *depstream = H2_STREAM_CTX(ctx, prio->parent);
-- int32_t depstream_id = depstream ? depstream->id : 0;
-- nghttp2_priority_spec_init(pri_spec, depstream_id,
-- sweight_wanted(data),
-- data->set.priority.exclusive);
-+ nghttp2_priority_spec_init(pri_spec, 0,
-+ sweight_wanted(data), FALSE);
- data->state.priority = *prio;
- }
-
-@@ -1960,13 +1956,11 @@ static CURLcode h2_progress_egress(struct Curl_cfilter *cf,
- int rv = 0;
-
- if(stream && stream->id > 0 &&
-- ((sweight_wanted(data) != sweight_in_effect(data)) ||
-- (data->set.priority.exclusive != data->state.priority.exclusive) ||
-- (data->set.priority.parent != data->state.priority.parent))) {
-+ (sweight_wanted(data) != sweight_in_effect(data))) {
- /* send new weight and/or dependency */
- nghttp2_priority_spec pri_spec;
-
-- h2_pri_spec(ctx, data, &pri_spec);
-+ h2_pri_spec(data, &pri_spec);
- CURL_TRC_CF(data, cf, "[%d] Queuing PRIORITY", stream->id);
- DEBUGASSERT(stream->id != -1);
- rv = nghttp2_submit_priority(ctx->h2, NGHTTP2_FLAG_NONE,
-@@ -2274,7 +2268,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream,
- goto out;
- }
-
-- h2_pri_spec(ctx, data, &pri_spec);
-+ h2_pri_spec(data, &pri_spec);
- if(!nghttp2_session_check_request_allowed(ctx->h2))
- CURL_TRC_CF(data, cf, "send request NOT allowed (via nghttp2)");
-
-diff --git a/lib/setopt.c b/lib/setopt.c
-index a74ca5e8f3..355a59c0a1 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -1508,13 +1508,10 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
-
- #ifdef USE_HTTP2
- case CURLOPT_STREAM_DEPENDS:
-- case CURLOPT_STREAM_DEPENDS_E: {
-- struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
-- if(!dep || GOOD_EASY_HANDLE(dep))
-- return Curl_data_priority_add_child(dep, data,
-- option == CURLOPT_STREAM_DEPENDS_E);
-+ case CURLOPT_STREAM_DEPENDS_E:
-+ /* not doing stream dependencies any longer, but accept options
-+ * for backward compatibility */
- break;
-- }
- #endif
-
- default:
-diff --git a/lib/url.c b/lib/url.c
-index fefc1a0518..900b0f7352 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -120,12 +120,6 @@
- #include "smtp.h"
- #include "ws.h"
-
--#ifdef USE_NGHTTP2
--static void data_priority_cleanup(struct Curl_easy *data);
--#else
--#define data_priority_cleanup(x)
--#endif
--
- /* Some parts of the code (e.g. chunked encoding) assume this buffer has at
- * more than just a few bytes to play with. Do not let it become too small or
- * bad things will happen.
-@@ -282,8 +276,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
- Curl_safefree(data->info.contenttype);
- Curl_safefree(data->info.wouldredirect);
-
-- data_priority_cleanup(data);
--
- /* No longer a dirty share, if it exists */
- if(data->share) {
- Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
-@@ -3970,96 +3962,6 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
-
- #if defined(USE_HTTP2) || defined(USE_HTTP3)
-
--#ifdef USE_NGHTTP2
--
--static void priority_remove_child(struct Curl_easy *parent,
-- struct Curl_easy *child)
--{
-- struct Curl_data_prio_node **pnext = &parent->set.priority.children;
-- struct Curl_data_prio_node *pnode = parent->set.priority.children;
--
-- DEBUGASSERT(child->set.priority.parent == parent);
-- while(pnode && pnode->data != child) {
-- pnext = &pnode->next;
-- pnode = pnode->next;
-- }
--
-- DEBUGASSERT(pnode);
-- if(pnode) {
-- *pnext = pnode->next;
-- curlx_free(pnode);
-- }
--
-- child->set.priority.parent = 0;
-- child->set.priority.exclusive = FALSE;
--}
--
--CURLcode Curl_data_priority_add_child(struct Curl_easy *parent,
-- struct Curl_easy *child,
-- bool exclusive)
--{
-- if(child->set.priority.parent) {
-- priority_remove_child(child->set.priority.parent, child);
-- }
--
-- if(parent) {
-- struct Curl_data_prio_node **tail;
-- struct Curl_data_prio_node *pnode;
--
-- pnode = curlx_calloc(1, sizeof(*pnode));
-- if(!pnode)
-- return CURLE_OUT_OF_MEMORY;
-- pnode->data = child;
--
-- if(parent->set.priority.children && exclusive) {
-- /* exclusive: move all existing children underneath the new child */
-- struct Curl_data_prio_node *node = parent->set.priority.children;
-- while(node) {
-- node->data->set.priority.parent = child;
-- node = node->next;
-- }
--
-- tail = &child->set.priority.children;
-- while(*tail)
-- tail = &(*tail)->next;
--
-- DEBUGASSERT(!*tail);
-- *tail = parent->set.priority.children;
-- parent->set.priority.children = 0;
-- }
--
-- tail = &parent->set.priority.children;
-- while(*tail) {
-- (*tail)->data->set.priority.exclusive = FALSE;
-- tail = &(*tail)->next;
-- }
--
-- DEBUGASSERT(!*tail);
-- *tail = pnode;
-- }
--
-- child->set.priority.parent = parent;
-- child->set.priority.exclusive = exclusive;
-- return CURLE_OK;
--}
--
--#endif /* USE_NGHTTP2 */
--
--#ifdef USE_NGHTTP2
--static void data_priority_cleanup(struct Curl_easy *data)
--{
-- while(data->set.priority.children) {
-- struct Curl_easy *tmp = data->set.priority.children->data;
-- priority_remove_child(data, tmp);
-- if(data->set.priority.parent)
-- Curl_data_priority_add_child(data->set.priority.parent, tmp, FALSE);
-- }
--
-- if(data->set.priority.parent)
-- priority_remove_child(data->set.priority.parent, data);
--}
--#endif
--
- void Curl_data_priority_clear_state(struct Curl_easy *data)
- {
- memset(&data->state.priority, 0, sizeof(data->state.priority));
-diff --git a/lib/url.h b/lib/url.h
-index 3a8d57c377..ddac784e75 100644
---- a/lib/url.h
-+++ b/lib/url.h
-@@ -111,12 +111,4 @@ void Curl_data_priority_clear_state(struct Curl_easy *data);
- #define Curl_data_priority_clear_state(x)
- #endif /* USE_HTTP2 || USE_HTTP3 */
-
--#ifdef USE_NGHTTP2
--CURLcode Curl_data_priority_add_child(struct Curl_easy *parent,
-- struct Curl_easy *child,
-- bool exclusive);
--#else
--#define Curl_data_priority_add_child(x, y, z) CURLE_NOT_BUILT_IN
--#endif
--
- #endif /* HEADER_CURL_URL_H */
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 1de8c4bfb1..7e36cc2336 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -864,27 +864,12 @@ struct auth {
- should be RFC compliant */
- };
-
--#ifdef USE_NGHTTP2
--struct Curl_data_prio_node {
-- struct Curl_data_prio_node *next;
-- struct Curl_easy *data;
--};
--#endif
--
- /**
- * Priority information for an easy handle in relation to others
- * on the same connection.
- */
- struct Curl_data_priority {
--#ifdef USE_NGHTTP2
-- /* tree like dependencies only implemented in nghttp2 */
-- struct Curl_easy *parent;
-- struct Curl_data_prio_node *children;
--#endif
- int weight;
--#ifdef USE_NGHTTP2
-- BIT(exclusive);
--#endif
- };
-
- /* Timers */
---
-2.55.0
-
diff --git a/0022-multi-handle-pause-in-multi-socket-callback.patch b/0022-multi-handle-pause-in-multi-socket-callback.patch
new file mode 100644
index 0000000..83195c9
--- /dev/null
+++ b/0022-multi-handle-pause-in-multi-socket-callback.patch
@@ -0,0 +1,93 @@
+From 78bb6dc1bbe3819ae49d8a9bb393fc3208838b4e Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 26 May 2026 09:52:19 +0200
+Subject: [PATCH] multi: handle pause in multi socket callback
+
+The mev_sh_entry object might be removed if curl_easy_pause() is called
+from within the socket callback.
+
+Introduced a 'magic' struct field to to 'mev_sh_entry' to make it easier
+to programmatically detect/assert if the pointer is bad - in debug
+builds.
+
+Reported-by: Joshua Rogers
+Closes #21748
+
+(cherry picked from commit 5ab34cba42e4ee4282fe8bab43f311d51b9bf9bd)
+---
+ lib/multi_ev.c | 23 ++++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/lib/multi_ev.c b/lib/multi_ev.c
+index 0c89721f35..e0566e9ff5 100644
+--- a/lib/multi_ev.c
++++ b/lib/multi_ev.c
+@@ -40,6 +40,8 @@ static void mev_in_callback(struct Curl_multi *multi, bool value)
+ multi->in_callback = value;
+ }
+
++#define SH_ENTRY_MAGIC 0x570091d
++
+ /* Information about a socket for which we inform the libcurl application
+ * what to supervise (CURL_POLL_IN/CURL_POLL_OUT/CURL_POLL_REMOVE)
+ */
+@@ -51,6 +53,9 @@ struct mev_sh_entry {
+ * libcurl application to watch out for */
+ unsigned int readers; /* this many transfers want to read */
+ unsigned int writers; /* this many transfers want to write */
++#ifdef DEBUGBUILD
++ unsigned int magic;
++#endif
+ BIT(announced); /* this socket has been passed to the socket
+ callback at least once */
+ };
+@@ -75,6 +80,9 @@ static void mev_sh_entry_dtor(void *freethis)
+ {
+ struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
+ Curl_uint32_spbset_destroy(&entry->xfers);
++#ifdef DEBUGBUILD
++ entry->magic = 0;
++#endif
+ curlx_free(entry);
+ }
+
+@@ -113,7 +121,9 @@ static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh,
+ mev_sh_entry_dtor(check);
+ return NULL; /* major failure */
+ }
+-
++#ifdef DEBUGBUILD
++ check->magic = SH_ENTRY_MAGIC;
++#endif
+ return check; /* things are good in sockhash land */
+ }
+
+@@ -222,6 +232,7 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
+
+ /* we should only be called when the callback exists */
+ DEBUGASSERT(multi->socket_cb);
++ DEBUGASSERT(entry->magic == SH_ENTRY_MAGIC);
+ if(!multi->socket_cb)
+ return CURLM_OK;
+
+@@ -271,12 +282,18 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
+ rc = multi->socket_cb(data, s, comboaction, multi->socket_userp,
+ entry->user_data);
+ mev_in_callback(multi, FALSE);
+- entry->announced = TRUE;
+ if(rc == -1) {
+ multi->dead = TRUE;
+ return CURLM_ABORTED_BY_CALLBACK;
+ }
+- entry->action = (unsigned int)comboaction;
++ /* curl_easy_pause() is documented as callable from any callback; it
++ * re-enters mev_assess() which may free this 'entry'. Re-fetch. */
++ entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
++ if(entry) {
++ DEBUGASSERT(entry->magic == SH_ENTRY_MAGIC);
++ entry->announced = TRUE;
++ entry->action = (unsigned int)comboaction;
++ }
+ return CURLM_OK;
+ }
+
diff --git a/0023-curl-8.18.0-CVE-2026-11564.patch b/0023-curl-8.18.0-CVE-2026-11564.patch
deleted file mode 100644
index 26433cc..0000000
--- a/0023-curl-8.18.0-CVE-2026-11564.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 900bbf21f1bc13b123fd6bd0c1f5c4d31197330d Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Mon, 8 Jun 2026 10:11:30 +0200
-Subject: [PATCH] ssl native_ca_store: always reinit
-
-Add bit `native_ca_store_opt` to keep the setting of
-CURLOPT_(PROXY_)SSL_OPTIONS and use that to calculate every easy
-transfer if a native CA store shall be used or not.
-
-This avoids `native_ca_store` getting stuck on TRUE after being set
-once.
-
-Closes #21902
-
-(cherry picked from commit d69bfad3fa3daf5e72331f6870667607828d5891)
----
- lib/doh.c | 3 ++-
- lib/setopt.c | 20 ++------------------
- lib/vtls/vtls.c | 19 +++++++++++++++++++
- 3 files changed, 23 insertions(+), 19 deletions(-)
-
-diff --git a/lib/doh.c b/lib/doh.c
-index 9052fab26b..13497e0253 100644
---- a/lib/doh.c
-+++ b/lib/doh.c
-@@ -400,7 +400,8 @@ static CURLcode doh_probe_run(struct Curl_easy *data,
- }
-
- (void)curl_easy_setopt(doh, CURLOPT_SSL_OPTIONS,
-- (long)data->set.ssl.primary.ssl_options);
-+ ((long)data->set.ssl.primary.ssl_options &
-+ ~CURLSSLOPT_AUTO_CLIENT_CERT));
-
- doh->state.internal = TRUE;
- doh->master_mid = data->mid; /* master transfer of this one */
-diff --git a/lib/setopt.c b/lib/setopt.c
-index 355a59c0a1..089390030c 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -414,22 +414,6 @@ static CURLcode setopt_RTSP_REQUEST(struct Curl_easy *data, long arg)
- }
- #endif /* !CURL_DISABLE_RTSP */
-
--#ifdef USE_SSL
--static void set_ssl_options(struct ssl_config_data *ssl,
-- struct ssl_primary_config *config,
-- long arg)
--{
-- config->ssl_options = (unsigned char)(arg & 0xff);
-- ssl->enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
-- ssl->no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
-- ssl->no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
-- ssl->revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
-- ssl->native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
-- ssl->auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
-- ssl->earlydata = !!(arg & CURLSSLOPT_EARLYDATA);
--}
--#endif
--
- static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option,
- long arg, bool *set)
- {
-@@ -1127,12 +1111,12 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
- s->use_ssl = (unsigned char)arg;
- break;
- case CURLOPT_SSL_OPTIONS:
-- set_ssl_options(&s->ssl, &s->ssl.primary, arg);
-+ s->ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
- break;
-
- #ifndef CURL_DISABLE_PROXY
- case CURLOPT_PROXY_SSL_OPTIONS:
-- set_ssl_options(&s->proxy_ssl, &s->proxy_ssl.primary, arg);
-+ s->proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
- break;
- #endif
-
-diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
-index be0c032bff..851bc341a9 100644
---- a/lib/vtls/vtls.c
-+++ b/lib/vtls/vtls.c
-@@ -286,6 +286,21 @@ static void free_primary_ssl_config(struct ssl_primary_config *sslc)
- #endif
- }
-
-+static void ssl_easy_config_compl_options(struct ssl_config_data *sslc)
-+{
-+ unsigned char options = sslc->primary.ssl_options;
-+ /* If set via CURLOPT_(PROXY_)SSL_OPTIONS, we definitely use it.
-+ * If not, we switch it on for supported backends if no custom
-+ * ca settings exist. */
-+ sslc->native_ca_store = !!(options & CURLSSLOPT_NATIVE_CA);
-+ sslc->enable_beast = !!(options & CURLSSLOPT_ALLOW_BEAST);
-+ sslc->no_partialchain = !!(options & CURLSSLOPT_NO_PARTIALCHAIN);
-+ sslc->no_revoke = !!(options & CURLSSLOPT_NO_REVOKE);
-+ sslc->revoke_best_effort = !!(options & CURLSSLOPT_REVOKE_BEST_EFFORT);
-+ sslc->auto_client_cert = !!(options & CURLSSLOPT_AUTO_CLIENT_CERT);
-+ sslc->earlydata = !!(options & CURLSSLOPT_EARLYDATA);
-+}
-+
- CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- {
- struct ssl_config_data *sslc = &data->set.ssl;
-@@ -294,6 +309,8 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- CURLcode result;
- #endif
-
-+ ssl_easy_config_compl_options(sslc);
-+
- if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
- #ifdef USE_APPLE_SECTRUST
- if(!sslc->custom_capath && !sslc->custom_cafile && !sslc->custom_cablob)
-@@ -340,6 +357,8 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
-
- #ifndef CURL_DISABLE_PROXY
- sslc = &data->set.proxy_ssl;
-+ ssl_easy_config_compl_options(sslc);
-+
- if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
- #ifdef USE_APPLE_SECTRUST
- if(!sslc->custom_capath && !sslc->custom_cafile && !sslc->custom_cablob)
---
-2.55.0
-
diff --git a/0023-http2-remove-stream-dependency-tracking.patch b/0023-http2-remove-stream-dependency-tracking.patch
new file mode 100644
index 0000000..c179b05
--- /dev/null
+++ b/0023-http2-remove-stream-dependency-tracking.patch
@@ -0,0 +1,372 @@
+From 8b6733e84267f09a171171b1dca46e905ec915c5 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Fri, 22 May 2026 09:11:41 +0200
+Subject: [PATCH] http2: remove stream dependency tracking
+
+The HTTP/2 feature is deprecated, few servers implement it and our
+implementation is complicated by its state management. Make the two
+CURLOPT_* involved a nop and deprecate them.
+
+Closes #21723
+
+(cherry picked from commit bfbff7852f050232edd3e5ca5c6bf2021c340f5a)
+---
+ docs/libcurl/curl_easy_setopt.md | 5 +-
+ docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md | 8 ++
+ docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md | 8 ++
+ docs/libcurl/symbols-in-versions | 4 +-
+ include/curl/curl.h | 6 +-
+ lib/http2.c | 18 ++--
+ lib/setopt.c | 9 +-
+ lib/url.c | 98 -------------------
+ lib/url.h | 8 --
+ lib/urldata.h | 15 ---
+ 10 files changed, 34 insertions(+), 145 deletions(-)
+
+diff --git a/docs/libcurl/curl_easy_setopt.md b/docs/libcurl/curl_easy_setopt.md
+index 771442b185..71ea9a5251 100644
+--- a/docs/libcurl/curl_easy_setopt.md
++++ b/docs/libcurl/curl_easy_setopt.md
+@@ -1162,11 +1162,12 @@ Redirect stderr to another stream. See CURLOPT_STDERR(3)
+
+ ## CURLOPT_STREAM_DEPENDS
+
+-This HTTP/2 stream depends on another. See CURLOPT_STREAM_DEPENDS(3)
++**Deprecated option** This HTTP/2 stream depends on another. See
++CURLOPT_STREAM_DEPENDS(3)
+
+ ## CURLOPT_STREAM_DEPENDS_E
+
+-This HTTP/2 stream depends on another exclusively. See
++**Deprecated option** This HTTP/2 stream depends on another exclusively. See
+ CURLOPT_STREAM_DEPENDS_E(3)
+
+ ## CURLOPT_STREAM_WEIGHT
+diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
+index 5e3e177dce..e0e8ef0c53 100644
+--- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
++++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS.md
+@@ -44,6 +44,10 @@ an error. It must be another easy handle, and it also needs to be a handle of
+ a transfer that is about to be sent over the same HTTP/2 connection for this
+ option to have an actual effect.
+
++Since version 8.21.0 setting this option no longer has an effect. HTTP/2
++stream dependencies were introduced in RFC 7540 and then later deprecated
++in RFC 9113.
++
+ # DEFAULT
+
+ NULL
+@@ -69,6 +73,10 @@ int main(void)
+ }
+ ~~~
+
++# DEPRECATED
++
++Deprecated since 8.21.0.
++
+ # %AVAILABILITY%
+
+ # RETURN VALUE
+diff --git a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
+index fe95ae8d71..fe8f97f950 100644
+--- a/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
++++ b/docs/libcurl/opts/CURLOPT_STREAM_DEPENDS_E.md
+@@ -47,6 +47,10 @@ an error. It must be another easy handle, and it also needs to be a handle of
+ a transfer that is about to be sent over the same HTTP/2 connection for this
+ option to have an actual effect.
+
++Since version 8.21.0 setting this option no longer has an effect. HTTP/2
++stream dependencies were introduced in RFC 7540 and then later deprecated
++in RFC 9113.
++
+ # DEFAULT
+
+ NULL
+@@ -72,6 +76,10 @@ int main(void)
+ }
+ ~~~
+
++# DEPRECATED
++
++Deprecated since 8.21.0.
++
+ # %AVAILABILITY%
+
+ # RETURN VALUE
+diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
+index e0e0a8e63a..2a045a82ed 100644
+--- a/docs/libcurl/symbols-in-versions
++++ b/docs/libcurl/symbols-in-versions
+@@ -878,8 +878,8 @@ CURLOPT_SSLKEYPASSWD 7.9.3 7.17.0
+ CURLOPT_SSLKEYTYPE 7.9.3
+ CURLOPT_SSLVERSION 7.1
+ CURLOPT_STDERR 7.1
+-CURLOPT_STREAM_DEPENDS 7.46.0
+-CURLOPT_STREAM_DEPENDS_E 7.46.0
++CURLOPT_STREAM_DEPENDS 7.46.0 8.21.0
++CURLOPT_STREAM_DEPENDS_E 7.46.0 8.21.0
+ CURLOPT_STREAM_WEIGHT 7.46.0
+ CURLOPT_SUPPRESS_CONNECT_HEADERS 7.54.0
+ CURLOPT_TCP_FASTOPEN 7.49.0
+diff --git a/include/curl/curl.h b/include/curl/curl.h
+index e755f098f2..d9ce7307e2 100644
+--- a/include/curl/curl.h
++++ b/include/curl/curl.h
+@@ -1980,10 +1980,12 @@ typedef enum {
+ CURLOPT(CURLOPT_STREAM_WEIGHT, CURLOPTTYPE_LONG, 239),
+
+ /* Set stream dependency on another curl handle */
+- CURLOPT(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240),
++ CURLOPTDEPRECATED(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240,
++ 8.21.0, "Has no function"),
+
+ /* Set E-xclusive stream dependency on another curl handle */
+- CURLOPT(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241),
++ CURLOPTDEPRECATED(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241,
++ 8.21.0, "Has no function"),
+
+ /* Do not send any tftp option requests to the server */
+ CURLOPT(CURLOPT_TFTP_NO_OPTIONS, CURLOPTTYPE_LONG, 242),
+diff --git a/lib/http2.c b/lib/http2.c
+index a8b8d5c52f..c3177b9294 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -1933,16 +1933,12 @@ static int sweight_in_effect(const struct Curl_easy *data)
+ * struct.
+ */
+
+-static void h2_pri_spec(struct cf_h2_ctx *ctx,
+- struct Curl_easy *data,
++static void h2_pri_spec(struct Curl_easy *data,
+ nghttp2_priority_spec *pri_spec)
+ {
+ struct Curl_data_priority *prio = &data->set.priority;
+- struct h2_stream_ctx *depstream = H2_STREAM_CTX(ctx, prio->parent);
+- int32_t depstream_id = depstream ? depstream->id : 0;
+- nghttp2_priority_spec_init(pri_spec, depstream_id,
+- sweight_wanted(data),
+- data->set.priority.exclusive);
++ nghttp2_priority_spec_init(pri_spec, 0,
++ sweight_wanted(data), FALSE);
+ data->state.priority = *prio;
+ }
+
+@@ -1960,13 +1956,11 @@ static CURLcode h2_progress_egress(struct Curl_cfilter *cf,
+ int rv = 0;
+
+ if(stream && stream->id > 0 &&
+- ((sweight_wanted(data) != sweight_in_effect(data)) ||
+- (data->set.priority.exclusive != data->state.priority.exclusive) ||
+- (data->set.priority.parent != data->state.priority.parent))) {
++ (sweight_wanted(data) != sweight_in_effect(data))) {
+ /* send new weight and/or dependency */
+ nghttp2_priority_spec pri_spec;
+
+- h2_pri_spec(ctx, data, &pri_spec);
++ h2_pri_spec(data, &pri_spec);
+ CURL_TRC_CF(data, cf, "[%d] Queuing PRIORITY", stream->id);
+ DEBUGASSERT(stream->id != -1);
+ rv = nghttp2_submit_priority(ctx->h2, NGHTTP2_FLAG_NONE,
+@@ -2274,7 +2268,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream,
+ goto out;
+ }
+
+- h2_pri_spec(ctx, data, &pri_spec);
++ h2_pri_spec(data, &pri_spec);
+ if(!nghttp2_session_check_request_allowed(ctx->h2))
+ CURL_TRC_CF(data, cf, "send request NOT allowed (via nghttp2)");
+
+diff --git a/lib/setopt.c b/lib/setopt.c
+index a74ca5e8f3..355a59c0a1 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -1508,13 +1508,10 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
+
+ #ifdef USE_HTTP2
+ case CURLOPT_STREAM_DEPENDS:
+- case CURLOPT_STREAM_DEPENDS_E: {
+- struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
+- if(!dep || GOOD_EASY_HANDLE(dep))
+- return Curl_data_priority_add_child(dep, data,
+- option == CURLOPT_STREAM_DEPENDS_E);
++ case CURLOPT_STREAM_DEPENDS_E:
++ /* not doing stream dependencies any longer, but accept options
++ * for backward compatibility */
+ break;
+- }
+ #endif
+
+ default:
+diff --git a/lib/url.c b/lib/url.c
+index fefc1a0518..900b0f7352 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -120,12 +120,6 @@
+ #include "smtp.h"
+ #include "ws.h"
+
+-#ifdef USE_NGHTTP2
+-static void data_priority_cleanup(struct Curl_easy *data);
+-#else
+-#define data_priority_cleanup(x)
+-#endif
+-
+ /* Some parts of the code (e.g. chunked encoding) assume this buffer has at
+ * more than just a few bytes to play with. Do not let it become too small or
+ * bad things will happen.
+@@ -282,8 +276,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
+ Curl_safefree(data->info.contenttype);
+ Curl_safefree(data->info.wouldredirect);
+
+- data_priority_cleanup(data);
+-
+ /* No longer a dirty share, if it exists */
+ if(data->share) {
+ Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
+@@ -3970,96 +3962,6 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
+
+ #if defined(USE_HTTP2) || defined(USE_HTTP3)
+
+-#ifdef USE_NGHTTP2
+-
+-static void priority_remove_child(struct Curl_easy *parent,
+- struct Curl_easy *child)
+-{
+- struct Curl_data_prio_node **pnext = &parent->set.priority.children;
+- struct Curl_data_prio_node *pnode = parent->set.priority.children;
+-
+- DEBUGASSERT(child->set.priority.parent == parent);
+- while(pnode && pnode->data != child) {
+- pnext = &pnode->next;
+- pnode = pnode->next;
+- }
+-
+- DEBUGASSERT(pnode);
+- if(pnode) {
+- *pnext = pnode->next;
+- curlx_free(pnode);
+- }
+-
+- child->set.priority.parent = 0;
+- child->set.priority.exclusive = FALSE;
+-}
+-
+-CURLcode Curl_data_priority_add_child(struct Curl_easy *parent,
+- struct Curl_easy *child,
+- bool exclusive)
+-{
+- if(child->set.priority.parent) {
+- priority_remove_child(child->set.priority.parent, child);
+- }
+-
+- if(parent) {
+- struct Curl_data_prio_node **tail;
+- struct Curl_data_prio_node *pnode;
+-
+- pnode = curlx_calloc(1, sizeof(*pnode));
+- if(!pnode)
+- return CURLE_OUT_OF_MEMORY;
+- pnode->data = child;
+-
+- if(parent->set.priority.children && exclusive) {
+- /* exclusive: move all existing children underneath the new child */
+- struct Curl_data_prio_node *node = parent->set.priority.children;
+- while(node) {
+- node->data->set.priority.parent = child;
+- node = node->next;
+- }
+-
+- tail = &child->set.priority.children;
+- while(*tail)
+- tail = &(*tail)->next;
+-
+- DEBUGASSERT(!*tail);
+- *tail = parent->set.priority.children;
+- parent->set.priority.children = 0;
+- }
+-
+- tail = &parent->set.priority.children;
+- while(*tail) {
+- (*tail)->data->set.priority.exclusive = FALSE;
+- tail = &(*tail)->next;
+- }
+-
+- DEBUGASSERT(!*tail);
+- *tail = pnode;
+- }
+-
+- child->set.priority.parent = parent;
+- child->set.priority.exclusive = exclusive;
+- return CURLE_OK;
+-}
+-
+-#endif /* USE_NGHTTP2 */
+-
+-#ifdef USE_NGHTTP2
+-static void data_priority_cleanup(struct Curl_easy *data)
+-{
+- while(data->set.priority.children) {
+- struct Curl_easy *tmp = data->set.priority.children->data;
+- priority_remove_child(data, tmp);
+- if(data->set.priority.parent)
+- Curl_data_priority_add_child(data->set.priority.parent, tmp, FALSE);
+- }
+-
+- if(data->set.priority.parent)
+- priority_remove_child(data->set.priority.parent, data);
+-}
+-#endif
+-
+ void Curl_data_priority_clear_state(struct Curl_easy *data)
+ {
+ memset(&data->state.priority, 0, sizeof(data->state.priority));
+diff --git a/lib/url.h b/lib/url.h
+index 3a8d57c377..ddac784e75 100644
+--- a/lib/url.h
++++ b/lib/url.h
+@@ -111,12 +111,4 @@ void Curl_data_priority_clear_state(struct Curl_easy *data);
+ #define Curl_data_priority_clear_state(x)
+ #endif /* USE_HTTP2 || USE_HTTP3 */
+
+-#ifdef USE_NGHTTP2
+-CURLcode Curl_data_priority_add_child(struct Curl_easy *parent,
+- struct Curl_easy *child,
+- bool exclusive);
+-#else
+-#define Curl_data_priority_add_child(x, y, z) CURLE_NOT_BUILT_IN
+-#endif
+-
+ #endif /* HEADER_CURL_URL_H */
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 1de8c4bfb1..7e36cc2336 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -864,27 +864,12 @@ struct auth {
+ should be RFC compliant */
+ };
+
+-#ifdef USE_NGHTTP2
+-struct Curl_data_prio_node {
+- struct Curl_data_prio_node *next;
+- struct Curl_easy *data;
+-};
+-#endif
+-
+ /**
+ * Priority information for an easy handle in relation to others
+ * on the same connection.
+ */
+ struct Curl_data_priority {
+-#ifdef USE_NGHTTP2
+- /* tree like dependencies only implemented in nghttp2 */
+- struct Curl_easy *parent;
+- struct Curl_data_prio_node *children;
+-#endif
+ int weight;
+-#ifdef USE_NGHTTP2
+- BIT(exclusive);
+-#endif
+ };
+
+ /* Timers */
diff --git a/0024-curl-8.18.0-CVE-2026-9079.patch b/0024-curl-8.18.0-CVE-2026-9079.patch
deleted file mode 100644
index 00beb51..0000000
--- a/0024-curl-8.18.0-CVE-2026-9079.patch
+++ /dev/null
@@ -1,286 +0,0 @@
-From 5a9084b780e028ac3bd44b76dc219e5383b2c2b8 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Wed, 20 May 2026 13:39:25 +0200
-Subject: [PATCH] setopt: clear proxy auth properly on NULL
-
-Verify NULLed proxy credentials with test1648
-
-Closes #21696
-
-(cherry picked from commit 88c7e16cceec816a2df45c899d49b1e85513f193)
----
- lib/setopt.c | 12 ++--
- tests/data/Makefile.am | 2 +-
- tests/data/test1648 | 63 +++++++++++++++++
- tests/libtest/Makefile.inc | 2 +-
- tests/libtest/lib1648.c | 135 +++++++++++++++++++++++++++++++++++++
- 5 files changed, 206 insertions(+), 8 deletions(-)
- create mode 100644 tests/data/test1648
- create mode 100644 tests/libtest/lib1648.c
-
-diff --git a/lib/setopt.c b/lib/setopt.c
-index 089390030c..8119e1c590 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -2008,16 +2008,16 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
- result = setstropt_userpwd(ptr, &u, &p);
-
- /* URL decode the components */
-- if(!result && u) {
-+ if(!result) {
- Curl_safefree(s->str[STRING_PROXYUSERNAME]);
-- result = Curl_urldecode(u, 0, &s->str[STRING_PROXYUSERNAME], NULL,
-- REJECT_ZERO);
-- }
-- if(!result && p) {
- Curl_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;
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index e326ff7eff..84ed10b3cf 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -212,7 +212,7 @@ test1580 test1581 test1582 test1583 test1584 test1585 \
- test1588 \
- test1629 \
- \
--test1647 \
-+test1647 test1648 \
- \
- test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
- test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
-diff --git a/tests/data/test1648 b/tests/data/test1648
-new file mode 100644
-index 0000000000..623f3c9a81
---- /dev/null
-+++ b/tests/data/test1648
-@@ -0,0 +1,63 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+HTTP GET
-+HTTP proxy
-+HTTP proxy auth
-+</keywords>
-+</info>
-+
-+# Server-side
-+<reply>
-+
-+# this is returned first since we get no proxy-auth
-+<data crlf="headers" nocheck="yes">
-+HTTP/1.1 407 Authorization Required to proxy me my dear
-+Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
-+Content-Length: 33
-+
-+And you should ignore this data.
-+</data>
-+
-+</reply>
-+
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+# tool is what to use instead of 'curl'
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<features>
-+proxy
-+</features>
-+<name>
-+HTTP proxy with auth, change proxy, clear auth
-+</name>
-+<command>
-+%HOSTIP %HTTPPORT
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+<protocol crlf="headers">
-+GET http://example.com/ HTTP/1.1
-+Host: example.com
-+Proxy-Authorization: Basic %b64[victim:secret]b64%
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+GET http://example.com/ HTTP/1.1
-+Host: example.com
-+Accept: */*
-+Proxy-Connection: Keep-Alive
-+
-+</protocol>
-+
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index 82740ef1b0..7eb0616469 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -100,7 +100,7 @@ TESTS_C = \
- lib1582.c lib1588.c \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
-- lib1647.c lib1649.c \
-+ lib1647.c lib1648.c lib1649.c \
- lib1662.c \
- lib1686.c \
- lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
-diff --git a/tests/libtest/lib1648.c b/tests/libtest/lib1648.c
-new file mode 100644
-index 0000000000..e97b2bdc88
---- /dev/null
-+++ b/tests/libtest/lib1648.c
-@@ -0,0 +1,135 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+/*
-+ * URL = host
-+ * arg2 = port
-+ */
-+
-+#include "first.h"
-+
-+/* this is meant to pick up the proxy from the environment variable */
-+static CURLcode init1648(CURL *curl, const char *url, const char *proxy)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
-+ if(result)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(result)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return result; /* failure */
-+}
-+
-+static CURLcode run1648(CURL *curl, const char *url, const char *userpwd)
-+{
-+ CURLcode result = CURLE_OK;
-+
-+ result = init1648(curl, url, userpwd);
-+ if(result)
-+ return result;
-+
-+ return curl_easy_perform(curl);
-+}
-+
-+#define GET_THIS "http://example.com/"
-+
-+/*
-+ * First get the URL over 'firstproxy' with auth.
-+ * Then clear the auth and get the URL again over 'secondproxy'.
-+ */
-+static CURLcode test_lib1648(const char *hostip)
-+{
-+ CURLcode result = CURLE_OK;
-+ CURL *curl = NULL;
-+ struct curl_slist *host = NULL;
-+ struct curl_slist *host2 = NULL;
-+ char proxy1_resolve[128];
-+ char proxy2_resolve[128];
-+ char proxy1_connect[128];
-+ char proxy2_connect[128];
-+
-+ curl_msnprintf(proxy1_resolve, sizeof(proxy1_resolve),
-+ "firstproxy:%s:%s", libtest_arg2, hostip);
-+ curl_msnprintf(proxy2_resolve, sizeof(proxy2_resolve),
-+ "secondproxy:%s:%s", libtest_arg2, hostip);
-+
-+ /* we connect to the fake host name but the right port number */
-+ curl_msnprintf(proxy1_connect, sizeof(proxy1_connect),
-+ "firstproxy:%s", libtest_arg2);
-+ curl_msnprintf(proxy2_connect, sizeof(proxy2_connect),
-+ "secondproxy:%s", libtest_arg2);
-+
-+ res_global_init(CURL_GLOBAL_ALL);
-+ if(result)
-+ return result;
-+
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
-+ curl_global_cleanup();
-+ return TEST_ERR_MAJOR_BAD;
-+ }
-+
-+ host = curl_slist_append(NULL, proxy1_resolve);
-+ if(!host)
-+ goto test_cleanup;
-+ host2 = curl_slist_append(host, proxy2_resolve);
-+ if(!host2)
-+ goto test_cleanup;
-+ host = host2;
-+
-+ start_test_timing();
-+
-+ easy_setopt(curl, CURLOPT_RESOLVE, host);
-+ easy_setopt(curl, CURLOPT_PROXYUSERPWD, "victim:secret");
-+
-+ curl_mprintf("--- First get over %s\n", proxy1_connect);
-+ result = run1648(curl, GET_THIS, proxy1_connect);
-+ if(result)
-+ goto test_cleanup;
-+
-+ easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
-+
-+ curl_mprintf("--- Then over '%s'\n", proxy2_connect);
-+ result = run1648(curl, GET_THIS, proxy2_connect);
-+
-+test_cleanup:
-+
-+ /* proper cleanup sequence - type PB */
-+
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ curl_slist_free_all(host);
-+ return result;
-+}
---
-2.55.0
-
diff --git a/0024-ssl-native_ca_store-always-reinit.patch b/0024-ssl-native_ca_store-always-reinit.patch
new file mode 100644
index 0000000..f6350e8
--- /dev/null
+++ b/0024-ssl-native_ca_store-always-reinit.patch
@@ -0,0 +1,121 @@
+From 7a29380c7b35a5b2de9b647325f91068f30f4298 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 8 Jun 2026 10:11:30 +0200
+Subject: [PATCH] ssl native_ca_store: always reinit
+
+Add bit `native_ca_store_opt` to keep the setting of
+CURLOPT_(PROXY_)SSL_OPTIONS and use that to calculate every easy
+transfer if a native CA store shall be used or not.
+
+This avoids `native_ca_store` getting stuck on TRUE after being set
+once.
+
+Closes #21902
+
+(cherry picked from commit d69bfad3fa3daf5e72331f6870667607828d5891)
+---
+ lib/doh.c | 3 ++-
+ lib/setopt.c | 20 ++------------------
+ lib/vtls/vtls.c | 19 +++++++++++++++++++
+ 3 files changed, 23 insertions(+), 19 deletions(-)
+
+diff --git a/lib/doh.c b/lib/doh.c
+index 9052fab26b..13497e0253 100644
+--- a/lib/doh.c
++++ b/lib/doh.c
+@@ -400,7 +400,8 @@ static CURLcode doh_probe_run(struct Curl_easy *data,
+ }
+
+ (void)curl_easy_setopt(doh, CURLOPT_SSL_OPTIONS,
+- (long)data->set.ssl.primary.ssl_options);
++ ((long)data->set.ssl.primary.ssl_options &
++ ~CURLSSLOPT_AUTO_CLIENT_CERT));
+
+ doh->state.internal = TRUE;
+ doh->master_mid = data->mid; /* master transfer of this one */
+diff --git a/lib/setopt.c b/lib/setopt.c
+index 355a59c0a1..089390030c 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -414,22 +414,6 @@ static CURLcode setopt_RTSP_REQUEST(struct Curl_easy *data, long arg)
+ }
+ #endif /* !CURL_DISABLE_RTSP */
+
+-#ifdef USE_SSL
+-static void set_ssl_options(struct ssl_config_data *ssl,
+- struct ssl_primary_config *config,
+- long arg)
+-{
+- config->ssl_options = (unsigned char)(arg & 0xff);
+- ssl->enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST);
+- ssl->no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
+- ssl->no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
+- ssl->revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
+- ssl->native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
+- ssl->auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT);
+- ssl->earlydata = !!(arg & CURLSSLOPT_EARLYDATA);
+-}
+-#endif
+-
+ static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option,
+ long arg, bool *set)
+ {
+@@ -1127,12 +1111,12 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
+ s->use_ssl = (unsigned char)arg;
+ break;
+ case CURLOPT_SSL_OPTIONS:
+- set_ssl_options(&s->ssl, &s->ssl.primary, arg);
++ s->ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
+ break;
+
+ #ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSL_OPTIONS:
+- set_ssl_options(&s->proxy_ssl, &s->proxy_ssl.primary, arg);
++ s->proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff);
+ break;
+ #endif
+
+diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
+index be0c032bff..851bc341a9 100644
+--- a/lib/vtls/vtls.c
++++ b/lib/vtls/vtls.c
+@@ -286,6 +286,21 @@ static void free_primary_ssl_config(struct ssl_primary_config *sslc)
+ #endif
+ }
+
++static void ssl_easy_config_compl_options(struct ssl_config_data *sslc)
++{
++ unsigned char options = sslc->primary.ssl_options;
++ /* If set via CURLOPT_(PROXY_)SSL_OPTIONS, we definitely use it.
++ * If not, we switch it on for supported backends if no custom
++ * ca settings exist. */
++ sslc->native_ca_store = !!(options & CURLSSLOPT_NATIVE_CA);
++ sslc->enable_beast = !!(options & CURLSSLOPT_ALLOW_BEAST);
++ sslc->no_partialchain = !!(options & CURLSSLOPT_NO_PARTIALCHAIN);
++ sslc->no_revoke = !!(options & CURLSSLOPT_NO_REVOKE);
++ sslc->revoke_best_effort = !!(options & CURLSSLOPT_REVOKE_BEST_EFFORT);
++ sslc->auto_client_cert = !!(options & CURLSSLOPT_AUTO_CLIENT_CERT);
++ sslc->earlydata = !!(options & CURLSSLOPT_EARLYDATA);
++}
++
+ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ {
+ struct ssl_config_data *sslc = &data->set.ssl;
+@@ -294,6 +309,8 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ CURLcode result;
+ #endif
+
++ ssl_easy_config_compl_options(sslc);
++
+ if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
+ #ifdef USE_APPLE_SECTRUST
+ if(!sslc->custom_capath && !sslc->custom_cafile && !sslc->custom_cablob)
+@@ -340,6 +357,8 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+
+ #ifndef CURL_DISABLE_PROXY
+ sslc = &data->set.proxy_ssl;
++ ssl_easy_config_compl_options(sslc);
++
+ if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
+ #ifdef USE_APPLE_SECTRUST
+ if(!sslc->custom_capath && !sslc->custom_cafile && !sslc->custom_cablob)
diff --git a/0025-curl-8.18.0-CVE-2026-8458.patch b/0025-curl-8.18.0-CVE-2026-8458.patch
deleted file mode 100644
index 0708bbc..0000000
--- a/0025-curl-8.18.0-CVE-2026-8458.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 179746545e59d241dfb9901588a60bbd100397ea Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Wed, 13 May 2026 12:02:48 +0200
-Subject: [PATCH] creds: add sasl service name
-
-The SASL service name, used in authentication, is part of curl's credentials
-when authenticating to a server/proxy. Make it part of the connection's
-credentials so that connection reuse is only allowed when the service
-name matches.
-
-Closes #21585
-
-(cherry picked from commit 5e99b73cf441d9c369768b9cd48b5389b9a2503d)
-Co-authored-by: Cursor <cursoragent@cursor.com>
----
- lib/url.c | 36 +++++++++++++++++++++++++++++++-----
- lib/urldata.h | 2 ++
- 2 files changed, 33 insertions(+), 5 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index 900b0f7352..c3fb1439ca 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -538,6 +538,8 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)
- Curl_safefree(conn->sasl_authzid);
- Curl_safefree(conn->options);
- Curl_safefree(conn->oauth_bearer);
-+ Curl_safefree(conn->sasl_service);
-+ Curl_safefree(conn->proxy_service);
- Curl_safefree(conn->host.rawalloc); /* hostname buffer */
- Curl_safefree(conn->conn_to_host.rawalloc); /* hostname buffer */
- Curl_safefree(conn->hostname_resolve);
-@@ -1032,7 +1034,8 @@ static bool url_match_auth(struct connectdata *conn,
- if(Curl_timestrcmp(m->needle->user, conn->user) ||
- Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
- Curl_timestrcmp(m->needle->sasl_authzid, conn->sasl_authzid) ||
-- Curl_timestrcmp(m->needle->oauth_bearer, conn->oauth_bearer)) {
-+ Curl_timestrcmp(m->needle->oauth_bearer, conn->oauth_bearer) ||
-+ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service)) {
- /* one of them was different */
- return FALSE;
- }
-@@ -1114,7 +1117,8 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
- partway through a handshake!) */
- if(m->want_ntlm_http) {
- if(Curl_timestrcmp(m->needle->user, conn->user) ||
-- Curl_timestrcmp(m->needle->passwd, conn->passwd)) {
-+ Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
-+ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service)) {
-
- /* we prefer a credential match, but this is at least a connection
- that can be reused and "upgraded" to NTLM */
-@@ -1139,7 +1143,9 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
- if(Curl_timestrcmp(m->needle->http_proxy.user,
- conn->http_proxy.user) ||
- Curl_timestrcmp(m->needle->http_proxy.passwd,
-- conn->http_proxy.passwd))
-+ conn->http_proxy.passwd) ||
-+ Curl_timestrcmp(m->needle->proxy_service,
-+ conn->proxy_service))
- return FALSE;
- }
- else if(conn->proxy_ntlm_state != NTLMSTATE_NONE) {
-@@ -1180,7 +1186,8 @@ static bool url_match_auth_nego(struct connectdata *conn,
- so that we can reuse Negotiate connections if possible. */
- if(m->want_nego_http) {
- if(Curl_timestrcmp(m->needle->user, conn->user) ||
-- Curl_timestrcmp(m->needle->passwd, conn->passwd))
-+ Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
-+ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service))
- return FALSE;
- }
- else if(conn->http_negotiate_state != GSS_AUTHNONE) {
-@@ -1199,7 +1206,9 @@ static bool url_match_auth_nego(struct connectdata *conn,
- if(Curl_timestrcmp(m->needle->http_proxy.user,
- conn->http_proxy.user) ||
- Curl_timestrcmp(m->needle->http_proxy.passwd,
-- conn->http_proxy.passwd))
-+ conn->http_proxy.passwd) ||
-+ Curl_timestrcmp(m->needle->proxy_service,
-+ conn->proxy_service))
- return FALSE;
- }
- else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
-@@ -3505,6 +3514,23 @@ static CURLcode create_conn(struct Curl_easy *data,
- }
- }
-
-+ if(data->set.str[STRING_SERVICE_NAME]) {
-+ conn->sasl_service = curlx_strdup(data->set.str[STRING_SERVICE_NAME]);
-+ if(!conn->sasl_service) {
-+ result = CURLE_OUT_OF_MEMORY;
-+ goto out;
-+ }
-+ }
-+
-+ if(data->set.str[STRING_PROXY_SERVICE_NAME]) {
-+ conn->proxy_service =
-+ curlx_strdup(data->set.str[STRING_PROXY_SERVICE_NAME]);
-+ if(!conn->proxy_service) {
-+ result = CURLE_OUT_OF_MEMORY;
-+ goto out;
-+ }
-+ }
-+
- #ifdef USE_UNIX_SOCKETS
- if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
- conn->unix_domain_socket =
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 7e36cc2336..318dfdb84c 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -637,6 +637,8 @@ struct connectdata {
- char *options; /* options string, allocated */
- char *sasl_authzid; /* authorization identity string, allocated */
- char *oauth_bearer; /* OAUTH2 bearer, allocated */
-+ char *sasl_service; /* SASL service name, allocated */
-+ char *proxy_service; /* proxy SASL service name, allocated */
- struct curltime created; /* creation time */
- struct curltime lastused; /* when returned to the connection poolas idle */
-
---
-2.55.0
-
diff --git a/0025-setopt-clear-proxy-auth-properly-on-NULL.patch b/0025-setopt-clear-proxy-auth-properly-on-NULL.patch
new file mode 100644
index 0000000..b000870
--- /dev/null
+++ b/0025-setopt-clear-proxy-auth-properly-on-NULL.patch
@@ -0,0 +1,283 @@
+From 39234697a40ed231592c34a5c21849bb97ad4ee3 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Wed, 20 May 2026 13:39:25 +0200
+Subject: [PATCH] setopt: clear proxy auth properly on NULL
+
+Verify NULLed proxy credentials with test1648
+
+Closes #21696
+
+(cherry picked from commit 88c7e16cceec816a2df45c899d49b1e85513f193)
+---
+ lib/setopt.c | 12 ++--
+ tests/data/Makefile.am | 2 +-
+ tests/data/test1648 | 63 +++++++++++++++++
+ tests/libtest/Makefile.inc | 2 +-
+ tests/libtest/lib1648.c | 135 +++++++++++++++++++++++++++++++++++++
+ 5 files changed, 206 insertions(+), 8 deletions(-)
+ create mode 100644 tests/data/test1648
+ create mode 100644 tests/libtest/lib1648.c
+
+diff --git a/lib/setopt.c b/lib/setopt.c
+index 089390030c..8119e1c590 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -2008,16 +2008,16 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
+ result = setstropt_userpwd(ptr, &u, &p);
+
+ /* URL decode the components */
+- if(!result && u) {
++ if(!result) {
+ Curl_safefree(s->str[STRING_PROXYUSERNAME]);
+- result = Curl_urldecode(u, 0, &s->str[STRING_PROXYUSERNAME], NULL,
+- REJECT_ZERO);
+- }
+- if(!result && p) {
+ Curl_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;
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index e326ff7eff..84ed10b3cf 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -212,7 +212,7 @@ test1580 test1581 test1582 test1583 test1584 test1585 \
+ test1588 \
+ test1629 \
+ \
+-test1647 \
++test1647 test1648 \
+ \
+ test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
+ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+diff --git a/tests/data/test1648 b/tests/data/test1648
+new file mode 100644
+index 0000000000..623f3c9a81
+--- /dev/null
++++ b/tests/data/test1648
+@@ -0,0 +1,63 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++HTTP GET
++HTTP proxy
++HTTP proxy auth
++</keywords>
++</info>
++
++# Server-side
++<reply>
++
++# this is returned first since we get no proxy-auth
++<data crlf="headers" nocheck="yes">
++HTTP/1.1 407 Authorization Required to proxy me my dear
++Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345"
++Content-Length: 33
++
++And you should ignore this data.
++</data>
++
++</reply>
++
++# Client-side
++<client>
++<server>
++http
++</server>
++# tool is what to use instead of 'curl'
++<tool>
++lib%TESTNUMBER
++</tool>
++<features>
++proxy
++</features>
++<name>
++HTTP proxy with auth, change proxy, clear auth
++</name>
++<command>
++%HOSTIP %HTTPPORT
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++<protocol crlf="headers">
++GET http://example.com/ HTTP/1.1
++Host: example.com
++Proxy-Authorization: Basic %b64[victim:secret]b64%
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++GET http://example.com/ HTTP/1.1
++Host: example.com
++Accept: */*
++Proxy-Connection: Keep-Alive
++
++</protocol>
++
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index 82740ef1b0..7eb0616469 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -100,7 +100,7 @@ TESTS_C = \
+ lib1582.c lib1588.c \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
+- lib1647.c lib1649.c \
++ lib1647.c lib1648.c lib1649.c \
+ lib1662.c \
+ lib1686.c \
+ lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c \
+diff --git a/tests/libtest/lib1648.c b/tests/libtest/lib1648.c
+new file mode 100644
+index 0000000000..e97b2bdc88
+--- /dev/null
++++ b/tests/libtest/lib1648.c
+@@ -0,0 +1,135 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++/*
++ * URL = host
++ * arg2 = port
++ */
++
++#include "first.h"
++
++/* this is meant to pick up the proxy from the environment variable */
++static CURLcode init1648(CURL *curl, const char *url, const char *proxy)
++{
++ CURLcode result = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
++ if(result)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(result)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return result; /* failure */
++}
++
++static CURLcode run1648(CURL *curl, const char *url, const char *userpwd)
++{
++ CURLcode result = CURLE_OK;
++
++ result = init1648(curl, url, userpwd);
++ if(result)
++ return result;
++
++ return curl_easy_perform(curl);
++}
++
++#define GET_THIS "http://example.com/"
++
++/*
++ * First get the URL over 'firstproxy' with auth.
++ * Then clear the auth and get the URL again over 'secondproxy'.
++ */
++static CURLcode test_lib1648(const char *hostip)
++{
++ CURLcode result = CURLE_OK;
++ CURL *curl = NULL;
++ struct curl_slist *host = NULL;
++ struct curl_slist *host2 = NULL;
++ char proxy1_resolve[128];
++ char proxy2_resolve[128];
++ char proxy1_connect[128];
++ char proxy2_connect[128];
++
++ curl_msnprintf(proxy1_resolve, sizeof(proxy1_resolve),
++ "firstproxy:%s:%s", libtest_arg2, hostip);
++ curl_msnprintf(proxy2_resolve, sizeof(proxy2_resolve),
++ "secondproxy:%s:%s", libtest_arg2, hostip);
++
++ /* we connect to the fake host name but the right port number */
++ curl_msnprintf(proxy1_connect, sizeof(proxy1_connect),
++ "firstproxy:%s", libtest_arg2);
++ curl_msnprintf(proxy2_connect, sizeof(proxy2_connect),
++ "secondproxy:%s", libtest_arg2);
++
++ res_global_init(CURL_GLOBAL_ALL);
++ if(result)
++ return result;
++
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_mfprintf(stderr, "curl_easy_init() failed\n");
++ curl_global_cleanup();
++ return TEST_ERR_MAJOR_BAD;
++ }
++
++ host = curl_slist_append(NULL, proxy1_resolve);
++ if(!host)
++ goto test_cleanup;
++ host2 = curl_slist_append(host, proxy2_resolve);
++ if(!host2)
++ goto test_cleanup;
++ host = host2;
++
++ start_test_timing();
++
++ easy_setopt(curl, CURLOPT_RESOLVE, host);
++ easy_setopt(curl, CURLOPT_PROXYUSERPWD, "victim:secret");
++
++ curl_mprintf("--- First get over %s\n", proxy1_connect);
++ result = run1648(curl, GET_THIS, proxy1_connect);
++ if(result)
++ goto test_cleanup;
++
++ easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
++
++ curl_mprintf("--- Then over '%s'\n", proxy2_connect);
++ result = run1648(curl, GET_THIS, proxy2_connect);
++
++test_cleanup:
++
++ /* proper cleanup sequence - type PB */
++
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ curl_slist_free_all(host);
++ return result;
++}
diff --git a/0026-creds-add-sasl-service-name.patch b/0026-creds-add-sasl-service-name.patch
new file mode 100644
index 0000000..a4c3052
--- /dev/null
+++ b/0026-creds-add-sasl-service-name.patch
@@ -0,0 +1,121 @@
+From 3d796b28ed407fa9ca841c4d94f7ea1c3efabb27 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Wed, 13 May 2026 12:02:48 +0200
+Subject: [PATCH] creds: add sasl service name
+
+The SASL service name, used in authentication, is part of curl's credentials
+when authenticating to a server/proxy. Make it part of the connection's
+credentials so that connection reuse is only allowed when the service
+name matches.
+
+Closes #21585
+
+(cherry picked from commit 5e99b73cf441d9c369768b9cd48b5389b9a2503d)
+Co-authored-by: Cursor <cursoragent@cursor.com>
+---
+ lib/url.c | 36 +++++++++++++++++++++++++++++++-----
+ lib/urldata.h | 2 ++
+ 2 files changed, 33 insertions(+), 5 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 900b0f7352..c3fb1439ca 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -538,6 +538,8 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)
+ Curl_safefree(conn->sasl_authzid);
+ Curl_safefree(conn->options);
+ Curl_safefree(conn->oauth_bearer);
++ Curl_safefree(conn->sasl_service);
++ Curl_safefree(conn->proxy_service);
+ Curl_safefree(conn->host.rawalloc); /* hostname buffer */
+ Curl_safefree(conn->conn_to_host.rawalloc); /* hostname buffer */
+ Curl_safefree(conn->hostname_resolve);
+@@ -1032,7 +1034,8 @@ static bool url_match_auth(struct connectdata *conn,
+ if(Curl_timestrcmp(m->needle->user, conn->user) ||
+ Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
+ Curl_timestrcmp(m->needle->sasl_authzid, conn->sasl_authzid) ||
+- Curl_timestrcmp(m->needle->oauth_bearer, conn->oauth_bearer)) {
++ Curl_timestrcmp(m->needle->oauth_bearer, conn->oauth_bearer) ||
++ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service)) {
+ /* one of them was different */
+ return FALSE;
+ }
+@@ -1114,7 +1117,8 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
+ partway through a handshake!) */
+ if(m->want_ntlm_http) {
+ if(Curl_timestrcmp(m->needle->user, conn->user) ||
+- Curl_timestrcmp(m->needle->passwd, conn->passwd)) {
++ Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
++ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service)) {
+
+ /* we prefer a credential match, but this is at least a connection
+ that can be reused and "upgraded" to NTLM */
+@@ -1139,7 +1143,9 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
+ if(Curl_timestrcmp(m->needle->http_proxy.user,
+ conn->http_proxy.user) ||
+ Curl_timestrcmp(m->needle->http_proxy.passwd,
+- conn->http_proxy.passwd))
++ conn->http_proxy.passwd) ||
++ Curl_timestrcmp(m->needle->proxy_service,
++ conn->proxy_service))
+ return FALSE;
+ }
+ else if(conn->proxy_ntlm_state != NTLMSTATE_NONE) {
+@@ -1180,7 +1186,8 @@ static bool url_match_auth_nego(struct connectdata *conn,
+ so that we can reuse Negotiate connections if possible. */
+ if(m->want_nego_http) {
+ if(Curl_timestrcmp(m->needle->user, conn->user) ||
+- Curl_timestrcmp(m->needle->passwd, conn->passwd))
++ Curl_timestrcmp(m->needle->passwd, conn->passwd) ||
++ Curl_timestrcmp(m->needle->sasl_service, conn->sasl_service))
+ return FALSE;
+ }
+ else if(conn->http_negotiate_state != GSS_AUTHNONE) {
+@@ -1199,7 +1206,9 @@ static bool url_match_auth_nego(struct connectdata *conn,
+ if(Curl_timestrcmp(m->needle->http_proxy.user,
+ conn->http_proxy.user) ||
+ Curl_timestrcmp(m->needle->http_proxy.passwd,
+- conn->http_proxy.passwd))
++ conn->http_proxy.passwd) ||
++ Curl_timestrcmp(m->needle->proxy_service,
++ conn->proxy_service))
+ return FALSE;
+ }
+ else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
+@@ -3505,6 +3514,23 @@ static CURLcode create_conn(struct Curl_easy *data,
+ }
+ }
+
++ if(data->set.str[STRING_SERVICE_NAME]) {
++ conn->sasl_service = curlx_strdup(data->set.str[STRING_SERVICE_NAME]);
++ if(!conn->sasl_service) {
++ result = CURLE_OUT_OF_MEMORY;
++ goto out;
++ }
++ }
++
++ if(data->set.str[STRING_PROXY_SERVICE_NAME]) {
++ conn->proxy_service =
++ curlx_strdup(data->set.str[STRING_PROXY_SERVICE_NAME]);
++ if(!conn->proxy_service) {
++ result = CURLE_OUT_OF_MEMORY;
++ goto out;
++ }
++ }
++
+ #ifdef USE_UNIX_SOCKETS
+ if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
+ conn->unix_domain_socket =
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 7e36cc2336..318dfdb84c 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -637,6 +637,8 @@ struct connectdata {
+ char *options; /* options string, allocated */
+ char *sasl_authzid; /* authorization identity string, allocated */
+ char *oauth_bearer; /* OAUTH2 bearer, allocated */
++ char *sasl_service; /* SASL service name, allocated */
++ char *proxy_service; /* proxy SASL service name, allocated */
+ struct curltime created; /* creation time */
+ struct curltime lastused; /* when returned to the connection poolas idle */
+
diff --git a/0026-curl-8.18.0-CVE-2026-18924.patch b/0026-curl-8.18.0-CVE-2026-18924.patch
deleted file mode 100644
index c6285ec..0000000
--- a/0026-curl-8.18.0-CVE-2026-18924.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 9a23169d37eb22cf3a05b6c00b9bcbaad938ca66 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Wed, 5 Aug 2026 10:02:53 +0200
-Subject: [PATCH] http2: make server push transfers inherit share from parent
-
-Reported-by: Stephan Zeisberg
-Closes #22488
-
-(cherry picked from commit 90325ff0444cbdff368bda5d26d6405a0bb6ee43)
----
- lib/http2.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/lib/http2.c b/lib/http2.c
-index c3177b9294..ecf10fe369 100644
---- a/lib/http2.c
-+++ b/lib/http2.c
-@@ -870,6 +870,8 @@ static struct Curl_easy *h2_duphandle(struct Curl_cfilter *cf,
- struct h2_stream_ctx *second_stream;
- http2_data_setup(cf, second, &second_stream);
- second->state.priority.weight = data->state.priority.weight;
-+ if(data->share)
-+ (void)curl_easy_setopt(second, CURLOPT_SHARE, data->share);
- }
- return second;
- }
---
-2.55.0
-
diff --git a/0027-curl-8.18.0-CVE-2026-80255.patch b/0027-curl-8.18.0-CVE-2026-80255.patch
deleted file mode 100644
index 0adf466..0000000
--- a/0027-curl-8.18.0-CVE-2026-80255.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 910fcaf795c37976e3bed67402c1674cff5a620b Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 27 Aug 2026 08:33:30 +0200
-Subject: [PATCH] cookie: improve TAB handling
-
-For entries with a leading tab. Verified in test 2885.
-
-Also stop exempting TAB from invalid_octets(), so cookies with a TAB
-in the name or value are properly rejected. This makes the separate
-memchr TAB check redundant.
-
-Reported-by: Stanislav Fort
-Closes #22699
-
-(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
-(cherry picked from commit 67300814294ab0aa311b8568b460619ecc522949)
----
- lib/cookie.c | 13 ++++---------
- tests/data/Makefile.am | 2 +-
- tests/data/test2885 | 52 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 57 insertions(+), 10 deletions(-)
- create mode 100644 tests/data/test2885
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index 38edf4a860..d7f3b2e1a4 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -355,9 +355,9 @@ static bool bad_domain(const char *domain, size_t len)
- static bool invalid_octets(const char *ptr, size_t len)
- {
- const unsigned char *p = (const unsigned char *)ptr;
-- /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */
-+ /* Reject all bytes \x01 - \x1f + \x7f */
- while(len && *p) {
-- if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f))
-+ if((*p < 0x20) || (*p == 0x7f))
- return TRUE;
- p++;
- len--;
-@@ -455,7 +455,7 @@ parse_cookie_header(struct Curl_easy *data,
- struct Curl_str val;
-
- /* we have a <name>=<value> pair or a stand-alone word here */
-- if(!curlx_str_cspn(&ptr, &name, ";\t\r\n=")) {
-+ if(!curlx_str_cspn(&ptr, &name, ";\r\n=")) {
- bool sep = FALSE;
- curlx_str_trimblanks(&name);
-
-@@ -493,12 +493,7 @@ parse_cookie_header(struct Curl_easy *data,
- return CURLE_OK;
- }
-
-- /* Reject cookies with a TAB inside the value */
-- if(curlx_strlen(&val) &&
-- memchr(curlx_str(&val), '\t', curlx_strlen(&val))) {
-- infof(data, "cookie contains TAB, dropping");
-- return CURLE_OK;
-- }
-+ /* TAB is now rejected by invalid_octets() above */
-
- /* Check if we have a reserved prefix set. */
- if(!strncmp("__Secure-", curlx_str(&name), 9))
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 84ed10b3cf..8b448cfcca 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -275,7 +275,7 @@ test2600 test2601 test2602 test2603 test2604 test2605 \
- test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 \
- test2708 test2709 test2710 test2711 test2712 test2713 test2714 test2715 \
- test2716 test2717 test2718 test2719 test2720 test2721 test2722 test2723 \
--\
-+test2885 \
- test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
- test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
- test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
-diff --git a/tests/data/test2885 b/tests/data/test2885
-new file mode 100644
-index 0000000000..456224fdc5
---- /dev/null
-+++ b/tests/data/test2885
-@@ -0,0 +1,52 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+cookies
-+</keywords>
-+</info>
-+
-+<reply>
-+<data crlf="headers">
-+HTTP/1.1 200 OK
-+Content-Length: 0
-+Set-Cookie: thisis=SECRET;%TABSecure
-+Set-Cookie: also=notab; Secure
-+
-+</data>
-+</reply>
-+
-+<client>
-+<features>
-+cookies
-+</features>
-+<server>
-+https
-+</server>
-+<name>
-+Cookies with TAB before 'secure'
-+</name>
-+<command>
-+https://cookie.example:%HTTPSPORT/%TESTNUMBER -c %LOGDIR/cookies.txt --resolve cookie.example:%HTTPSPORT:%HOSTIP --insecure
-+</command>
-+</client>
-+
-+<verify>
-+<protocol crlf="headers">
-+GET /%TESTNUMBER HTTP/1.1
-+Host: cookie.example:%HTTPSPORT
-+User-Agent: curl/%VERSION
-+Accept: */*
-+
-+</protocol>
-+<file name="%LOGDIR/cookies.txt" mode="text">
-+# Netscape HTTP Cookie File
-+# https://curl.se/docs/http-cookies.html
-+# This file was generated by libcurl! Edit at your own risk.
-+
-+cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABalso%TABnotab
-+cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABthisis%TABSECRET
-+</file>
-+</verify>
-+</testcase>
---
-2.55.0
diff --git a/0027-http2-make-server-push-transfers-inherit-share-from-.patch b/0027-http2-make-server-push-transfers-inherit-share-from-.patch
new file mode 100644
index 0000000..b187d31
--- /dev/null
+++ b/0027-http2-make-server-push-transfers-inherit-share-from-.patch
@@ -0,0 +1,26 @@
+From 0f01ffd0232ba2dd9e9ddaf91ea9a8b6c72911c0 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Wed, 5 Aug 2026 10:02:53 +0200
+Subject: [PATCH] http2: make server push transfers inherit share from parent
+
+Reported-by: Stephan Zeisberg
+Closes #22488
+
+(cherry picked from commit 90325ff0444cbdff368bda5d26d6405a0bb6ee43)
+---
+ lib/http2.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lib/http2.c b/lib/http2.c
+index c3177b9294..ecf10fe369 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -870,6 +870,8 @@ static struct Curl_easy *h2_duphandle(struct Curl_cfilter *cf,
+ struct h2_stream_ctx *second_stream;
+ http2_data_setup(cf, second, &second_stream);
+ second->state.priority.weight = data->state.priority.weight;
++ if(data->share)
++ (void)curl_easy_setopt(second, CURLOPT_SHARE, data->share);
+ }
+ return second;
+ }
diff --git a/0028-cookie-improve-TAB-handling.patch b/0028-cookie-improve-TAB-handling.patch
new file mode 100644
index 0000000..86626ac
--- /dev/null
+++ b/0028-cookie-improve-TAB-handling.patch
@@ -0,0 +1,133 @@
+From 7217863285c243fe20dc8ad0f3998041b667f40c Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Thu, 27 Aug 2026 08:33:30 +0200
+Subject: [PATCH] cookie: improve TAB handling
+
+For entries with a leading tab. Verified in test 2885.
+
+Also stop exempting TAB from invalid_octets(), so cookies with a TAB
+in the name or value are properly rejected. This makes the separate
+memchr TAB check redundant.
+
+Reported-by: Stanislav Fort
+Closes #22699
+
+(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
+(cherry picked from commit 67300814294ab0aa311b8568b460619ecc522949)
+---
+ lib/cookie.c | 13 ++++-------
+ tests/data/Makefile.am | 2 +-
+ tests/data/test2885 | 52 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 57 insertions(+), 10 deletions(-)
+ create mode 100644 tests/data/test2885
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index 38edf4a860..1eaf72a4a5 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -355,9 +355,9 @@ static bool bad_domain(const char *domain, size_t len)
+ static bool invalid_octets(const char *ptr, size_t len)
+ {
+ const unsigned char *p = (const unsigned char *)ptr;
+- /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */
++ /* Reject all bytes \x01 - \x1f + \x7f */
+ while(len && *p) {
+- if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f))
++ if((*p < 0x20) || (*p == 0x7f))
+ return TRUE;
+ p++;
+ len--;
+@@ -455,7 +455,7 @@ parse_cookie_header(struct Curl_easy *data,
+ struct Curl_str val;
+
+ /* we have a <name>=<value> pair or a stand-alone word here */
+- if(!curlx_str_cspn(&ptr, &name, ";\t\r\n=")) {
++ if(!curlx_str_cspn(&ptr, &name, ";\r\n=")) {
+ bool sep = FALSE;
+ curlx_str_trimblanks(&name);
+
+@@ -491,12 +491,7 @@ parse_cookie_header(struct Curl_easy *data,
+ return CURLE_OK;
+ }
+
+- /* Reject cookies with a TAB inside the value */
+- if(curlx_strlen(&val) &&
+- memchr(curlx_str(&val), '\t', curlx_strlen(&val))) {
+- infof(data, "cookie contains TAB, dropping");
+- return CURLE_OK;
+- }
++ /* TAB is now rejected by invalid_octets() above */
+
+ /* Check if we have a reserved prefix set. */
+ if(!strncmp("__Secure-", curlx_str(&name), 9))
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 84ed10b3cf..8b448cfcca 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -275,7 +275,7 @@ test2600 test2601 test2602 test2603 test2604 test2605 \
+ test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 \
+ test2708 test2709 test2710 test2711 test2712 test2713 test2714 test2715 \
+ test2716 test2717 test2718 test2719 test2720 test2721 test2722 test2723 \
+-\
++test2885 \
+ test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
+ test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
+ test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
+diff --git a/tests/data/test2885 b/tests/data/test2885
+new file mode 100644
+index 0000000000..456224fdc5
+--- /dev/null
++++ b/tests/data/test2885
+@@ -0,0 +1,52 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++cookies
++</keywords>
++</info>
++
++<reply>
++<data crlf="headers">
++HTTP/1.1 200 OK
++Content-Length: 0
++Set-Cookie: thisis=SECRET;%TABSecure
++Set-Cookie: also=notab; Secure
++
++</data>
++</reply>
++
++<client>
++<features>
++cookies
++</features>
++<server>
++https
++</server>
++<name>
++Cookies with TAB before 'secure'
++</name>
++<command>
++https://cookie.example:%HTTPSPORT/%TESTNUMBER -c %LOGDIR/cookies.txt --resolve cookie.example:%HTTPSPORT:%HOSTIP --insecure
++</command>
++</client>
++
++<verify>
++<protocol crlf="headers">
++GET /%TESTNUMBER HTTP/1.1
++Host: cookie.example:%HTTPSPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++</protocol>
++<file name="%LOGDIR/cookies.txt" mode="text">
++# Netscape HTTP Cookie File
++# https://curl.se/docs/http-cookies.html
++# This file was generated by libcurl! Edit at your own risk.
++
++cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABalso%TABnotab
++cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABthisis%TABSECRET
++</file>
++</verify>
++</testcase>
diff --git a/0028-curl-8.18.0-CVE-2026-80229.patch b/0028-curl-8.18.0-CVE-2026-80229.patch
deleted file mode 100644
index 10896f7..0000000
--- a/0028-curl-8.18.0-CVE-2026-80229.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From b3e3ca7ac321725e44b02a2ff628c79c7511b35e Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Tue, 25 Aug 2026 11:14:30 +0200
-Subject: [PATCH 2/2] openssl: avoid conn reuse if provider is used
-
-Reported-by: Stanislav Fort
-
-Closes #22665
-
-(cherry picked from commit 7ea37abc6ac0120ba5f6d94be8d196f7cf1506bb)
----
- lib/vtls/openssl.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index f044c10e14..600a64ca6a 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -3717,6 +3717,11 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
- ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
- return CURLE_OUT_OF_MEMORY;
- }
-+#ifdef OPENSSL_HAS_PROVIDERS
-+ if(data->state.libctx)
-+ /* forbid connection reuse with provider/engine use */
-+ connclose(data->conn, "provider in use");
-+#endif
-
- if(cb_setup) {
- result = cb_setup(cf, data, cb_user_data);
---
-2.55.0
-
diff --git a/0029-curl-8.18.0-CVE-2026-19931.patch b/0029-curl-8.18.0-CVE-2026-19931.patch
deleted file mode 100644
index e5e191c..0000000
--- a/0029-curl-8.18.0-CVE-2026-19931.patch
+++ /dev/null
@@ -1,1616 +0,0 @@
-From 219c2096e3d597dbb540b0fbb6ec2e9dfaaa2ec3 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Thu, 8 Oct 2026 10:10:56 +0200
-Subject: [PATCH] connections: use admin handles only for maintenance
-
-Maintenance tasks like connection upkeep, liveliness checks and cache
-eviction must only run on an admin handle, not the application transfer
-from the calling context.
-
-Then application transfers will get only attached to the connections
-they actually work on. This makes `data->state.lastconnect_id`
-meaningful for checks if a subsequent address is finding the previous
-connection again.
-
-One thing led to another:
-- add Curl_get_admin(data), to obtain an admin handle for
- an application handle, inheriting some properties for
- connection operation.
-- rename `Curl_easy *data` parameter to `Curl_easy *admin`
- where only admin handles should be passed. Add DEBUGASSERTs
- in the called function.
-- add Curl_share_lock_share(), Curl_share_unlock_share()
- so it possible to operate on a share without the passed
- easy handle having the share set.
- This catches a case where a shared needed to be locked
- but was not before. Adjust test1554 results.
-
-Fixes #22567
-Reported-by: cybertron10 on github
-Closes #22572
-
-(cherry picked from commit 7103a93b05bc69ea98ed9d05d02fa9eeba533f2f)
-Co-authored-by: Cursor <cursoragent@cursor.com>
----
- lib/conncache.c | 190 ++++++++++++++++++++++++++++----------------
- lib/conncache.h | 23 +++---
- lib/cshutdn.c | 166 +++++++++++++++++++-------------------
- lib/cshutdn.h | 28 +++----
- lib/curl_share.c | 28 +++++--
- lib/curl_share.h | 8 ++
- lib/curl_trc.c | 3 +-
- lib/easy.c | 9 +--
- lib/getinfo.c | 3 +-
- lib/multi.c | 28 ++++---
- lib/multiif.h | 3 +-
- lib/url.c | 44 ++++++++--
- lib/url.h | 6 ++
- lib/urldata.h | 4 +-
- tests/data/test1554 | 2 +
- 15 files changed, 325 insertions(+), 220 deletions(-)
-
-diff --git a/lib/conncache.c b/lib/conncache.c
-index 1a3dba7f63..a152f95b60 100644
---- a/lib/conncache.c
-+++ b/lib/conncache.c
-@@ -45,7 +45,7 @@
- do { \
- if(c) { \
- if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
-- Curl_share_lock((d), CURL_LOCK_DATA_CONNECT, \
-+ Curl_share_lock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT, \
- CURL_LOCK_ACCESS_SINGLE); \
- DEBUGASSERT(!(c)->locked); \
- (c)->locked = TRUE; \
-@@ -58,7 +58,7 @@
- DEBUGASSERT((c)->locked); \
- (c)->locked = FALSE; \
- if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
-- Curl_share_unlock((d), CURL_LOCK_DATA_CONNECT); \
-+ Curl_share_unlock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT); \
- } \
- } while(0)
-
-@@ -74,6 +74,15 @@ static void cpool_discard_conn(struct cpool *cpool,
- struct connectdata *conn,
- bool aborted);
-
-+static void cpool_conn_close(struct cpool *cpool,
-+ struct Curl_easy *data,
-+ struct connectdata *conn,
-+ bool aborted);
-+
-+static void cpool_evict_conn(struct cpool *cpool,
-+ struct Curl_easy *admin,
-+ struct connectdata *conn);
-+
- static struct cpool_bundle *cpool_bundle_create(const char *dest)
- {
- struct cpool_bundle *bundle;
-@@ -119,16 +128,12 @@ static void cpool_bundle_free_entry(void *freethis)
- }
-
- void Curl_cpool_init(struct cpool *cpool,
-- struct Curl_easy *idata,
- struct Curl_share *share,
- size_t size)
- {
- Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
- curlx_str_key_compare, cpool_bundle_free_entry);
-
-- DEBUGASSERT(idata);
--
-- cpool->idata = idata;
- cpool->share = share;
- cpool->initialised = TRUE;
- }
-@@ -189,25 +194,25 @@ static void cpool_remove_conn(struct cpool *cpool,
- }
- }
-
--void Curl_cpool_destroy(struct cpool *cpool)
-+void Curl_cpool_destroy(struct cpool *cpool, struct Curl_easy *admin)
- {
-- if(cpool && cpool->initialised && cpool->idata) {
-+ if(cpool && cpool->initialised && admin) {
- struct connectdata *conn;
- SIGPIPE_VARIABLE(pipe_st);
-
-- CURL_TRC_M(cpool->idata, "%s[CPOOL] destroy, %zu connections",
-+ CURL_TRC_M(admin, "%s[CPOOL] destroy, %zu connections",
- cpool->share ? "[SHARE] " : "", cpool->num_conn);
- /* Move all connections to the shutdown list */
- sigpipe_init(&pipe_st);
-- CPOOL_LOCK(cpool, cpool->idata);
-+ CPOOL_LOCK(cpool, admin);
- conn = cpool_get_first(cpool);
- while(conn) {
- cpool_remove_conn(cpool, conn);
-- sigpipe_apply(cpool->idata, &pipe_st);
-- cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
-+ sigpipe_apply(admin, &pipe_st);
-+ cpool_discard_conn(cpool, admin, conn, FALSE);
- conn = cpool_get_first(cpool);
- }
-- CPOOL_UNLOCK(cpool, cpool->idata);
-+ CPOOL_UNLOCK(cpool, admin);
- sigpipe_restore(&pipe_st);
- Curl_hash_destroy(&cpool->dest2bundle);
- }
-@@ -226,6 +231,11 @@ static struct cpool *cpool_get_instance(struct Curl_easy *data)
- return NULL;
- }
-
-+struct cpool *Curl_cpool_get_instance(struct Curl_easy *data)
-+{
-+ return cpool_get_instance(data);
-+}
-+
- void Curl_cpool_xfer_init(struct Curl_easy *data)
- {
- struct cpool *cpool = cpool_get_instance(data);
-@@ -327,10 +337,28 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool,
- return oldest_idle;
- }
-
-+/* Evict an idle connection to make room in the pool. A pool owned by
-+ * a share has no multi that could perform a controlled shutdown of the
-+ * connection; terminate it right away. Otherwise, hand it to the
-+ * transfer's multi for shutdown. Expects the pool to be locked. */
-+static void cpool_evict_conn(struct cpool *cpool,
-+ struct Curl_easy *admin,
-+ struct connectdata *conn)
-+{
-+ if(cpool->share) {
-+ cpool_remove_conn(cpool, conn);
-+ Curl_cshutdn_terminate(admin, conn, TRUE);
-+ }
-+ else
-+ cpool_conn_close(cpool, admin, conn, FALSE);
-+}
-+
- int Curl_cpool_check_limits(struct Curl_easy *data,
- struct connectdata *conn)
- {
- struct cpool *cpool = cpool_get_instance(data);
-+ struct cshutdn *cshutdn = Curl_cshutdn_get(data);
-+ struct Curl_easy *admin;
- struct cpool_bundle *bundle;
- size_t dest_limit = 0;
- size_t total_limit = 0;
-@@ -340,25 +368,26 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
- if(!cpool)
- return CPOOL_LIMIT_OK;
-
-- if(cpool->idata->multi) {
-- dest_limit = cpool->idata->multi->max_host_connections;
-- total_limit = cpool->idata->multi->max_total_connections;
-+ if(data->multi) {
-+ dest_limit = data->multi->max_host_connections;
-+ total_limit = data->multi->max_total_connections;
- }
-
- if(!dest_limit && !total_limit)
- return CPOOL_LIMIT_OK;
-
-- CPOOL_LOCK(cpool, cpool->idata);
-+ admin = Curl_get_admin(data);
-+ CPOOL_LOCK(cpool, admin);
- if(dest_limit) {
- size_t live;
-
- bundle = cpool_find_bundle(cpool, conn);
- live = bundle ? Curl_llist_count(&bundle->conns) : 0;
-- shutdowns = Curl_cshutdn_dest_count(data, conn->destination);
-+ shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
- while((live + shutdowns) >= dest_limit) {
- if(shutdowns) {
- /* close one connection in shutdown right away, if we can */
-- if(!Curl_cshutdn_close_oldest(data, conn->destination))
-+ if(!Curl_cshutdn_close_oldest(cshutdn, conn->destination))
- break;
- }
- else if(!bundle)
-@@ -372,17 +401,17 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
- if(!oldest_idle)
- break;
- /* disconnect the old conn and continue */
-- CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
-+ CURL_TRC_M(admin, "Discarding connection #%" FMT_OFF_T
- " from %zu to reach destination limit of %zu",
- oldest_idle->connection_id,
- Curl_llist_count(&bundle->conns), dest_limit);
-- Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
-+ cpool_evict_conn(cpool, admin, oldest_idle);
-
- /* in case the bundle was destroyed in disconnect, look it up again */
- bundle = cpool_find_bundle(cpool, conn);
- live = bundle ? Curl_llist_count(&bundle->conns) : 0;
- }
-- shutdowns = Curl_cshutdn_dest_count(cpool->idata, conn->destination);
-+ shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
- }
- if((live + shutdowns) >= dest_limit) {
- result = CPOOL_LIMIT_DEST;
-@@ -391,11 +420,11 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
- }
-
- if(total_limit) {
-- shutdowns = Curl_cshutdn_count(cpool->idata);
-+ shutdowns = Curl_cshutdn_count(cshutdn);
- while((cpool->num_conn + shutdowns) >= total_limit) {
- if(shutdowns) {
- /* close one connection in shutdown right away, if we can */
-- if(!Curl_cshutdn_close_oldest(data, NULL))
-+ if(!Curl_cshutdn_close_oldest(cshutdn, NULL))
- break;
- }
- else {
-@@ -404,13 +433,13 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
- if(!oldest_idle)
- break;
- /* disconnect the old conn and continue */
-- CURL_TRC_M(data, "Discarding connection #%"
-+ CURL_TRC_M(admin, "Discarding connection #%"
- FMT_OFF_T " from %zu to reach total "
- "limit of %zu",
- oldest_idle->connection_id, cpool->num_conn, total_limit);
-- Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
-+ cpool_evict_conn(cpool, admin, oldest_idle);
- }
-- shutdowns = Curl_cshutdn_count(cpool->idata);
-+ shutdowns = Curl_cshutdn_count(cshutdn);
- }
- if((cpool->num_conn + shutdowns) >= total_limit) {
- result = CPOOL_LIMIT_TOTAL;
-@@ -419,7 +448,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
- }
-
- out:
-- CPOOL_UNLOCK(cpool, cpool->idata);
-+ CPOOL_UNLOCK(cpool, admin);
- return result;
- }
-
-@@ -472,7 +501,8 @@ out:
- static bool cpool_foreach(struct Curl_easy *data,
- struct cpool *cpool,
- void *param,
-- int (*func)(struct Curl_easy *data,
-+ int (*func)(struct cpool *cpool,
-+ struct Curl_easy *data,
- struct connectdata *conn, void *param))
- {
- struct Curl_hash_iterator iter;
-@@ -496,7 +526,7 @@ static bool cpool_foreach(struct Curl_easy *data,
- struct connectdata *conn = Curl_node_elem(curr);
- curr = Curl_node_next(curr);
-
-- if(func(data, conn, param) == 1) {
-+ if(func(cpool, data, conn, param) == 1) {
- return TRUE;
- }
- }
-@@ -533,8 +563,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
- if(cpool && maxconnects) {
- /* may be called form a callback already under lock */
- bool do_lock = !CPOOL_IS_LOCKED(cpool);
-+ struct Curl_easy *admin;
-+
-+ admin = Curl_get_admin(data);
- if(do_lock)
-- CPOOL_LOCK(cpool, data);
-+ CPOOL_LOCK(cpool, admin);
- if(cpool->num_conn > maxconnects) {
- infof(data, "Connection pool is full, closing the oldest of %zu/%u",
- cpool->num_conn, maxconnects);
-@@ -542,11 +575,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
- oldest_idle = cpool_get_oldest_idle(cpool, Curl_pgrs_now(data));
- kept = (oldest_idle != conn);
- if(oldest_idle) {
-- Curl_conn_terminate(data, oldest_idle, FALSE);
-+ cpool_evict_conn(cpool, admin, oldest_idle);
- }
- }
- if(do_lock)
-- CPOOL_UNLOCK(cpool, data);
-+ CPOOL_UNLOCK(cpool, admin);
- }
-
- return kept;
-@@ -597,6 +630,8 @@ static void cpool_discard_conn(struct cpool *cpool,
- struct connectdata *conn,
- bool aborted)
- {
-+ struct cshutdn *cshutdn;
-+ struct Curl_easy *admin;
- bool done = FALSE;
-
- DEBUGASSERT(data);
-@@ -604,12 +639,13 @@ static void cpool_discard_conn(struct cpool *cpool,
- DEBUGASSERT(cpool);
- DEBUGASSERT(!conn->bits.in_cpool);
-
-+ admin = Curl_get_admin(data);
- /*
- * If this connection is not marked to force-close, leave it open if there
- * are other users of it
- */
- if(CONN_INUSE(conn) && !aborted) {
-- CURL_TRC_M(data, "[CPOOL] not discarding #%" FMT_OFF_T
-+ CURL_TRC_M(admin, "[CPOOL] not discarding #%" FMT_OFF_T
- " still in use by %u transfers", conn->connection_id,
- conn->attached_xfers);
- return;
-@@ -630,20 +666,22 @@ static void cpool_discard_conn(struct cpool *cpool,
- done = TRUE;
- if(!done) {
- /* Attempt to shutdown the connection right away. */
-- Curl_cshutdn_run_once(cpool->idata, conn, &done);
-+ Curl_conn_shutdown_once(admin, conn, &done);
- }
-
-- if(done || !data->multi)
-- Curl_cshutdn_terminate(cpool->idata, conn, FALSE);
-+ cshutdn = Curl_cshutdn_get(data);
-+ if(done || !cshutdn)
-+ Curl_cshutdn_terminate(admin, conn, FALSE);
- else
-- Curl_cshutdn_add(&data->multi->cshutdn, conn, cpool->num_conn);
-+ Curl_cshutdn_add(cshutdn, conn, cpool->num_conn);
- }
-
--void Curl_conn_terminate(struct Curl_easy *data,
-- struct connectdata *conn,
-- bool aborted)
-+static void cpool_conn_close(struct cpool *cpool,
-+ struct Curl_easy *data,
-+ struct connectdata *conn,
-+ bool aborted)
- {
-- struct cpool *cpool = cpool_get_instance(data);
-+ struct Curl_easy *admin;
- bool do_lock;
-
- DEBUGASSERT(cpool);
-@@ -661,9 +699,10 @@ void Curl_conn_terminate(struct Curl_easy *data,
-
- /* This method may be called while we are under lock, e.g. from a
- * user callback in find. */
-+ admin = Curl_get_admin(data);
- do_lock = !CPOOL_IS_LOCKED(cpool);
- if(do_lock)
-- CPOOL_LOCK(cpool, data);
-+ CPOOL_LOCK(cpool, admin);
-
- if(conn->bits.in_cpool) {
- cpool_remove_conn(cpool, conn);
-@@ -684,11 +723,19 @@ void Curl_conn_terminate(struct Curl_easy *data,
- else {
- /* No multi available, terminate */
- infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
-- Curl_cshutdn_terminate(cpool->idata, conn, !aborted);
-+ Curl_cshutdn_terminate(admin, conn, !aborted);
- }
-
- if(do_lock)
-- CPOOL_UNLOCK(cpool, data);
-+ CPOOL_UNLOCK(cpool, admin);
-+}
-+
-+void Curl_conn_terminate(struct Curl_easy *data,
-+ struct connectdata *conn,
-+ bool aborted)
-+{
-+ struct cpool *cpool = cpool_get_instance(data);
-+ cpool_conn_close(cpool, data, conn, aborted);
- }
-
- struct cpool_reaper_ctx {
-@@ -696,7 +743,8 @@ struct cpool_reaper_ctx {
- size_t reaped;
- };
-
--static int cpool_reap_dead_cb(struct Curl_easy *data,
-+static int cpool_reap_dead_cb(struct cpool *cpool,
-+ struct Curl_easy *admin,
- struct connectdata *conn, void *param)
- {
- struct cpool_reaper_ctx *reaper = param;
-@@ -704,12 +752,12 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
-
- if(!terminate) {
- reaper->checked++;
-- terminate = Curl_conn_seems_dead(conn, data);
-+ terminate = Curl_conn_seems_dead(conn, admin);
- }
- if(terminate) {
- /* stop the iteration here, pass back the connection that was pruned */
- reaper->reaped++;
-- Curl_conn_terminate(data, conn, FALSE);
-+ cpool_conn_close(cpool, admin, conn, FALSE);
- return 1;
- }
- return 0; /* continue iteration */
-@@ -722,31 +770,35 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
- *
- * When called, this transfer has no connection attached.
- */
--void Curl_cpool_prune_dead(struct Curl_easy *data)
-+void Curl_cpool_prune_dead(struct cpool *cpool,
-+ struct Curl_easy *data)
- {
-- struct cpool *cpool = cpool_get_instance(data);
-+ struct Curl_easy *admin;
- struct cpool_reaper_ctx reaper;
- timediff_t elapsed;
-
- if(!cpool)
- return;
-
-+ admin = Curl_get_admin(data);
- memset(&reaper, 0, sizeof(reaper));
-- CPOOL_LOCK(cpool, data);
-+ CPOOL_LOCK(cpool, admin);
- elapsed = curlx_ptimediff_ms(Curl_pgrs_now(data), &cpool->last_cleanup);
-
- if(elapsed >= 1000L) {
-- while(cpool_foreach(data, cpool, &reaper, cpool_reap_dead_cb))
-+ while(cpool_foreach(admin, cpool, &reaper, cpool_reap_dead_cb))
- ;
- cpool->last_cleanup = *Curl_pgrs_now(data);
- }
-- CPOOL_UNLOCK(cpool, data);
-+ CPOOL_UNLOCK(cpool, admin);
- }
-
--static int conn_upkeep(struct Curl_easy *data,
-+static int conn_upkeep(struct cpool *cpool,
-+ struct Curl_easy *data,
- struct connectdata *conn,
- void *param)
- {
-+ (void)cpool;
- (void)param;
- Curl_conn_upkeep(data, conn);
- return 0; /* continue iteration */
-@@ -770,10 +822,12 @@ struct cpool_find_ctx {
- struct connectdata *conn;
- };
-
--static int cpool_find_conn(struct Curl_easy *data,
-+static int cpool_find_conn(struct cpool *cpool,
-+ struct Curl_easy *data,
- struct connectdata *conn, void *param)
- {
- struct cpool_find_ctx *fctx = param;
-+ (void)cpool;
- (void)data;
- if(conn->connection_id == fctx->id) {
- fctx->conn = conn;
-@@ -804,10 +858,12 @@ struct cpool_do_conn_ctx {
- void *cbdata;
- };
-
--static int cpool_do_conn(struct Curl_easy *data,
-+static int cpool_do_conn(struct cpool *cpool,
-+ struct Curl_easy *data,
- struct connectdata *conn, void *param)
- {
- struct cpool_do_conn_ctx *dctx = param;
-+ (void)cpool;
- (void)data;
- if(conn->connection_id == dctx->id) {
- dctx->cb(conn, data, dctx->cbdata);
-@@ -846,37 +902,37 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
- cb(conn, data, cbdata);
- }
-
--static int cpool_mark_stale(struct Curl_easy *data,
-+static int cpool_mark_stale(struct cpool *cpool,
-+ struct Curl_easy *data,
- struct connectdata *conn, void *param)
- {
-+ (void)cpool;
- (void)data;
- (void)param;
- conn->bits.no_reuse = TRUE;
- return 0;
- }
-
--static int cpool_reap_no_reuse(struct Curl_easy *data,
-+static int cpool_reap_no_reuse(struct cpool *cpool,
-+ struct Curl_easy *admin,
- struct connectdata *conn, void *param)
- {
-- (void)data;
- (void)param;
- if(!CONN_INUSE(conn) && conn->bits.no_reuse) {
-- Curl_conn_terminate(data, conn, FALSE);
-+ cpool_conn_close(cpool, admin, conn, FALSE);
- return 1;
- }
- return 0; /* continue iteration */
- }
-
--void Curl_cpool_nw_changed(struct Curl_easy *data)
-+void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin)
- {
-- struct cpool *cpool = cpool_get_instance(data);
--
- if(cpool) {
-- CPOOL_LOCK(cpool, data);
-- cpool_foreach(data, cpool, NULL, cpool_mark_stale);
-- while(cpool_foreach(data, cpool, NULL, cpool_reap_no_reuse))
-+ CPOOL_LOCK(cpool, admin);
-+ cpool_foreach(admin, cpool, NULL, cpool_mark_stale);
-+ while(cpool_foreach(admin, cpool, NULL, cpool_reap_no_reuse))
- ;
-- CPOOL_UNLOCK(cpool, data);
-+ CPOOL_UNLOCK(cpool, admin);
- }
- }
-
-diff --git a/lib/conncache.h b/lib/conncache.h
-index 9b392af05c..4acefb0f9e 100644
---- a/lib/conncache.h
-+++ b/lib/conncache.h
-@@ -34,7 +34,7 @@ struct Curl_multi;
- struct Curl_share;
-
- /**
-- * Terminate the connection, e.g. close and destroy.
-+ * Close and destroy the connection.
- * If the connection is in a cpool, remove it.
- * If a `cshutdn` is available (e.g. data has a multi handle),
- * pass the connection to that for controlled shutdown.
-@@ -43,8 +43,8 @@ struct Curl_share;
- * `data` should not be attached to a connection.
- */
- void Curl_conn_terminate(struct Curl_easy *data,
-- struct connectdata *conn,
-- bool aborted);
-+ struct connectdata *conn,
-+ bool aborted);
-
- struct cpool {
- /* the pooled connections, bundled per destination */
-@@ -53,22 +53,24 @@ struct cpool {
- curl_off_t next_connection_id;
- curl_off_t next_easy_id;
- struct curltime last_cleanup;
-- struct Curl_easy *idata; /* internal handle for maintenance */
- struct Curl_share *share; /* != NULL if pool belongs to share */
- BIT(locked);
- BIT(initialised);
- };
-
-+/* Get connection pool instance for data or NULL if none exists */
-+struct cpool *Curl_cpool_get_instance(struct Curl_easy *data);
-+
- /* Init the pool, pass multi only if pool is owned by it.
- * Cannot fail.
- */
- void Curl_cpool_init(struct cpool *cpool,
-- struct Curl_easy *idata,
- struct Curl_share *share,
- size_t size);
-
- /* Destroy all connections and free all members */
--void Curl_cpool_destroy(struct cpool *connc);
-+void Curl_cpool_destroy(struct cpool *cpool,
-+ struct Curl_easy *admin);
-
- /* Init the transfer to be used within its connection pool.
- * Assigns `data->id`. */
-@@ -126,13 +128,12 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
- struct connectdata *conn);
-
- /**
-- * This function scans the data's connection pool for half-open/dead
-+ * Scans the connection pool for half-open/dead
- * connections, closes and removes them.
- * The cleanup is done at most once per second.
-- *
-- * When called, this transfer has no connection attached.
- */
--void Curl_cpool_prune_dead(struct Curl_easy *data);
-+void Curl_cpool_prune_dead(struct cpool *cpool,
-+ struct Curl_easy *data);
-
- /**
- * Perform upkeep actions on connections in the transfer's pool.
-@@ -162,6 +163,6 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
- Curl_cpool_conn_do_cb *cb, void *cbdata);
-
- /* Close all unused connections, prevent reuse of existing ones. */
--void Curl_cpool_nw_changed(struct Curl_easy *data);
-+void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin);
-
- #endif /* HEADER_CURL_CONNCACHE_H */
-diff --git a/lib/cshutdn.c b/lib/cshutdn.c
-index 84e5b2a116..5610e7070b 100644
---- a/lib/cshutdn.c
-+++ b/lib/cshutdn.c
-@@ -38,6 +38,13 @@
- #include "curlx/strparse.h"
-
-
-+struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data)
-+{
-+ if(data && data->multi)
-+ return &data->multi->cshutdn;
-+ return NULL;
-+}
-+
- static void cshutdn_run_conn_handler(struct Curl_easy *data,
- struct connectdata *conn)
- {
-@@ -103,22 +110,22 @@ static void cshutdn_run_once(struct Curl_easy *data,
- conn->bits.shutdown_filters = TRUE;
- }
-
--void Curl_cshutdn_run_once(struct Curl_easy *data,
-+void Curl_conn_shutdown_once(struct Curl_easy *admin,
- struct connectdata *conn,
- bool *done)
- {
-- DEBUGASSERT(!data->conn);
-- Curl_attach_connection(data, conn);
-- cshutdn_run_once(data, conn, done);
-- CURL_TRC_M(data, "[SHUTDOWN] shutdown, done=%d", *done);
-- Curl_detach_connection(data);
-+ DEBUGASSERT(!admin->conn);
-+ DEBUGASSERT(!admin->mid);
-+ Curl_attach_connection(admin, conn, FALSE);
-+ cshutdn_run_once(admin, conn, done);
-+ CURL_TRC_M(admin, "[SHUTDOWN] shutdown, done=%d", *done);
-+ Curl_detach_connection(admin);
- }
-
--void Curl_cshutdn_terminate(struct Curl_easy *data,
-+void Curl_cshutdn_terminate(struct Curl_easy *admin,
- struct connectdata *conn,
- bool do_shutdown)
- {
-- struct Curl_easy *admin = data;
- bool done;
-
- /* there must be a connection to close */
-@@ -126,16 +133,10 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
- /* it must be removed from the connection pool */
- DEBUGASSERT(!conn->bits.in_cpool);
- /* the transfer must be detached from the connection */
-- DEBUGASSERT(data && !data->conn);
--
-- /* If we can obtain an internal admin handle, use that to attach
-- * and terminate the connection. Some protocol will try to mess with
-- * `data` during shutdown and we do not want that with a `data` from
-- * the application. */
-- if(data->multi && data->multi->admin)
-- admin = data->multi->admin;
-+ DEBUGASSERT(admin && !admin->conn);
-+ DEBUGASSERT(!admin->mid);
-
-- Curl_attach_connection(admin, conn);
-+ Curl_attach_connection(admin, conn, FALSE);
-
- cshutdn_run_conn_handler(admin, conn);
- if(do_shutdown) {
-@@ -150,18 +151,17 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
- Curl_conn_close(admin, FIRSTSOCKET);
- Curl_detach_connection(admin);
-
-- if(data->multi)
-- Curl_multi_ev_conn_done(data->multi, data, conn);
-+ if(admin->multi)
-+ Curl_multi_ev_conn_done(admin->multi, admin, conn);
- Curl_conn_free(admin, conn);
-
-- if(data->multi) {
-- CURL_TRC_M(data, "[SHUTDOWN] trigger multi connchanged");
-- Curl_multi_connchanged(data->multi);
-+ if(admin->multi) {
-+ CURL_TRC_M(admin, "[SHUTDOWN] trigger multi connchanged");
-+ Curl_multi_connchanged(admin->multi);
- }
- }
-
- static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- const char *destination)
- {
- struct Curl_llist_node *e;
-@@ -180,20 +180,19 @@ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
- conn = Curl_node_elem(e);
- Curl_node_remove(e);
- sigpipe_init(&pipe_st);
-- sigpipe_apply(data, &pipe_st);
-- Curl_cshutdn_terminate(data, conn, FALSE);
-+ sigpipe_apply(cshutdn->multi->admin, &pipe_st);
-+ Curl_cshutdn_terminate(cshutdn->multi->admin, conn, FALSE);
- sigpipe_restore(&pipe_st);
- return TRUE;
- }
- return FALSE;
- }
-
--bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
-+bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
- const char *destination)
- {
-- if(data && data->multi) {
-- struct cshutdn *csd = &data->multi->cshutdn;
-- return cshutdn_destroy_oldest(csd, data, destination);
-+ if(cshutdn) {
-+ return cshutdn_destroy_oldest(cshutdn, destination);
- }
- return FALSE;
- }
-@@ -201,7 +200,6 @@ bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
- #define NUM_POLLS_ON_STACK 10
-
- static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- int timeout_ms)
- {
- struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
-@@ -210,7 +208,7 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
-
- Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK);
-
-- result = Curl_cshutdn_add_pollfds(cshutdn, data, &cpfds);
-+ result = Curl_cshutdn_add_pollfds(cshutdn, &cpfds);
- if(result)
- goto out;
-
-@@ -222,7 +220,7 @@ out:
- }
-
- static void cshutdn_perform(struct cshutdn *cshutdn,
-- struct Curl_easy *data)
-+ struct Curl_easy *admin)
- {
- struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
- struct Curl_llist_node *enext;
-@@ -233,20 +231,20 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
- if(!e)
- return;
-
-- CURL_TRC_M(data, "[SHUTDOWN] perform on %zu connections",
-+ CURL_TRC_M(admin, "[SHUTDOWN] perform on %zu connections",
- Curl_llist_count(&cshutdn->list));
- while(e) {
- enext = Curl_node_next(e);
- conn = Curl_node_elem(e);
-- Curl_cshutdn_run_once(data, conn, &done);
-+ Curl_conn_shutdown_once(admin, conn, &done);
- if(done) {
- Curl_node_remove(e);
-- Curl_cshutdn_terminate(data, conn, FALSE);
-+ Curl_cshutdn_terminate(admin, conn, FALSE);
- }
- else {
- /* idata has one timer list, but maybe more than one connection.
- * Set EXPIRE_SHUTDOWN to the smallest time left for all. */
-- ms = Curl_conn_shutdown_timeleft(data, conn);
-+ ms = Curl_conn_shutdown_timeleft(admin, conn);
- if(ms && ms < next_expire_ms)
- next_expire_ms = ms;
- }
-@@ -254,46 +252,43 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
- }
-
- if(next_expire_ms)
-- Curl_expire_ex(data, next_expire_ms, EXPIRE_SHUTDOWN);
-+ Curl_expire_ex(admin, next_expire_ms, EXPIRE_SHUTDOWN);
- }
-
- static void cshutdn_terminate_all(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- int timeout_ms)
- {
-- struct curltime started = *Curl_pgrs_now(data);
-+ struct Curl_easy *admin = cshutdn->multi->admin;
-+ struct curltime started = *Curl_pgrs_now(admin);
- struct Curl_llist_node *e;
- SIGPIPE_VARIABLE(pipe_st);
-
-- DEBUGASSERT(cshutdn);
-- DEBUGASSERT(data);
--
-- CURL_TRC_M(data, "[SHUTDOWN] shutdown all");
-+ CURL_TRC_M(admin, "[SHUTDOWN] shutdown all");
- sigpipe_init(&pipe_st);
-- sigpipe_apply(data, &pipe_st);
-+ sigpipe_apply(admin, &pipe_st);
-
- while(Curl_llist_head(&cshutdn->list)) {
- timediff_t spent_ms;
- int remain_ms;
-
-- cshutdn_perform(cshutdn, data);
-+ cshutdn_perform(cshutdn, admin);
-
- if(!Curl_llist_head(&cshutdn->list)) {
-- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished cleanly");
-+ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished cleanly");
- break;
- }
-
- /* wait for activity, timeout or "nothing" */
-- spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &started);
-+ spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(admin), &started);
- if(spent_ms >= (timediff_t)timeout_ms) {
-- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
-+ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, %s",
- (timeout_ms > 0) ? "timeout" : "best effort done");
- break;
- }
-
- remain_ms = timeout_ms - (int)spent_ms;
-- if(cshutdn_wait(cshutdn, data, remain_ms)) {
-- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, aborted");
-+ if(cshutdn_wait(cshutdn, remain_ms)) {
-+ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, aborted");
- break;
- }
- }
-@@ -303,7 +298,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
- while(e) {
- struct connectdata *conn = Curl_node_elem(e);
- Curl_node_remove(e);
-- Curl_cshutdn_terminate(data, conn, FALSE);
-+ Curl_cshutdn_terminate(admin, conn, FALSE);
- e = Curl_llist_head(&cshutdn->list);
- }
- DEBUGASSERT(!Curl_llist_count(&cshutdn->list));
-@@ -322,9 +317,9 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn,
- }
-
- void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
-- struct Curl_easy *data)
-+ struct Curl_easy *admin)
- {
-- if(cshutdn->initialised && data) {
-+ if(cshutdn->initialised && admin) {
- int timeout_ms = 0;
- /* Just for testing, run graceful shutdown */
- #ifdef DEBUGBUILD
-@@ -338,29 +333,27 @@ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
- }
- #endif
-
-- CURL_TRC_M(data, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
-+ CURL_TRC_M(admin, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
- Curl_llist_count(&cshutdn->list), timeout_ms);
-- cshutdn_terminate_all(cshutdn, data, timeout_ms);
-+ cshutdn_terminate_all(cshutdn, timeout_ms);
- }
- cshutdn->multi = NULL;
- }
-
--size_t Curl_cshutdn_count(struct Curl_easy *data)
-+size_t Curl_cshutdn_count(struct cshutdn *cshutdn)
- {
-- if(data && data->multi) {
-- struct cshutdn *csd = &data->multi->cshutdn;
-- return Curl_llist_count(&csd->list);
-+ if(cshutdn) {
-+ return Curl_llist_count(&cshutdn->list);
- }
- return 0;
- }
-
--size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
-+size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
- const char *destination)
- {
-- if(data && data->multi) {
-- struct cshutdn *csd = &data->multi->cshutdn;
-+ if(cshutdn) {
- size_t n = 0;
-- struct Curl_llist_node *e = Curl_llist_head(&csd->list);
-+ struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
- while(e) {
- struct connectdata *conn = Curl_node_elem(e);
- if(!strcmp(destination, conn->destination))
-@@ -373,7 +366,7 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
- }
-
- static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
-+ struct Curl_easy *admin,
- struct connectdata *conn)
- {
- CURLMcode mresult;
-@@ -381,9 +374,9 @@ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
- DEBUGASSERT(cshutdn);
- DEBUGASSERT(cshutdn->multi->socket_cb);
-
-- Curl_attach_connection(data, conn);
-- mresult = Curl_multi_ev_assess_conn(cshutdn->multi, data, conn);
-- Curl_detach_connection(data);
-+ Curl_attach_connection(admin, conn, FALSE);
-+ mresult = Curl_multi_ev_assess_conn(cshutdn->multi, admin, conn);
-+ Curl_detach_connection(admin);
- return mresult;
- }
-
-@@ -400,7 +393,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
- (conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
- CURL_TRC_M(data, "[SHUTDOWN] discarding oldest shutdown connection "
- "due to connection limit of %zu", max_total);
-- cshutdn_destroy_oldest(cshutdn, data, NULL);
-+ cshutdn_destroy_oldest(cshutdn, NULL);
- }
-
- if(cshutdn->multi->socket_cb) {
-@@ -419,7 +412,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
- }
-
- static void cshutdn_multi_socket(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
-+ struct Curl_easy *admin,
- curl_socket_t s)
- {
- struct Curl_llist_node *e;
-@@ -431,10 +424,10 @@ static void cshutdn_multi_socket(struct cshutdn *cshutdn,
- while(e) {
- conn = Curl_node_elem(e);
- if(s == conn->sock[FIRSTSOCKET] || s == conn->sock[SECONDARYSOCKET]) {
-- Curl_cshutdn_run_once(data, conn, &done);
-- if(done || cshutdn_update_ev(cshutdn, data, conn)) {
-+ Curl_conn_shutdown_once(admin, conn, &done);
-+ if(done || cshutdn_update_ev(cshutdn, admin, conn)) {
- Curl_node_remove(e);
-- Curl_cshutdn_terminate(data, conn, FALSE);
-+ Curl_cshutdn_terminate(admin, conn, FALSE);
- }
- break;
- }
-@@ -446,21 +439,22 @@ void Curl_cshutdn_perform(struct cshutdn *cshutdn,
- struct Curl_easy *data,
- curl_socket_t s)
- {
-+ struct Curl_easy *admin = Curl_get_admin(data);
- if((s == CURL_SOCKET_TIMEOUT) || (!cshutdn->multi->socket_cb))
-- cshutdn_perform(cshutdn, data);
-+ cshutdn_perform(cshutdn, admin);
- else
-- cshutdn_multi_socket(cshutdn, data, s);
-+ cshutdn_multi_socket(cshutdn, admin, s);
- }
-
- /* return fd_set info about the shutdown connections */
- void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- fd_set *read_fd_set, fd_set *write_fd_set,
- int *maxfd)
- {
- if(Curl_llist_head(&cshutdn->list)) {
- struct Curl_llist_node *e;
- struct easy_pollset ps;
-+ struct Curl_easy *admin = cshutdn->multi->admin;
-
- Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
-@@ -469,9 +463,9 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
- CURLcode result;
-
- Curl_pollset_reset(&ps);
-- Curl_attach_connection(data, conn);
-- result = Curl_conn_adjust_pollset(data, conn, &ps);
-- Curl_detach_connection(data);
-+ Curl_attach_connection(admin, conn, FALSE);
-+ result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+ Curl_detach_connection(admin);
-
- if(result)
- continue;
-@@ -502,7 +496,6 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
-
- /* return information about the shutdown connections */
- unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- struct Curl_waitfds *cwfds)
- {
- unsigned int need = 0;
-@@ -511,15 +504,16 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
- struct Curl_llist_node *e;
- struct easy_pollset ps;
- struct connectdata *conn;
-+ struct Curl_easy *admin = cshutdn->multi->admin;
- CURLcode result;
-
- Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
- conn = Curl_node_elem(e);
- Curl_pollset_reset(&ps);
-- Curl_attach_connection(data, conn);
-- result = Curl_conn_adjust_pollset(data, conn, &ps);
-- Curl_detach_connection(data);
-+ Curl_attach_connection(admin, conn, FALSE);
-+ result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+ Curl_detach_connection(admin);
-
- if(!result)
- need += Curl_waitfds_add_ps(cwfds, &ps);
-@@ -530,7 +524,6 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
- }
-
- CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- struct curl_pollfds *cpfds)
- {
- CURLcode result = CURLE_OK;
-@@ -539,14 +532,15 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
- struct Curl_llist_node *e;
- struct easy_pollset ps;
- struct connectdata *conn;
-+ struct Curl_easy *admin = cshutdn->multi->admin;
-
- Curl_pollset_init(&ps);
- for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
- conn = Curl_node_elem(e);
- Curl_pollset_reset(&ps);
-- Curl_attach_connection(data, conn);
-- result = Curl_conn_adjust_pollset(data, conn, &ps);
-- Curl_detach_connection(data);
-+ Curl_attach_connection(admin, conn, FALSE);
-+ result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+ Curl_detach_connection(admin);
-
- if(!result)
- result = Curl_pollfds_add_ps(cpfds, &ps);
-diff --git a/lib/cshutdn.h b/lib/cshutdn.h
-index 0a15d39f1c..71b99a4e5a 100644
---- a/lib/cshutdn.h
-+++ b/lib/cshutdn.h
-@@ -32,20 +32,20 @@ struct Curl_multi;
- struct Curl_share;
-
- /* Run the shutdown of the connection once.
-- * Will shortly attach/detach `data` to `conn` while doing so.
-+ * Shortly attach/detach the admin handle to `conn` while doing so.
- * `done` will be set TRUE if any error was encountered or if
- * the connection was shut down completely. */
--void Curl_cshutdn_run_once(struct Curl_easy *data,
-- struct connectdata *conn,
-- bool *done);
-+void Curl_conn_shutdown_once(struct Curl_easy *admin,
-+ struct connectdata *conn,
-+ bool *done);
-
- /* Terminates the connection, e.g. closes and destroys it.
- * If `run_shutdown` is TRUE, the shutdown will be run once before
- * terminating it.
- * Takes ownership of `conn`. */
--void Curl_cshutdn_terminate(struct Curl_easy *data,
-- struct connectdata *conn,
-- bool run_shutdown);
-+void Curl_cshutdn_terminate(struct Curl_easy *admin,
-+ struct connectdata *conn,
-+ bool do_shutdown);
-
- /* A `cshutdown` is always owned by a multi handle to maintain
- * the connections to be shut down. It registers timers and
-@@ -56,25 +56,28 @@ struct cshutdn {
- BIT(initialised);
- };
-
-+/* Get the cshutdn instance relevant for `data` or NULL if there is none */
-+struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data);
-+
- /* Init as part of the given multi handle. */
- int Curl_cshutdn_init(struct cshutdn *cshutdn,
- struct Curl_multi *multi);
-
- /* Terminate all remaining connections and free resources. */
- void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
-- struct Curl_easy *data);
-+ struct Curl_easy *admin);
-
- /* Number of connections being shut down. */
--size_t Curl_cshutdn_count(struct Curl_easy *data);
-+size_t Curl_cshutdn_count(struct cshutdn *cshutdn);
-
- /* Number of connections to the destination being shut down. */
--size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
-+size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
- const char *destination);
-
- /* Close the oldest connection in shutdown to destination or,
- * when destination is NULL for any destination.
- * Return TRUE if a connection has been closed. */
--bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
-+bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
- const char *destination);
-
- /* Add a connection to have it shut down. Will terminate the oldest
-@@ -85,15 +88,12 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
-
- /* Add sockets and POLLIN/OUT flags for connections being shut down. */
- CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- struct curl_pollfds *cpfds);
-
- unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- struct Curl_waitfds *cwfds);
-
- void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
-- struct Curl_easy *data,
- fd_set *read_fd_set, fd_set *write_fd_set,
- int *maxfd);
-
-diff --git a/lib/curl_share.c b/lib/curl_share.c
-index 3ff2755684..426e85a8ae 100644
---- a/lib/curl_share.c
-+++ b/lib/curl_share.c
-@@ -31,6 +31,7 @@
- #include "hsts.h"
- #include "url.h"
-
-+
- CURLSH *curl_share_init(void)
- {
- struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share));
-@@ -128,7 +129,7 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
- case CURL_LOCK_DATA_CONNECT:
- /* It is safe to set this option several times on a share. */
- if(!share->cpool.initialised) {
-- Curl_cpool_init(&share->cpool, share->admin, share, 103);
-+ Curl_cpool_init(&share->cpool, share, 103);
- }
- break;
-
-@@ -236,7 +237,7 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
- }
-
- if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
-- Curl_cpool_destroy(&share->cpool);
-+ Curl_cpool_destroy(&share->cpool, share->admin);
- }
-
- Curl_dnscache_destroy(&share->dnscache);
-@@ -267,11 +268,11 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
- return CURLSHE_OK;
- }
-
--CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
-- curl_lock_access accesstype)
-+CURLSHcode Curl_share_lock_share(struct Curl_share *share,
-+ struct Curl_easy *data,
-+ curl_lock_data type,
-+ curl_lock_access accesstype)
- {
-- struct Curl_share *share = data->share;
--
- if(!share)
- return CURLSHE_INVALID;
-
-@@ -284,10 +285,16 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
- return CURLSHE_OK;
- }
-
--CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-+CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
-+ curl_lock_access accesstype)
- {
-- struct Curl_share *share = data->share;
-+ return Curl_share_lock_share(data->share, data, type, accesstype);
-+}
-
-+CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
-+ struct Curl_easy *data,
-+ curl_lock_data type)
-+{
- if(!share)
- return CURLSHE_INVALID;
-
-@@ -298,3 +305,8 @@ CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-
- return CURLSHE_OK;
- }
-+
-+CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-+{
-+ return Curl_share_unlock_share(data->share, data, type);
-+}
-diff --git a/lib/curl_share.h b/lib/curl_share.h
-index fcd9e32980..9a4fdba392 100644
---- a/lib/curl_share.h
-+++ b/lib/curl_share.h
-@@ -69,6 +69,14 @@ CURLSHcode Curl_share_lock(struct Curl_easy *, curl_lock_data,
- curl_lock_access);
- CURLSHcode Curl_share_unlock(struct Curl_easy *, curl_lock_data);
-
-+CURLSHcode Curl_share_lock_share(struct Curl_share *share,
-+ struct Curl_easy *data,
-+ curl_lock_data type,
-+ curl_lock_access accesstype);
-+CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
-+ struct Curl_easy *data,
-+ curl_lock_data type);
-+
- /* convenience macro to check if this handle is using a shared SSL spool */
- #define CURL_SHARE_ssl_scache(data) (data->share && \
- (data->share->specifier & \
-diff --git a/lib/curl_trc.c b/lib/curl_trc.c
-index 565d1b45f0..6be80f0910 100644
---- a/lib/curl_trc.c
-+++ b/lib/curl_trc.c
-@@ -90,8 +90,7 @@ static struct curl_trc_feat Curl_trc_feat_ids = {
-
- static size_t trc_print_ids(struct Curl_easy *data, char *buf, size_t maxlen)
- {
-- curl_off_t cid = data->conn ?
-- data->conn->connection_id : data->state.recent_conn_id;
-+ curl_off_t cid = data->state.lastconnect_id;
- if(data->id >= 0) {
- if(cid >= 0)
- return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
-diff --git a/lib/easy.c b/lib/easy.c
-index 398b20edd1..dc6a83617f 100644
---- a/lib/easy.c
-+++ b/lib/easy.c
-@@ -977,7 +977,6 @@ CURL *curl_easy_duphandle(CURL *d)
-
- /* the connection pool is setup on demand */
- outcurl->state.lastconnect_id = -1;
-- outcurl->state.recent_conn_id = -1;
- outcurl->id = -1;
- outcurl->mid = UINT32_MAX;
- outcurl->master_mid = UINT32_MAX;
-@@ -1109,7 +1108,7 @@ void curl_easy_reset(CURL *d)
-
- data->progress.hide = TRUE;
- data->state.current_speed = -1; /* init to negative == impossible */
-- data->state.recent_conn_id = -1; /* clear remembered connection id */
-+ data->state.lastconnect_id = -1; /* clear remembered connection id */
-
- /* zero out authentication data: */
- memset(&data->state.authhost, 0, sizeof(struct auth));
-@@ -1240,7 +1239,7 @@ CURLcode curl_easy_recv(CURL *d, void *buffer, size_t buflen, size_t *n)
- if(!data->conn)
- /* on first invoke, the transfer has been detached from the connection and
- needs to be reattached */
-- Curl_attach_connection(data, c);
-+ Curl_attach_connection(data, c, TRUE);
-
- *n = 0;
- return Curl_conn_recv(data, FIRSTSOCKET, buffer, buflen, n);
-@@ -1259,7 +1258,7 @@ CURLcode Curl_connect_only_attach(struct Curl_easy *data)
- if(!data->conn)
- /* on first invoke, the transfer has been detached from the connection and
- needs to be reattached */
-- Curl_attach_connection(data, c);
-+ Curl_attach_connection(data, c, TRUE);
-
- return CURLE_OK;
- }
-@@ -1285,7 +1284,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
- if(!data->conn)
- /* on first invoke, the transfer has been detached from the connection and
- needs to be reattached */
-- Curl_attach_connection(data, c);
-+ Curl_attach_connection(data, c, TRUE);
-
- sigpipe_ignore(data, &pipe_st);
- result = Curl_conn_send(data, FIRSTSOCKET, buffer, buflen, FALSE, n);
-diff --git a/lib/getinfo.c b/lib/getinfo.c
-index e094ffd134..67b9eeb76c 100644
---- a/lib/getinfo.c
-+++ b/lib/getinfo.c
-@@ -463,8 +463,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
- *param_offt = data->id;
- break;
- case CURLINFO_CONN_ID:
-- *param_offt = data->conn ?
-- data->conn->connection_id : data->state.recent_conn_id;
-+ *param_offt = data->state.lastconnect_id;
- break;
- case CURLINFO_EARLYDATA_SENT_T:
- *param_offt = data->progress.earlydata_sent;
-diff --git a/lib/multi.c b/lib/multi.c
-index 6db86abda2..7691c92629 100644
---- a/lib/multi.c
-+++ b/lib/multi.c
-@@ -280,7 +280,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
- if(Curl_cshutdn_init(&multi->cshutdn, multi))
- goto error;
-
-- Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize);
-+ Curl_cpool_init(&multi->cpool, NULL, chashsize);
-
- #ifdef USE_SSL
- if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
-@@ -307,7 +307,7 @@ error:
- Curl_multi_ev_cleanup(multi);
- Curl_hash_destroy(&multi->proto_hash);
- Curl_dnscache_destroy(&multi->dnscache);
-- Curl_cpool_destroy(&multi->cpool);
-+ Curl_cpool_destroy(&multi->cpool, multi->admin);
- Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
- #ifdef USE_SSL
- Curl_ssl_scache_destroy(multi->ssl_scache);
-@@ -617,7 +617,6 @@ static void multi_done_locked(struct connectdata *conn,
- }
-
- data->state.done = TRUE; /* called just now! */
-- data->state.recent_conn_id = conn->connection_id;
-
- Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
- Curl_resolv_unlink(data, &data->state.dns[1]);
-@@ -646,7 +645,6 @@ static void multi_done_locked(struct connectdata *conn,
- /* the connection is no longer in use by any transfer */
- if(Curl_cpool_conn_now_idle(data, conn)) {
- /* connection kept in the cpool */
-- data->state.lastconnect_id = conn->connection_id;
- #ifndef CURL_DISABLE_VERBOSE_STRINGS
- infof(data, "Connection #%" FMT_OFF_T " to host %s:%d left intact",
- conn->connection_id, host, port);
-@@ -654,7 +652,6 @@ static void multi_done_locked(struct connectdata *conn,
- }
- else {
- /* connection was removed from the cpool and destroyed. */
-- data->state.lastconnect_id = -1;
- }
- }
- }
-@@ -917,16 +914,21 @@ void Curl_detach_connection(struct Curl_easy *data)
- /*
- * Curl_attach_connection() attaches this transfer to this connection.
- *
-- * This is the only function that should assign data->conn
-+ * This is the only function that should assign data->conn.
-+ * `matched == TRUE` means the transfer's properties match this
-+ * connection and it is not a temporary attach for maintenance.
- */
- void Curl_attach_connection(struct Curl_easy *data,
-- struct connectdata *conn)
-+ struct connectdata *conn,
-+ bool matched)
- {
- DEBUGASSERT(data);
- DEBUGASSERT(!data->conn);
- DEBUGASSERT(conn);
- DEBUGASSERT(conn->attached_xfers < UINT32_MAX);
- data->conn = conn;
-+ if(matched)
-+ data->state.lastconnect_id = conn->connection_id;
- conn->attached_xfers++;
- /* all attached transfers must be from the same multi */
- if(!conn->attached_multi)
-@@ -1259,7 +1261,7 @@ CURLMcode curl_multi_fdset(CURLM *m,
- } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
- }
-
-- Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
-+ Curl_cshutdn_setfds(&multi->cshutdn,
- read_fd_set, write_fd_set, &this_max_fd);
-
- *max_fd = this_max_fd;
-@@ -1305,7 +1307,7 @@ CURLMcode curl_multi_waitfds(CURLM *m,
- } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
- }
-
-- need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
-+ need += Curl_cshutdn_add_waitfds(&multi->cshutdn, &cwfds);
-
- if(need != cwfds.n && ufds)
- mresult = CURLM_OUT_OF_MEMORY;
-@@ -1392,7 +1394,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
- } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
- }
-
-- if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
-+ if(Curl_cshutdn_add_pollfds(&multi->cshutdn, &cpfds)) {
- mresult = CURLM_OUT_OF_MEMORY;
- goto out;
- }
-@@ -1717,7 +1719,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
-
- /* take this handle to the perform state right away */
- multistate(data, MSTATE_PERFORMING);
-- Curl_attach_connection(data, conn);
-+ Curl_attach_connection(data, conn, TRUE);
- k->keepon |= KEEP_RECV; /* setup to receive! */
- }
- return mresult;
-@@ -2893,7 +2895,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
- } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
- }
-
-- Curl_cpool_destroy(&multi->cpool);
-+ Curl_cpool_destroy(&multi->cpool, multi->admin);
- Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
- if(multi->admin) {
- CURL_TRC_M(multi->admin, "multi_cleanup, closing admin handle, done");
-@@ -3277,7 +3279,7 @@ CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
- Curl_dnscache_clear(multi->admin);
- }
- if(val & CURLMNWC_CLEAR_CONNS) {
-- Curl_cpool_nw_changed(multi->admin);
-+ Curl_cpool_nw_changed(&multi->cpool, multi->admin);
- }
- break;
- }
-diff --git a/lib/multiif.h b/lib/multiif.h
-index f368639857..9054dc6a66 100644
---- a/lib/multiif.h
-+++ b/lib/multiif.h
-@@ -34,7 +34,8 @@ void Curl_expire_clear(struct Curl_easy *data);
- void Curl_expire_done(struct Curl_easy *data, expire_id id);
- CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
- void Curl_attach_connection(struct Curl_easy *data,
-- struct connectdata *conn);
-+ struct connectdata *conn,
-+ bool matched);
- void Curl_detach_connection(struct Curl_easy *data);
- bool Curl_multiplex_wanted(const struct Curl_multi *multi);
- void Curl_set_in_callback(struct Curl_easy *data, bool value);
-diff --git a/lib/url.c b/lib/url.c
-index c3fb1439ca..6e42ca0ec4 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -482,7 +482,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
- data->magic = CURLEASY_MAGIC_NUMBER;
- /* most recent connection is not yet defined */
- data->state.lastconnect_id = -1;
-- data->state.recent_conn_id = -1;
-+ data->state.lastconnect_id = -1;
- /* and not assigned an id yet */
- data->id = -1;
- data->mid = UINT32_MAX;
-@@ -658,7 +658,7 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
-
- /* briefly attach the connection to this transfer for the purpose of
- checking it */
-- Curl_attach_connection(data, conn);
-+ Curl_attach_connection(data, conn, FALSE);
-
- state = conn->handler->connection_check(data, conn, CONNCHECK_ISDEAD);
- dead = (state & CONNRESULT_DEAD);
-@@ -668,7 +668,7 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
- else {
- bool input_pending = FALSE;
-
-- Curl_attach_connection(data, conn);
-+ Curl_attach_connection(data, conn, FALSE);
- dead = !Curl_conn_is_alive(data, conn, &input_pending);
- if(input_pending) {
- /* For reuse, we want a "clean" connection state. The includes
-@@ -704,7 +704,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data,
- return result;
-
- /* briefly attach for action */
-- Curl_attach_connection(data, conn);
-+ Curl_attach_connection(data, conn, FALSE);
- if(conn->handler->connection_check) {
- /* Do a protocol-specific keepalive check on the connection. */
- unsigned int rc;
-@@ -1306,7 +1306,7 @@ static bool url_match_result(bool result, void *userdata)
- if(match->found) {
- /* Attach it now while still under lock, so the connection does
- * no longer appear idle and can be reaped. */
-- Curl_attach_connection(match->data, match->found);
-+ Curl_attach_connection(match->data, match->found, TRUE);
- return TRUE;
- }
- else if(match->seen_single_use_conn && !match->seen_multiplex_conn) {
-@@ -3656,8 +3656,8 @@ static CURLcode create_conn(struct Curl_easy *data,
- goto out;
-
- /* Setup a "faked" transfer that will do nothing */
-- Curl_attach_connection(data, conn);
- result = Curl_cpool_add(data, conn);
-+ Curl_attach_connection(data, conn, TRUE);
- if(!result) {
- /* Setup whatever necessary for a resumed transfer */
- result = setup_range(data);
-@@ -3688,7 +3688,10 @@ static CURLcode create_conn(struct Curl_easy *data,
- if(result)
- goto out;
-
-- Curl_cpool_prune_dead(data);
-+ {
-+ struct cpool *cpool = Curl_cpool_get_instance(data);
-+ Curl_cpool_prune_dead(cpool, data);
-+ }
-
- /*************************************************************
- * Check the current list of connections to see if we can
-@@ -3795,8 +3798,8 @@ static CURLcode create_conn(struct Curl_easy *data,
- goto out;
- }
-
-- Curl_attach_connection(data, conn);
- result = Curl_cpool_add(data, conn);
-+ Curl_attach_connection(data, conn, TRUE);
- if(result)
- goto out;
- }
-@@ -4021,6 +4024,31 @@ CURLcode Curl_1st_err(CURLcode r1, CURLcode r2)
- return r1 ? r1 : r2;
- }
-
-+struct Curl_easy *Curl_get_admin(struct Curl_easy *data)
-+{
-+ struct Curl_easy *admin;
-+
-+ if(!data->mid) /* already an admin handle */
-+ admin = data;
-+ else if(data->multi)
-+ admin = data->multi->admin;
-+ else if(data->multi_easy)
-+ admin = data->multi_easy->admin;
-+ else {
-+ DEBUGASSERT(0); /* we do not want this. does it happen? */
-+ admin = data;
-+ }
-+ if(admin != data) {
-+ admin->set.conn_max_idle_ms = data->set.conn_max_idle_ms;
-+ admin->set.conn_max_age_ms = data->set.conn_max_age_ms;
-+ admin->set.upkeep_interval_ms = data->set.upkeep_interval_ms;
-+ admin->set.timeout = data->set.timeout;
-+ admin->set.server_response_timeout = data->set.server_response_timeout;
-+ admin->set.no_signal = data->set.no_signal;
-+ }
-+ return admin;
-+}
-+
- CURLcode Curl_1st_fatal(CURLcode r1, CURLcode r2)
- {
- if(r1 && (r1 != CURLE_AGAIN))
-diff --git a/lib/url.h b/lib/url.h
-index ddac784e75..3796a1f899 100644
---- a/lib/url.h
-+++ b/lib/url.h
-@@ -75,6 +75,12 @@ const struct Curl_handler *Curl_get_scheme_handler(const char *scheme);
- const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme,
- size_t len);
-
-+/* Get an admin handle for internal operations from the given
-+ * easy handle, if possible. The admin handle inherits certain
-+ * properties from `data`. If no admin handle is available (not multi
-+ * or share attached), the easy handle itself is returned. */
-+struct Curl_easy *Curl_get_admin(struct Curl_easy *data);
-+
- #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
- #define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
- specified */
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 318dfdb84c..1e527826ca 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -931,9 +931,7 @@ struct UrlState {
- /* buffers to store authentication data in, as parsed from input options */
- struct curltime keeps_speed; /* for the progress meter really */
-
-- curl_off_t lastconnect_id; /* The last connection, -1 if undefined */
-- curl_off_t recent_conn_id; /* The most recent connection used, might no
-- * longer exist */
-+ curl_off_t lastconnect_id; /* The last assigned connection or -1 */
- struct dynbuf headerb; /* buffer to store headers in */
- struct curl_slist *hstslist; /* list of HSTS files set by
- curl_easy_setopt(HSTS) calls */
-diff --git a/tests/data/test1554 b/tests/data/test1554
-index fa071b09b2..f87b23371e 100644
---- a/tests/data/test1554
-+++ b/tests/data/test1554
-@@ -68,7 +68,9 @@ run 1: foobar and so on fun!
- -] Mutex lock SHARE
- [- Mutex unlock SHARE
- -] Mutex lock SHARE
--[- Mutex unlock SHARE
-+-] Mutex lock CONNECT
-+[- Mutex unlock CONNECT
-+[- Mutex unlock SHARE
- </datacheck>
- </reply>
-
---
-2.56.0
-
diff --git a/0029-openssl-avoid-conn-reuse-if-provider-is-used.patch b/0029-openssl-avoid-conn-reuse-if-provider-is-used.patch
new file mode 100644
index 0000000..513bd4c
--- /dev/null
+++ b/0029-openssl-avoid-conn-reuse-if-provider-is-used.patch
@@ -0,0 +1,30 @@
+From 0ee361c65fe982a1294f66e6d10cd63b7294da70 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 25 Aug 2026 11:14:30 +0200
+Subject: [PATCH] openssl: avoid conn reuse if provider is used
+
+Reported-by: Stanislav Fort
+
+Closes #22665
+
+(cherry picked from commit 7ea37abc6ac0120ba5f6d94be8d196f7cf1506bb)
+---
+ lib/vtls/openssl.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index f044c10e14..600a64ca6a 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -3717,6 +3717,11 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+ ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
+ return CURLE_OUT_OF_MEMORY;
+ }
++#ifdef OPENSSL_HAS_PROVIDERS
++ if(data->state.libctx)
++ /* forbid connection reuse with provider/engine use */
++ connclose(data->conn, "provider in use");
++#endif
+
+ if(cb_setup) {
+ result = cb_setup(cf, data, cb_user_data);
diff --git a/0030-connections-use-admin-handles-only-for-maintenance.patch b/0030-connections-use-admin-handles-only-for-maintenance.patch
new file mode 100644
index 0000000..8db07bd
--- /dev/null
+++ b/0030-connections-use-admin-handles-only-for-maintenance.patch
@@ -0,0 +1,1611 @@
+From 7e77dcb1b663491be44ddff67b58ef5c0e138b2a Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Thu, 8 Oct 2026 10:10:56 +0200
+Subject: [PATCH] connections: use admin handles only for maintenance
+
+Maintenance tasks like connection upkeep, liveliness checks and cache
+eviction must only run on an admin handle, not the application transfer
+from the calling context.
+
+Then application transfers will get only attached to the connections
+they actually work on. This makes `data->state.lastconnect_id`
+meaningful for checks if a subsequent address is finding the previous
+connection again.
+
+One thing led to another:
+- add Curl_get_admin(data), to obtain an admin handle for
+ an application handle, inheriting some properties for
+ connection operation.
+- rename `Curl_easy *data` parameter to `Curl_easy *admin`
+ where only admin handles should be passed. Add DEBUGASSERTs
+ in the called function.
+- add Curl_share_lock_share(), Curl_share_unlock_share()
+ so it possible to operate on a share without the passed
+ easy handle having the share set.
+ This catches a case where a shared needed to be locked
+ but was not before. Adjust test1554 results.
+
+Fixes #22567
+Reported-by: cybertron10 on github
+Closes #22572
+
+(cherry picked from commit 7103a93b05bc69ea98ed9d05d02fa9eeba533f2f)
+Co-authored-by: Cursor <cursoragent@cursor.com>
+---
+ lib/conncache.c | 190 ++++++++++++++++++++++++++++----------------
+ lib/conncache.h | 23 +++---
+ lib/cshutdn.c | 166 +++++++++++++++++++-------------------
+ lib/cshutdn.h | 28 +++----
+ lib/curl_share.c | 28 +++++--
+ lib/curl_share.h | 8 ++
+ lib/curl_trc.c | 3 +-
+ lib/easy.c | 9 +--
+ lib/getinfo.c | 3 +-
+ lib/multi.c | 28 ++++---
+ lib/multiif.h | 3 +-
+ lib/url.c | 44 ++++++++--
+ lib/url.h | 6 ++
+ lib/urldata.h | 4 +-
+ tests/data/test1554 | 2 +
+ 15 files changed, 325 insertions(+), 220 deletions(-)
+
+diff --git a/lib/conncache.c b/lib/conncache.c
+index 1a3dba7f63..a152f95b60 100644
+--- a/lib/conncache.c
++++ b/lib/conncache.c
+@@ -45,7 +45,7 @@
+ do { \
+ if(c) { \
+ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
+- Curl_share_lock((d), CURL_LOCK_DATA_CONNECT, \
++ Curl_share_lock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT, \
+ CURL_LOCK_ACCESS_SINGLE); \
+ DEBUGASSERT(!(c)->locked); \
+ (c)->locked = TRUE; \
+@@ -58,7 +58,7 @@
+ DEBUGASSERT((c)->locked); \
+ (c)->locked = FALSE; \
+ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
+- Curl_share_unlock((d), CURL_LOCK_DATA_CONNECT); \
++ Curl_share_unlock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT); \
+ } \
+ } while(0)
+
+@@ -74,6 +74,15 @@ static void cpool_discard_conn(struct cpool *cpool,
+ struct connectdata *conn,
+ bool aborted);
+
++static void cpool_conn_close(struct cpool *cpool,
++ struct Curl_easy *data,
++ struct connectdata *conn,
++ bool aborted);
++
++static void cpool_evict_conn(struct cpool *cpool,
++ struct Curl_easy *admin,
++ struct connectdata *conn);
++
+ static struct cpool_bundle *cpool_bundle_create(const char *dest)
+ {
+ struct cpool_bundle *bundle;
+@@ -119,16 +128,12 @@ static void cpool_bundle_free_entry(void *freethis)
+ }
+
+ void Curl_cpool_init(struct cpool *cpool,
+- struct Curl_easy *idata,
+ struct Curl_share *share,
+ size_t size)
+ {
+ Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
+ curlx_str_key_compare, cpool_bundle_free_entry);
+
+- DEBUGASSERT(idata);
+-
+- cpool->idata = idata;
+ cpool->share = share;
+ cpool->initialised = TRUE;
+ }
+@@ -189,25 +194,25 @@ static void cpool_remove_conn(struct cpool *cpool,
+ }
+ }
+
+-void Curl_cpool_destroy(struct cpool *cpool)
++void Curl_cpool_destroy(struct cpool *cpool, struct Curl_easy *admin)
+ {
+- if(cpool && cpool->initialised && cpool->idata) {
++ if(cpool && cpool->initialised && admin) {
+ struct connectdata *conn;
+ SIGPIPE_VARIABLE(pipe_st);
+
+- CURL_TRC_M(cpool->idata, "%s[CPOOL] destroy, %zu connections",
++ CURL_TRC_M(admin, "%s[CPOOL] destroy, %zu connections",
+ cpool->share ? "[SHARE] " : "", cpool->num_conn);
+ /* Move all connections to the shutdown list */
+ sigpipe_init(&pipe_st);
+- CPOOL_LOCK(cpool, cpool->idata);
++ CPOOL_LOCK(cpool, admin);
+ conn = cpool_get_first(cpool);
+ while(conn) {
+ cpool_remove_conn(cpool, conn);
+- sigpipe_apply(cpool->idata, &pipe_st);
+- cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
++ sigpipe_apply(admin, &pipe_st);
++ cpool_discard_conn(cpool, admin, conn, FALSE);
+ conn = cpool_get_first(cpool);
+ }
+- CPOOL_UNLOCK(cpool, cpool->idata);
++ CPOOL_UNLOCK(cpool, admin);
+ sigpipe_restore(&pipe_st);
+ Curl_hash_destroy(&cpool->dest2bundle);
+ }
+@@ -226,6 +231,11 @@ static struct cpool *cpool_get_instance(struct Curl_easy *data)
+ return NULL;
+ }
+
++struct cpool *Curl_cpool_get_instance(struct Curl_easy *data)
++{
++ return cpool_get_instance(data);
++}
++
+ void Curl_cpool_xfer_init(struct Curl_easy *data)
+ {
+ struct cpool *cpool = cpool_get_instance(data);
+@@ -327,10 +337,28 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool,
+ return oldest_idle;
+ }
+
++/* Evict an idle connection to make room in the pool. A pool owned by
++ * a share has no multi that could perform a controlled shutdown of the
++ * connection; terminate it right away. Otherwise, hand it to the
++ * transfer's multi for shutdown. Expects the pool to be locked. */
++static void cpool_evict_conn(struct cpool *cpool,
++ struct Curl_easy *admin,
++ struct connectdata *conn)
++{
++ if(cpool->share) {
++ cpool_remove_conn(cpool, conn);
++ Curl_cshutdn_terminate(admin, conn, TRUE);
++ }
++ else
++ cpool_conn_close(cpool, admin, conn, FALSE);
++}
++
+ int Curl_cpool_check_limits(struct Curl_easy *data,
+ struct connectdata *conn)
+ {
+ struct cpool *cpool = cpool_get_instance(data);
++ struct cshutdn *cshutdn = Curl_cshutdn_get(data);
++ struct Curl_easy *admin;
+ struct cpool_bundle *bundle;
+ size_t dest_limit = 0;
+ size_t total_limit = 0;
+@@ -340,25 +368,26 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+ if(!cpool)
+ return CPOOL_LIMIT_OK;
+
+- if(cpool->idata->multi) {
+- dest_limit = cpool->idata->multi->max_host_connections;
+- total_limit = cpool->idata->multi->max_total_connections;
++ if(data->multi) {
++ dest_limit = data->multi->max_host_connections;
++ total_limit = data->multi->max_total_connections;
+ }
+
+ if(!dest_limit && !total_limit)
+ return CPOOL_LIMIT_OK;
+
+- CPOOL_LOCK(cpool, cpool->idata);
++ admin = Curl_get_admin(data);
++ CPOOL_LOCK(cpool, admin);
+ if(dest_limit) {
+ size_t live;
+
+ bundle = cpool_find_bundle(cpool, conn);
+ live = bundle ? Curl_llist_count(&bundle->conns) : 0;
+- shutdowns = Curl_cshutdn_dest_count(data, conn->destination);
++ shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
+ while((live + shutdowns) >= dest_limit) {
+ if(shutdowns) {
+ /* close one connection in shutdown right away, if we can */
+- if(!Curl_cshutdn_close_oldest(data, conn->destination))
++ if(!Curl_cshutdn_close_oldest(cshutdn, conn->destination))
+ break;
+ }
+ else if(!bundle)
+@@ -372,17 +401,17 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+ if(!oldest_idle)
+ break;
+ /* disconnect the old conn and continue */
+- CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
++ CURL_TRC_M(admin, "Discarding connection #%" FMT_OFF_T
+ " from %zu to reach destination limit of %zu",
+ oldest_idle->connection_id,
+ Curl_llist_count(&bundle->conns), dest_limit);
+- Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
++ cpool_evict_conn(cpool, admin, oldest_idle);
+
+ /* in case the bundle was destroyed in disconnect, look it up again */
+ bundle = cpool_find_bundle(cpool, conn);
+ live = bundle ? Curl_llist_count(&bundle->conns) : 0;
+ }
+- shutdowns = Curl_cshutdn_dest_count(cpool->idata, conn->destination);
++ shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
+ }
+ if((live + shutdowns) >= dest_limit) {
+ result = CPOOL_LIMIT_DEST;
+@@ -391,11 +420,11 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+ }
+
+ if(total_limit) {
+- shutdowns = Curl_cshutdn_count(cpool->idata);
++ shutdowns = Curl_cshutdn_count(cshutdn);
+ while((cpool->num_conn + shutdowns) >= total_limit) {
+ if(shutdowns) {
+ /* close one connection in shutdown right away, if we can */
+- if(!Curl_cshutdn_close_oldest(data, NULL))
++ if(!Curl_cshutdn_close_oldest(cshutdn, NULL))
+ break;
+ }
+ else {
+@@ -404,13 +433,13 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+ if(!oldest_idle)
+ break;
+ /* disconnect the old conn and continue */
+- CURL_TRC_M(data, "Discarding connection #%"
++ CURL_TRC_M(admin, "Discarding connection #%"
+ FMT_OFF_T " from %zu to reach total "
+ "limit of %zu",
+ oldest_idle->connection_id, cpool->num_conn, total_limit);
+- Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
++ cpool_evict_conn(cpool, admin, oldest_idle);
+ }
+- shutdowns = Curl_cshutdn_count(cpool->idata);
++ shutdowns = Curl_cshutdn_count(cshutdn);
+ }
+ if((cpool->num_conn + shutdowns) >= total_limit) {
+ result = CPOOL_LIMIT_TOTAL;
+@@ -419,7 +448,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+ }
+
+ out:
+- CPOOL_UNLOCK(cpool, cpool->idata);
++ CPOOL_UNLOCK(cpool, admin);
+ return result;
+ }
+
+@@ -472,7 +501,8 @@ out:
+ static bool cpool_foreach(struct Curl_easy *data,
+ struct cpool *cpool,
+ void *param,
+- int (*func)(struct Curl_easy *data,
++ int (*func)(struct cpool *cpool,
++ struct Curl_easy *data,
+ struct connectdata *conn, void *param))
+ {
+ struct Curl_hash_iterator iter;
+@@ -496,7 +526,7 @@ static bool cpool_foreach(struct Curl_easy *data,
+ struct connectdata *conn = Curl_node_elem(curr);
+ curr = Curl_node_next(curr);
+
+- if(func(data, conn, param) == 1) {
++ if(func(cpool, data, conn, param) == 1) {
+ return TRUE;
+ }
+ }
+@@ -533,8 +563,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+ if(cpool && maxconnects) {
+ /* may be called form a callback already under lock */
+ bool do_lock = !CPOOL_IS_LOCKED(cpool);
++ struct Curl_easy *admin;
++
++ admin = Curl_get_admin(data);
+ if(do_lock)
+- CPOOL_LOCK(cpool, data);
++ CPOOL_LOCK(cpool, admin);
+ if(cpool->num_conn > maxconnects) {
+ infof(data, "Connection pool is full, closing the oldest of %zu/%u",
+ cpool->num_conn, maxconnects);
+@@ -542,11 +575,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+ oldest_idle = cpool_get_oldest_idle(cpool, Curl_pgrs_now(data));
+ kept = (oldest_idle != conn);
+ if(oldest_idle) {
+- Curl_conn_terminate(data, oldest_idle, FALSE);
++ cpool_evict_conn(cpool, admin, oldest_idle);
+ }
+ }
+ if(do_lock)
+- CPOOL_UNLOCK(cpool, data);
++ CPOOL_UNLOCK(cpool, admin);
+ }
+
+ return kept;
+@@ -597,6 +630,8 @@ static void cpool_discard_conn(struct cpool *cpool,
+ struct connectdata *conn,
+ bool aborted)
+ {
++ struct cshutdn *cshutdn;
++ struct Curl_easy *admin;
+ bool done = FALSE;
+
+ DEBUGASSERT(data);
+@@ -604,12 +639,13 @@ static void cpool_discard_conn(struct cpool *cpool,
+ DEBUGASSERT(cpool);
+ DEBUGASSERT(!conn->bits.in_cpool);
+
++ admin = Curl_get_admin(data);
+ /*
+ * If this connection is not marked to force-close, leave it open if there
+ * are other users of it
+ */
+ if(CONN_INUSE(conn) && !aborted) {
+- CURL_TRC_M(data, "[CPOOL] not discarding #%" FMT_OFF_T
++ CURL_TRC_M(admin, "[CPOOL] not discarding #%" FMT_OFF_T
+ " still in use by %u transfers", conn->connection_id,
+ conn->attached_xfers);
+ return;
+@@ -630,20 +666,22 @@ static void cpool_discard_conn(struct cpool *cpool,
+ done = TRUE;
+ if(!done) {
+ /* Attempt to shutdown the connection right away. */
+- Curl_cshutdn_run_once(cpool->idata, conn, &done);
++ Curl_conn_shutdown_once(admin, conn, &done);
+ }
+
+- if(done || !data->multi)
+- Curl_cshutdn_terminate(cpool->idata, conn, FALSE);
++ cshutdn = Curl_cshutdn_get(data);
++ if(done || !cshutdn)
++ Curl_cshutdn_terminate(admin, conn, FALSE);
+ else
+- Curl_cshutdn_add(&data->multi->cshutdn, conn, cpool->num_conn);
++ Curl_cshutdn_add(cshutdn, conn, cpool->num_conn);
+ }
+
+-void Curl_conn_terminate(struct Curl_easy *data,
+- struct connectdata *conn,
+- bool aborted)
++static void cpool_conn_close(struct cpool *cpool,
++ struct Curl_easy *data,
++ struct connectdata *conn,
++ bool aborted)
+ {
+- struct cpool *cpool = cpool_get_instance(data);
++ struct Curl_easy *admin;
+ bool do_lock;
+
+ DEBUGASSERT(cpool);
+@@ -661,9 +699,10 @@ void Curl_conn_terminate(struct Curl_easy *data,
+
+ /* This method may be called while we are under lock, e.g. from a
+ * user callback in find. */
++ admin = Curl_get_admin(data);
+ do_lock = !CPOOL_IS_LOCKED(cpool);
+ if(do_lock)
+- CPOOL_LOCK(cpool, data);
++ CPOOL_LOCK(cpool, admin);
+
+ if(conn->bits.in_cpool) {
+ cpool_remove_conn(cpool, conn);
+@@ -684,11 +723,19 @@ void Curl_conn_terminate(struct Curl_easy *data,
+ else {
+ /* No multi available, terminate */
+ infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
+- Curl_cshutdn_terminate(cpool->idata, conn, !aborted);
++ Curl_cshutdn_terminate(admin, conn, !aborted);
+ }
+
+ if(do_lock)
+- CPOOL_UNLOCK(cpool, data);
++ CPOOL_UNLOCK(cpool, admin);
++}
++
++void Curl_conn_terminate(struct Curl_easy *data,
++ struct connectdata *conn,
++ bool aborted)
++{
++ struct cpool *cpool = cpool_get_instance(data);
++ cpool_conn_close(cpool, data, conn, aborted);
+ }
+
+ struct cpool_reaper_ctx {
+@@ -696,7 +743,8 @@ struct cpool_reaper_ctx {
+ size_t reaped;
+ };
+
+-static int cpool_reap_dead_cb(struct Curl_easy *data,
++static int cpool_reap_dead_cb(struct cpool *cpool,
++ struct Curl_easy *admin,
+ struct connectdata *conn, void *param)
+ {
+ struct cpool_reaper_ctx *reaper = param;
+@@ -704,12 +752,12 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
+
+ if(!terminate) {
+ reaper->checked++;
+- terminate = Curl_conn_seems_dead(conn, data);
++ terminate = Curl_conn_seems_dead(conn, admin);
+ }
+ if(terminate) {
+ /* stop the iteration here, pass back the connection that was pruned */
+ reaper->reaped++;
+- Curl_conn_terminate(data, conn, FALSE);
++ cpool_conn_close(cpool, admin, conn, FALSE);
+ return 1;
+ }
+ return 0; /* continue iteration */
+@@ -722,31 +770,35 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
+ *
+ * When called, this transfer has no connection attached.
+ */
+-void Curl_cpool_prune_dead(struct Curl_easy *data)
++void Curl_cpool_prune_dead(struct cpool *cpool,
++ struct Curl_easy *data)
+ {
+- struct cpool *cpool = cpool_get_instance(data);
++ struct Curl_easy *admin;
+ struct cpool_reaper_ctx reaper;
+ timediff_t elapsed;
+
+ if(!cpool)
+ return;
+
++ admin = Curl_get_admin(data);
+ memset(&reaper, 0, sizeof(reaper));
+- CPOOL_LOCK(cpool, data);
++ CPOOL_LOCK(cpool, admin);
+ elapsed = curlx_ptimediff_ms(Curl_pgrs_now(data), &cpool->last_cleanup);
+
+ if(elapsed >= 1000L) {
+- while(cpool_foreach(data, cpool, &reaper, cpool_reap_dead_cb))
++ while(cpool_foreach(admin, cpool, &reaper, cpool_reap_dead_cb))
+ ;
+ cpool->last_cleanup = *Curl_pgrs_now(data);
+ }
+- CPOOL_UNLOCK(cpool, data);
++ CPOOL_UNLOCK(cpool, admin);
+ }
+
+-static int conn_upkeep(struct Curl_easy *data,
++static int conn_upkeep(struct cpool *cpool,
++ struct Curl_easy *data,
+ struct connectdata *conn,
+ void *param)
+ {
++ (void)cpool;
+ (void)param;
+ Curl_conn_upkeep(data, conn);
+ return 0; /* continue iteration */
+@@ -770,10 +822,12 @@ struct cpool_find_ctx {
+ struct connectdata *conn;
+ };
+
+-static int cpool_find_conn(struct Curl_easy *data,
++static int cpool_find_conn(struct cpool *cpool,
++ struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+ {
+ struct cpool_find_ctx *fctx = param;
++ (void)cpool;
+ (void)data;
+ if(conn->connection_id == fctx->id) {
+ fctx->conn = conn;
+@@ -804,10 +858,12 @@ struct cpool_do_conn_ctx {
+ void *cbdata;
+ };
+
+-static int cpool_do_conn(struct Curl_easy *data,
++static int cpool_do_conn(struct cpool *cpool,
++ struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+ {
+ struct cpool_do_conn_ctx *dctx = param;
++ (void)cpool;
+ (void)data;
+ if(conn->connection_id == dctx->id) {
+ dctx->cb(conn, data, dctx->cbdata);
+@@ -846,37 +902,37 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
+ cb(conn, data, cbdata);
+ }
+
+-static int cpool_mark_stale(struct Curl_easy *data,
++static int cpool_mark_stale(struct cpool *cpool,
++ struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+ {
++ (void)cpool;
+ (void)data;
+ (void)param;
+ conn->bits.no_reuse = TRUE;
+ return 0;
+ }
+
+-static int cpool_reap_no_reuse(struct Curl_easy *data,
++static int cpool_reap_no_reuse(struct cpool *cpool,
++ struct Curl_easy *admin,
+ struct connectdata *conn, void *param)
+ {
+- (void)data;
+ (void)param;
+ if(!CONN_INUSE(conn) && conn->bits.no_reuse) {
+- Curl_conn_terminate(data, conn, FALSE);
++ cpool_conn_close(cpool, admin, conn, FALSE);
+ return 1;
+ }
+ return 0; /* continue iteration */
+ }
+
+-void Curl_cpool_nw_changed(struct Curl_easy *data)
++void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin)
+ {
+- struct cpool *cpool = cpool_get_instance(data);
+-
+ if(cpool) {
+- CPOOL_LOCK(cpool, data);
+- cpool_foreach(data, cpool, NULL, cpool_mark_stale);
+- while(cpool_foreach(data, cpool, NULL, cpool_reap_no_reuse))
++ CPOOL_LOCK(cpool, admin);
++ cpool_foreach(admin, cpool, NULL, cpool_mark_stale);
++ while(cpool_foreach(admin, cpool, NULL, cpool_reap_no_reuse))
+ ;
+- CPOOL_UNLOCK(cpool, data);
++ CPOOL_UNLOCK(cpool, admin);
+ }
+ }
+
+diff --git a/lib/conncache.h b/lib/conncache.h
+index 9b392af05c..4acefb0f9e 100644
+--- a/lib/conncache.h
++++ b/lib/conncache.h
+@@ -34,7 +34,7 @@ struct Curl_multi;
+ struct Curl_share;
+
+ /**
+- * Terminate the connection, e.g. close and destroy.
++ * Close and destroy the connection.
+ * If the connection is in a cpool, remove it.
+ * If a `cshutdn` is available (e.g. data has a multi handle),
+ * pass the connection to that for controlled shutdown.
+@@ -43,8 +43,8 @@ struct Curl_share;
+ * `data` should not be attached to a connection.
+ */
+ void Curl_conn_terminate(struct Curl_easy *data,
+- struct connectdata *conn,
+- bool aborted);
++ struct connectdata *conn,
++ bool aborted);
+
+ struct cpool {
+ /* the pooled connections, bundled per destination */
+@@ -53,22 +53,24 @@ struct cpool {
+ curl_off_t next_connection_id;
+ curl_off_t next_easy_id;
+ struct curltime last_cleanup;
+- struct Curl_easy *idata; /* internal handle for maintenance */
+ struct Curl_share *share; /* != NULL if pool belongs to share */
+ BIT(locked);
+ BIT(initialised);
+ };
+
++/* Get connection pool instance for data or NULL if none exists */
++struct cpool *Curl_cpool_get_instance(struct Curl_easy *data);
++
+ /* Init the pool, pass multi only if pool is owned by it.
+ * Cannot fail.
+ */
+ void Curl_cpool_init(struct cpool *cpool,
+- struct Curl_easy *idata,
+ struct Curl_share *share,
+ size_t size);
+
+ /* Destroy all connections and free all members */
+-void Curl_cpool_destroy(struct cpool *connc);
++void Curl_cpool_destroy(struct cpool *cpool,
++ struct Curl_easy *admin);
+
+ /* Init the transfer to be used within its connection pool.
+ * Assigns `data->id`. */
+@@ -126,13 +128,12 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+ struct connectdata *conn);
+
+ /**
+- * This function scans the data's connection pool for half-open/dead
++ * Scans the connection pool for half-open/dead
+ * connections, closes and removes them.
+ * The cleanup is done at most once per second.
+- *
+- * When called, this transfer has no connection attached.
+ */
+-void Curl_cpool_prune_dead(struct Curl_easy *data);
++void Curl_cpool_prune_dead(struct cpool *cpool,
++ struct Curl_easy *data);
+
+ /**
+ * Perform upkeep actions on connections in the transfer's pool.
+@@ -162,6 +163,6 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
+ Curl_cpool_conn_do_cb *cb, void *cbdata);
+
+ /* Close all unused connections, prevent reuse of existing ones. */
+-void Curl_cpool_nw_changed(struct Curl_easy *data);
++void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin);
+
+ #endif /* HEADER_CURL_CONNCACHE_H */
+diff --git a/lib/cshutdn.c b/lib/cshutdn.c
+index 84e5b2a116..5610e7070b 100644
+--- a/lib/cshutdn.c
++++ b/lib/cshutdn.c
+@@ -38,6 +38,13 @@
+ #include "curlx/strparse.h"
+
+
++struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data)
++{
++ if(data && data->multi)
++ return &data->multi->cshutdn;
++ return NULL;
++}
++
+ static void cshutdn_run_conn_handler(struct Curl_easy *data,
+ struct connectdata *conn)
+ {
+@@ -103,22 +110,22 @@ static void cshutdn_run_once(struct Curl_easy *data,
+ conn->bits.shutdown_filters = TRUE;
+ }
+
+-void Curl_cshutdn_run_once(struct Curl_easy *data,
++void Curl_conn_shutdown_once(struct Curl_easy *admin,
+ struct connectdata *conn,
+ bool *done)
+ {
+- DEBUGASSERT(!data->conn);
+- Curl_attach_connection(data, conn);
+- cshutdn_run_once(data, conn, done);
+- CURL_TRC_M(data, "[SHUTDOWN] shutdown, done=%d", *done);
+- Curl_detach_connection(data);
++ DEBUGASSERT(!admin->conn);
++ DEBUGASSERT(!admin->mid);
++ Curl_attach_connection(admin, conn, FALSE);
++ cshutdn_run_once(admin, conn, done);
++ CURL_TRC_M(admin, "[SHUTDOWN] shutdown, done=%d", *done);
++ Curl_detach_connection(admin);
+ }
+
+-void Curl_cshutdn_terminate(struct Curl_easy *data,
++void Curl_cshutdn_terminate(struct Curl_easy *admin,
+ struct connectdata *conn,
+ bool do_shutdown)
+ {
+- struct Curl_easy *admin = data;
+ bool done;
+
+ /* there must be a connection to close */
+@@ -126,16 +133,10 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
+ /* it must be removed from the connection pool */
+ DEBUGASSERT(!conn->bits.in_cpool);
+ /* the transfer must be detached from the connection */
+- DEBUGASSERT(data && !data->conn);
+-
+- /* If we can obtain an internal admin handle, use that to attach
+- * and terminate the connection. Some protocol will try to mess with
+- * `data` during shutdown and we do not want that with a `data` from
+- * the application. */
+- if(data->multi && data->multi->admin)
+- admin = data->multi->admin;
++ DEBUGASSERT(admin && !admin->conn);
++ DEBUGASSERT(!admin->mid);
+
+- Curl_attach_connection(admin, conn);
++ Curl_attach_connection(admin, conn, FALSE);
+
+ cshutdn_run_conn_handler(admin, conn);
+ if(do_shutdown) {
+@@ -150,18 +151,17 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
+ Curl_conn_close(admin, FIRSTSOCKET);
+ Curl_detach_connection(admin);
+
+- if(data->multi)
+- Curl_multi_ev_conn_done(data->multi, data, conn);
++ if(admin->multi)
++ Curl_multi_ev_conn_done(admin->multi, admin, conn);
+ Curl_conn_free(admin, conn);
+
+- if(data->multi) {
+- CURL_TRC_M(data, "[SHUTDOWN] trigger multi connchanged");
+- Curl_multi_connchanged(data->multi);
++ if(admin->multi) {
++ CURL_TRC_M(admin, "[SHUTDOWN] trigger multi connchanged");
++ Curl_multi_connchanged(admin->multi);
+ }
+ }
+
+ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ const char *destination)
+ {
+ struct Curl_llist_node *e;
+@@ -180,20 +180,19 @@ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
+ conn = Curl_node_elem(e);
+ Curl_node_remove(e);
+ sigpipe_init(&pipe_st);
+- sigpipe_apply(data, &pipe_st);
+- Curl_cshutdn_terminate(data, conn, FALSE);
++ sigpipe_apply(cshutdn->multi->admin, &pipe_st);
++ Curl_cshutdn_terminate(cshutdn->multi->admin, conn, FALSE);
+ sigpipe_restore(&pipe_st);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+-bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
++bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
+ const char *destination)
+ {
+- if(data && data->multi) {
+- struct cshutdn *csd = &data->multi->cshutdn;
+- return cshutdn_destroy_oldest(csd, data, destination);
++ if(cshutdn) {
++ return cshutdn_destroy_oldest(cshutdn, destination);
+ }
+ return FALSE;
+ }
+@@ -201,7 +200,6 @@ bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
+ #define NUM_POLLS_ON_STACK 10
+
+ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ int timeout_ms)
+ {
+ struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
+@@ -210,7 +208,7 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
+
+ Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK);
+
+- result = Curl_cshutdn_add_pollfds(cshutdn, data, &cpfds);
++ result = Curl_cshutdn_add_pollfds(cshutdn, &cpfds);
+ if(result)
+ goto out;
+
+@@ -222,7 +220,7 @@ out:
+ }
+
+ static void cshutdn_perform(struct cshutdn *cshutdn,
+- struct Curl_easy *data)
++ struct Curl_easy *admin)
+ {
+ struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
+ struct Curl_llist_node *enext;
+@@ -233,20 +231,20 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
+ if(!e)
+ return;
+
+- CURL_TRC_M(data, "[SHUTDOWN] perform on %zu connections",
++ CURL_TRC_M(admin, "[SHUTDOWN] perform on %zu connections",
+ Curl_llist_count(&cshutdn->list));
+ while(e) {
+ enext = Curl_node_next(e);
+ conn = Curl_node_elem(e);
+- Curl_cshutdn_run_once(data, conn, &done);
++ Curl_conn_shutdown_once(admin, conn, &done);
+ if(done) {
+ Curl_node_remove(e);
+- Curl_cshutdn_terminate(data, conn, FALSE);
++ Curl_cshutdn_terminate(admin, conn, FALSE);
+ }
+ else {
+ /* idata has one timer list, but maybe more than one connection.
+ * Set EXPIRE_SHUTDOWN to the smallest time left for all. */
+- ms = Curl_conn_shutdown_timeleft(data, conn);
++ ms = Curl_conn_shutdown_timeleft(admin, conn);
+ if(ms && ms < next_expire_ms)
+ next_expire_ms = ms;
+ }
+@@ -254,46 +252,43 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
+ }
+
+ if(next_expire_ms)
+- Curl_expire_ex(data, next_expire_ms, EXPIRE_SHUTDOWN);
++ Curl_expire_ex(admin, next_expire_ms, EXPIRE_SHUTDOWN);
+ }
+
+ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ int timeout_ms)
+ {
+- struct curltime started = *Curl_pgrs_now(data);
++ struct Curl_easy *admin = cshutdn->multi->admin;
++ struct curltime started = *Curl_pgrs_now(admin);
+ struct Curl_llist_node *e;
+ SIGPIPE_VARIABLE(pipe_st);
+
+- DEBUGASSERT(cshutdn);
+- DEBUGASSERT(data);
+-
+- CURL_TRC_M(data, "[SHUTDOWN] shutdown all");
++ CURL_TRC_M(admin, "[SHUTDOWN] shutdown all");
+ sigpipe_init(&pipe_st);
+- sigpipe_apply(data, &pipe_st);
++ sigpipe_apply(admin, &pipe_st);
+
+ while(Curl_llist_head(&cshutdn->list)) {
+ timediff_t spent_ms;
+ int remain_ms;
+
+- cshutdn_perform(cshutdn, data);
++ cshutdn_perform(cshutdn, admin);
+
+ if(!Curl_llist_head(&cshutdn->list)) {
+- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished cleanly");
++ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished cleanly");
+ break;
+ }
+
+ /* wait for activity, timeout or "nothing" */
+- spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &started);
++ spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(admin), &started);
+ if(spent_ms >= (timediff_t)timeout_ms) {
+- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
++ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, %s",
+ (timeout_ms > 0) ? "timeout" : "best effort done");
+ break;
+ }
+
+ remain_ms = timeout_ms - (int)spent_ms;
+- if(cshutdn_wait(cshutdn, data, remain_ms)) {
+- CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, aborted");
++ if(cshutdn_wait(cshutdn, remain_ms)) {
++ CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, aborted");
+ break;
+ }
+ }
+@@ -303,7 +298,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
+ while(e) {
+ struct connectdata *conn = Curl_node_elem(e);
+ Curl_node_remove(e);
+- Curl_cshutdn_terminate(data, conn, FALSE);
++ Curl_cshutdn_terminate(admin, conn, FALSE);
+ e = Curl_llist_head(&cshutdn->list);
+ }
+ DEBUGASSERT(!Curl_llist_count(&cshutdn->list));
+@@ -322,9 +317,9 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn,
+ }
+
+ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+- struct Curl_easy *data)
++ struct Curl_easy *admin)
+ {
+- if(cshutdn->initialised && data) {
++ if(cshutdn->initialised && admin) {
+ int timeout_ms = 0;
+ /* Just for testing, run graceful shutdown */
+ #ifdef DEBUGBUILD
+@@ -338,29 +333,27 @@ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+ }
+ #endif
+
+- CURL_TRC_M(data, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
++ CURL_TRC_M(admin, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
+ Curl_llist_count(&cshutdn->list), timeout_ms);
+- cshutdn_terminate_all(cshutdn, data, timeout_ms);
++ cshutdn_terminate_all(cshutdn, timeout_ms);
+ }
+ cshutdn->multi = NULL;
+ }
+
+-size_t Curl_cshutdn_count(struct Curl_easy *data)
++size_t Curl_cshutdn_count(struct cshutdn *cshutdn)
+ {
+- if(data && data->multi) {
+- struct cshutdn *csd = &data->multi->cshutdn;
+- return Curl_llist_count(&csd->list);
++ if(cshutdn) {
++ return Curl_llist_count(&cshutdn->list);
+ }
+ return 0;
+ }
+
+-size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
++size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
+ const char *destination)
+ {
+- if(data && data->multi) {
+- struct cshutdn *csd = &data->multi->cshutdn;
++ if(cshutdn) {
+ size_t n = 0;
+- struct Curl_llist_node *e = Curl_llist_head(&csd->list);
++ struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
+ while(e) {
+ struct connectdata *conn = Curl_node_elem(e);
+ if(!strcmp(destination, conn->destination))
+@@ -373,7 +366,7 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
+ }
+
+ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
++ struct Curl_easy *admin,
+ struct connectdata *conn)
+ {
+ CURLMcode mresult;
+@@ -381,9 +374,9 @@ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
+ DEBUGASSERT(cshutdn);
+ DEBUGASSERT(cshutdn->multi->socket_cb);
+
+- Curl_attach_connection(data, conn);
+- mresult = Curl_multi_ev_assess_conn(cshutdn->multi, data, conn);
+- Curl_detach_connection(data);
++ Curl_attach_connection(admin, conn, FALSE);
++ mresult = Curl_multi_ev_assess_conn(cshutdn->multi, admin, conn);
++ Curl_detach_connection(admin);
+ return mresult;
+ }
+
+@@ -400,7 +393,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
+ (conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
+ CURL_TRC_M(data, "[SHUTDOWN] discarding oldest shutdown connection "
+ "due to connection limit of %zu", max_total);
+- cshutdn_destroy_oldest(cshutdn, data, NULL);
++ cshutdn_destroy_oldest(cshutdn, NULL);
+ }
+
+ if(cshutdn->multi->socket_cb) {
+@@ -419,7 +412,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
+ }
+
+ static void cshutdn_multi_socket(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
++ struct Curl_easy *admin,
+ curl_socket_t s)
+ {
+ struct Curl_llist_node *e;
+@@ -431,10 +424,10 @@ static void cshutdn_multi_socket(struct cshutdn *cshutdn,
+ while(e) {
+ conn = Curl_node_elem(e);
+ if(s == conn->sock[FIRSTSOCKET] || s == conn->sock[SECONDARYSOCKET]) {
+- Curl_cshutdn_run_once(data, conn, &done);
+- if(done || cshutdn_update_ev(cshutdn, data, conn)) {
++ Curl_conn_shutdown_once(admin, conn, &done);
++ if(done || cshutdn_update_ev(cshutdn, admin, conn)) {
+ Curl_node_remove(e);
+- Curl_cshutdn_terminate(data, conn, FALSE);
++ Curl_cshutdn_terminate(admin, conn, FALSE);
+ }
+ break;
+ }
+@@ -446,21 +439,22 @@ void Curl_cshutdn_perform(struct cshutdn *cshutdn,
+ struct Curl_easy *data,
+ curl_socket_t s)
+ {
++ struct Curl_easy *admin = Curl_get_admin(data);
+ if((s == CURL_SOCKET_TIMEOUT) || (!cshutdn->multi->socket_cb))
+- cshutdn_perform(cshutdn, data);
++ cshutdn_perform(cshutdn, admin);
+ else
+- cshutdn_multi_socket(cshutdn, data, s);
++ cshutdn_multi_socket(cshutdn, admin, s);
+ }
+
+ /* return fd_set info about the shutdown connections */
+ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ fd_set *read_fd_set, fd_set *write_fd_set,
+ int *maxfd)
+ {
+ if(Curl_llist_head(&cshutdn->list)) {
+ struct Curl_llist_node *e;
+ struct easy_pollset ps;
++ struct Curl_easy *admin = cshutdn->multi->admin;
+
+ Curl_pollset_init(&ps);
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
+@@ -469,9 +463,9 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+ CURLcode result;
+
+ Curl_pollset_reset(&ps);
+- Curl_attach_connection(data, conn);
+- result = Curl_conn_adjust_pollset(data, conn, &ps);
+- Curl_detach_connection(data);
++ Curl_attach_connection(admin, conn, FALSE);
++ result = Curl_conn_adjust_pollset(admin, conn, &ps);
++ Curl_detach_connection(admin);
+
+ if(result)
+ continue;
+@@ -502,7 +496,6 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+
+ /* return information about the shutdown connections */
+ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ struct Curl_waitfds *cwfds)
+ {
+ unsigned int need = 0;
+@@ -511,15 +504,16 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+ struct Curl_llist_node *e;
+ struct easy_pollset ps;
+ struct connectdata *conn;
++ struct Curl_easy *admin = cshutdn->multi->admin;
+ CURLcode result;
+
+ Curl_pollset_init(&ps);
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
+ conn = Curl_node_elem(e);
+ Curl_pollset_reset(&ps);
+- Curl_attach_connection(data, conn);
+- result = Curl_conn_adjust_pollset(data, conn, &ps);
+- Curl_detach_connection(data);
++ Curl_attach_connection(admin, conn, FALSE);
++ result = Curl_conn_adjust_pollset(admin, conn, &ps);
++ Curl_detach_connection(admin);
+
+ if(!result)
+ need += Curl_waitfds_add_ps(cwfds, &ps);
+@@ -530,7 +524,6 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+ }
+
+ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ struct curl_pollfds *cpfds)
+ {
+ CURLcode result = CURLE_OK;
+@@ -539,14 +532,15 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+ struct Curl_llist_node *e;
+ struct easy_pollset ps;
+ struct connectdata *conn;
++ struct Curl_easy *admin = cshutdn->multi->admin;
+
+ Curl_pollset_init(&ps);
+ for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
+ conn = Curl_node_elem(e);
+ Curl_pollset_reset(&ps);
+- Curl_attach_connection(data, conn);
+- result = Curl_conn_adjust_pollset(data, conn, &ps);
+- Curl_detach_connection(data);
++ Curl_attach_connection(admin, conn, FALSE);
++ result = Curl_conn_adjust_pollset(admin, conn, &ps);
++ Curl_detach_connection(admin);
+
+ if(!result)
+ result = Curl_pollfds_add_ps(cpfds, &ps);
+diff --git a/lib/cshutdn.h b/lib/cshutdn.h
+index 0a15d39f1c..71b99a4e5a 100644
+--- a/lib/cshutdn.h
++++ b/lib/cshutdn.h
+@@ -32,20 +32,20 @@ struct Curl_multi;
+ struct Curl_share;
+
+ /* Run the shutdown of the connection once.
+- * Will shortly attach/detach `data` to `conn` while doing so.
++ * Shortly attach/detach the admin handle to `conn` while doing so.
+ * `done` will be set TRUE if any error was encountered or if
+ * the connection was shut down completely. */
+-void Curl_cshutdn_run_once(struct Curl_easy *data,
+- struct connectdata *conn,
+- bool *done);
++void Curl_conn_shutdown_once(struct Curl_easy *admin,
++ struct connectdata *conn,
++ bool *done);
+
+ /* Terminates the connection, e.g. closes and destroys it.
+ * If `run_shutdown` is TRUE, the shutdown will be run once before
+ * terminating it.
+ * Takes ownership of `conn`. */
+-void Curl_cshutdn_terminate(struct Curl_easy *data,
+- struct connectdata *conn,
+- bool run_shutdown);
++void Curl_cshutdn_terminate(struct Curl_easy *admin,
++ struct connectdata *conn,
++ bool do_shutdown);
+
+ /* A `cshutdown` is always owned by a multi handle to maintain
+ * the connections to be shut down. It registers timers and
+@@ -56,25 +56,28 @@ struct cshutdn {
+ BIT(initialised);
+ };
+
++/* Get the cshutdn instance relevant for `data` or NULL if there is none */
++struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data);
++
+ /* Init as part of the given multi handle. */
+ int Curl_cshutdn_init(struct cshutdn *cshutdn,
+ struct Curl_multi *multi);
+
+ /* Terminate all remaining connections and free resources. */
+ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+- struct Curl_easy *data);
++ struct Curl_easy *admin);
+
+ /* Number of connections being shut down. */
+-size_t Curl_cshutdn_count(struct Curl_easy *data);
++size_t Curl_cshutdn_count(struct cshutdn *cshutdn);
+
+ /* Number of connections to the destination being shut down. */
+-size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
++size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
+ const char *destination);
+
+ /* Close the oldest connection in shutdown to destination or,
+ * when destination is NULL for any destination.
+ * Return TRUE if a connection has been closed. */
+-bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
++bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
+ const char *destination);
+
+ /* Add a connection to have it shut down. Will terminate the oldest
+@@ -85,15 +88,12 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
+
+ /* Add sockets and POLLIN/OUT flags for connections being shut down. */
+ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ struct curl_pollfds *cpfds);
+
+ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ struct Curl_waitfds *cwfds);
+
+ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+- struct Curl_easy *data,
+ fd_set *read_fd_set, fd_set *write_fd_set,
+ int *maxfd);
+
+diff --git a/lib/curl_share.c b/lib/curl_share.c
+index 3ff2755684..426e85a8ae 100644
+--- a/lib/curl_share.c
++++ b/lib/curl_share.c
+@@ -31,6 +31,7 @@
+ #include "hsts.h"
+ #include "url.h"
+
++
+ CURLSH *curl_share_init(void)
+ {
+ struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share));
+@@ -128,7 +129,7 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
+ case CURL_LOCK_DATA_CONNECT:
+ /* It is safe to set this option several times on a share. */
+ if(!share->cpool.initialised) {
+- Curl_cpool_init(&share->cpool, share->admin, share, 103);
++ Curl_cpool_init(&share->cpool, share, 103);
+ }
+ break;
+
+@@ -236,7 +237,7 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
+ }
+
+ if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
+- Curl_cpool_destroy(&share->cpool);
++ Curl_cpool_destroy(&share->cpool, share->admin);
+ }
+
+ Curl_dnscache_destroy(&share->dnscache);
+@@ -267,11 +268,11 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
+ return CURLSHE_OK;
+ }
+
+-CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
+- curl_lock_access accesstype)
++CURLSHcode Curl_share_lock_share(struct Curl_share *share,
++ struct Curl_easy *data,
++ curl_lock_data type,
++ curl_lock_access accesstype)
+ {
+- struct Curl_share *share = data->share;
+-
+ if(!share)
+ return CURLSHE_INVALID;
+
+@@ -284,10 +285,16 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
+ return CURLSHE_OK;
+ }
+
+-CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
++CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
++ curl_lock_access accesstype)
+ {
+- struct Curl_share *share = data->share;
++ return Curl_share_lock_share(data->share, data, type, accesstype);
++}
+
++CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
++ struct Curl_easy *data,
++ curl_lock_data type)
++{
+ if(!share)
+ return CURLSHE_INVALID;
+
+@@ -298,3 +305,8 @@ CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
+
+ return CURLSHE_OK;
+ }
++
++CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
++{
++ return Curl_share_unlock_share(data->share, data, type);
++}
+diff --git a/lib/curl_share.h b/lib/curl_share.h
+index fcd9e32980..9a4fdba392 100644
+--- a/lib/curl_share.h
++++ b/lib/curl_share.h
+@@ -69,6 +69,14 @@ CURLSHcode Curl_share_lock(struct Curl_easy *, curl_lock_data,
+ curl_lock_access);
+ CURLSHcode Curl_share_unlock(struct Curl_easy *, curl_lock_data);
+
++CURLSHcode Curl_share_lock_share(struct Curl_share *share,
++ struct Curl_easy *data,
++ curl_lock_data type,
++ curl_lock_access accesstype);
++CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
++ struct Curl_easy *data,
++ curl_lock_data type);
++
+ /* convenience macro to check if this handle is using a shared SSL spool */
+ #define CURL_SHARE_ssl_scache(data) (data->share && \
+ (data->share->specifier & \
+diff --git a/lib/curl_trc.c b/lib/curl_trc.c
+index 565d1b45f0..6be80f0910 100644
+--- a/lib/curl_trc.c
++++ b/lib/curl_trc.c
+@@ -90,8 +90,7 @@ static struct curl_trc_feat Curl_trc_feat_ids = {
+
+ static size_t trc_print_ids(struct Curl_easy *data, char *buf, size_t maxlen)
+ {
+- curl_off_t cid = data->conn ?
+- data->conn->connection_id : data->state.recent_conn_id;
++ curl_off_t cid = data->state.lastconnect_id;
+ if(data->id >= 0) {
+ if(cid >= 0)
+ return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
+diff --git a/lib/easy.c b/lib/easy.c
+index 398b20edd1..dc6a83617f 100644
+--- a/lib/easy.c
++++ b/lib/easy.c
+@@ -977,7 +977,6 @@ CURL *curl_easy_duphandle(CURL *d)
+
+ /* the connection pool is setup on demand */
+ outcurl->state.lastconnect_id = -1;
+- outcurl->state.recent_conn_id = -1;
+ outcurl->id = -1;
+ outcurl->mid = UINT32_MAX;
+ outcurl->master_mid = UINT32_MAX;
+@@ -1109,7 +1108,7 @@ void curl_easy_reset(CURL *d)
+
+ data->progress.hide = TRUE;
+ data->state.current_speed = -1; /* init to negative == impossible */
+- data->state.recent_conn_id = -1; /* clear remembered connection id */
++ data->state.lastconnect_id = -1; /* clear remembered connection id */
+
+ /* zero out authentication data: */
+ memset(&data->state.authhost, 0, sizeof(struct auth));
+@@ -1240,7 +1239,7 @@ CURLcode curl_easy_recv(CURL *d, void *buffer, size_t buflen, size_t *n)
+ if(!data->conn)
+ /* on first invoke, the transfer has been detached from the connection and
+ needs to be reattached */
+- Curl_attach_connection(data, c);
++ Curl_attach_connection(data, c, TRUE);
+
+ *n = 0;
+ return Curl_conn_recv(data, FIRSTSOCKET, buffer, buflen, n);
+@@ -1259,7 +1258,7 @@ CURLcode Curl_connect_only_attach(struct Curl_easy *data)
+ if(!data->conn)
+ /* on first invoke, the transfer has been detached from the connection and
+ needs to be reattached */
+- Curl_attach_connection(data, c);
++ Curl_attach_connection(data, c, TRUE);
+
+ return CURLE_OK;
+ }
+@@ -1285,7 +1284,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
+ if(!data->conn)
+ /* on first invoke, the transfer has been detached from the connection and
+ needs to be reattached */
+- Curl_attach_connection(data, c);
++ Curl_attach_connection(data, c, TRUE);
+
+ sigpipe_ignore(data, &pipe_st);
+ result = Curl_conn_send(data, FIRSTSOCKET, buffer, buflen, FALSE, n);
+diff --git a/lib/getinfo.c b/lib/getinfo.c
+index e094ffd134..67b9eeb76c 100644
+--- a/lib/getinfo.c
++++ b/lib/getinfo.c
+@@ -463,8 +463,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
+ *param_offt = data->id;
+ break;
+ case CURLINFO_CONN_ID:
+- *param_offt = data->conn ?
+- data->conn->connection_id : data->state.recent_conn_id;
++ *param_offt = data->state.lastconnect_id;
+ break;
+ case CURLINFO_EARLYDATA_SENT_T:
+ *param_offt = data->progress.earlydata_sent;
+diff --git a/lib/multi.c b/lib/multi.c
+index 6db86abda2..7691c92629 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -280,7 +280,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
+ if(Curl_cshutdn_init(&multi->cshutdn, multi))
+ goto error;
+
+- Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize);
++ Curl_cpool_init(&multi->cpool, NULL, chashsize);
+
+ #ifdef USE_SSL
+ if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
+@@ -307,7 +307,7 @@ error:
+ Curl_multi_ev_cleanup(multi);
+ Curl_hash_destroy(&multi->proto_hash);
+ Curl_dnscache_destroy(&multi->dnscache);
+- Curl_cpool_destroy(&multi->cpool);
++ Curl_cpool_destroy(&multi->cpool, multi->admin);
+ Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
+ #ifdef USE_SSL
+ Curl_ssl_scache_destroy(multi->ssl_scache);
+@@ -617,7 +617,6 @@ static void multi_done_locked(struct connectdata *conn,
+ }
+
+ data->state.done = TRUE; /* called just now! */
+- data->state.recent_conn_id = conn->connection_id;
+
+ Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
+ Curl_resolv_unlink(data, &data->state.dns[1]);
+@@ -646,7 +645,6 @@ static void multi_done_locked(struct connectdata *conn,
+ /* the connection is no longer in use by any transfer */
+ if(Curl_cpool_conn_now_idle(data, conn)) {
+ /* connection kept in the cpool */
+- data->state.lastconnect_id = conn->connection_id;
+ #ifndef CURL_DISABLE_VERBOSE_STRINGS
+ infof(data, "Connection #%" FMT_OFF_T " to host %s:%d left intact",
+ conn->connection_id, host, port);
+@@ -654,7 +652,6 @@ static void multi_done_locked(struct connectdata *conn,
+ }
+ else {
+ /* connection was removed from the cpool and destroyed. */
+- data->state.lastconnect_id = -1;
+ }
+ }
+ }
+@@ -917,16 +914,21 @@ void Curl_detach_connection(struct Curl_easy *data)
+ /*
+ * Curl_attach_connection() attaches this transfer to this connection.
+ *
+- * This is the only function that should assign data->conn
++ * This is the only function that should assign data->conn.
++ * `matched == TRUE` means the transfer's properties match this
++ * connection and it is not a temporary attach for maintenance.
+ */
+ void Curl_attach_connection(struct Curl_easy *data,
+- struct connectdata *conn)
++ struct connectdata *conn,
++ bool matched)
+ {
+ DEBUGASSERT(data);
+ DEBUGASSERT(!data->conn);
+ DEBUGASSERT(conn);
+ DEBUGASSERT(conn->attached_xfers < UINT32_MAX);
+ data->conn = conn;
++ if(matched)
++ data->state.lastconnect_id = conn->connection_id;
+ conn->attached_xfers++;
+ /* all attached transfers must be from the same multi */
+ if(!conn->attached_multi)
+@@ -1259,7 +1261,7 @@ CURLMcode curl_multi_fdset(CURLM *m,
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ }
+
+- Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
++ Curl_cshutdn_setfds(&multi->cshutdn,
+ read_fd_set, write_fd_set, &this_max_fd);
+
+ *max_fd = this_max_fd;
+@@ -1305,7 +1307,7 @@ CURLMcode curl_multi_waitfds(CURLM *m,
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ }
+
+- need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
++ need += Curl_cshutdn_add_waitfds(&multi->cshutdn, &cwfds);
+
+ if(need != cwfds.n && ufds)
+ mresult = CURLM_OUT_OF_MEMORY;
+@@ -1392,7 +1394,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ }
+
+- if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
++ if(Curl_cshutdn_add_pollfds(&multi->cshutdn, &cpfds)) {
+ mresult = CURLM_OUT_OF_MEMORY;
+ goto out;
+ }
+@@ -1717,7 +1719,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
+
+ /* take this handle to the perform state right away */
+ multistate(data, MSTATE_PERFORMING);
+- Curl_attach_connection(data, conn);
++ Curl_attach_connection(data, conn, TRUE);
+ k->keepon |= KEEP_RECV; /* setup to receive! */
+ }
+ return mresult;
+@@ -2893,7 +2895,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
+ } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
+ }
+
+- Curl_cpool_destroy(&multi->cpool);
++ Curl_cpool_destroy(&multi->cpool, multi->admin);
+ Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
+ if(multi->admin) {
+ CURL_TRC_M(multi->admin, "multi_cleanup, closing admin handle, done");
+@@ -3277,7 +3279,7 @@ CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
+ Curl_dnscache_clear(multi->admin);
+ }
+ if(val & CURLMNWC_CLEAR_CONNS) {
+- Curl_cpool_nw_changed(multi->admin);
++ Curl_cpool_nw_changed(&multi->cpool, multi->admin);
+ }
+ break;
+ }
+diff --git a/lib/multiif.h b/lib/multiif.h
+index f368639857..9054dc6a66 100644
+--- a/lib/multiif.h
++++ b/lib/multiif.h
+@@ -34,7 +34,8 @@ void Curl_expire_clear(struct Curl_easy *data);
+ void Curl_expire_done(struct Curl_easy *data, expire_id id);
+ CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
+ void Curl_attach_connection(struct Curl_easy *data,
+- struct connectdata *conn);
++ struct connectdata *conn,
++ bool matched);
+ void Curl_detach_connection(struct Curl_easy *data);
+ bool Curl_multiplex_wanted(const struct Curl_multi *multi);
+ void Curl_set_in_callback(struct Curl_easy *data, bool value);
+diff --git a/lib/url.c b/lib/url.c
+index c3fb1439ca..6e42ca0ec4 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -482,7 +482,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
+ data->magic = CURLEASY_MAGIC_NUMBER;
+ /* most recent connection is not yet defined */
+ data->state.lastconnect_id = -1;
+- data->state.recent_conn_id = -1;
++ data->state.lastconnect_id = -1;
+ /* and not assigned an id yet */
+ data->id = -1;
+ data->mid = UINT32_MAX;
+@@ -658,7 +658,7 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
+
+ /* briefly attach the connection to this transfer for the purpose of
+ checking it */
+- Curl_attach_connection(data, conn);
++ Curl_attach_connection(data, conn, FALSE);
+
+ state = conn->handler->connection_check(data, conn, CONNCHECK_ISDEAD);
+ dead = (state & CONNRESULT_DEAD);
+@@ -668,7 +668,7 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
+ else {
+ bool input_pending = FALSE;
+
+- Curl_attach_connection(data, conn);
++ Curl_attach_connection(data, conn, FALSE);
+ dead = !Curl_conn_is_alive(data, conn, &input_pending);
+ if(input_pending) {
+ /* For reuse, we want a "clean" connection state. The includes
+@@ -704,7 +704,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data,
+ return result;
+
+ /* briefly attach for action */
+- Curl_attach_connection(data, conn);
++ Curl_attach_connection(data, conn, FALSE);
+ if(conn->handler->connection_check) {
+ /* Do a protocol-specific keepalive check on the connection. */
+ unsigned int rc;
+@@ -1306,7 +1306,7 @@ static bool url_match_result(bool result, void *userdata)
+ if(match->found) {
+ /* Attach it now while still under lock, so the connection does
+ * no longer appear idle and can be reaped. */
+- Curl_attach_connection(match->data, match->found);
++ Curl_attach_connection(match->data, match->found, TRUE);
+ return TRUE;
+ }
+ else if(match->seen_single_use_conn && !match->seen_multiplex_conn) {
+@@ -3656,8 +3656,8 @@ static CURLcode create_conn(struct Curl_easy *data,
+ goto out;
+
+ /* Setup a "faked" transfer that will do nothing */
+- Curl_attach_connection(data, conn);
+ result = Curl_cpool_add(data, conn);
++ Curl_attach_connection(data, conn, TRUE);
+ if(!result) {
+ /* Setup whatever necessary for a resumed transfer */
+ result = setup_range(data);
+@@ -3688,7 +3688,10 @@ static CURLcode create_conn(struct Curl_easy *data,
+ if(result)
+ goto out;
+
+- Curl_cpool_prune_dead(data);
++ {
++ struct cpool *cpool = Curl_cpool_get_instance(data);
++ Curl_cpool_prune_dead(cpool, data);
++ }
+
+ /*************************************************************
+ * Check the current list of connections to see if we can
+@@ -3795,8 +3798,8 @@ static CURLcode create_conn(struct Curl_easy *data,
+ goto out;
+ }
+
+- Curl_attach_connection(data, conn);
+ result = Curl_cpool_add(data, conn);
++ Curl_attach_connection(data, conn, TRUE);
+ if(result)
+ goto out;
+ }
+@@ -4021,6 +4024,31 @@ CURLcode Curl_1st_err(CURLcode r1, CURLcode r2)
+ return r1 ? r1 : r2;
+ }
+
++struct Curl_easy *Curl_get_admin(struct Curl_easy *data)
++{
++ struct Curl_easy *admin;
++
++ if(!data->mid) /* already an admin handle */
++ admin = data;
++ else if(data->multi)
++ admin = data->multi->admin;
++ else if(data->multi_easy)
++ admin = data->multi_easy->admin;
++ else {
++ DEBUGASSERT(0); /* we do not want this. does it happen? */
++ admin = data;
++ }
++ if(admin != data) {
++ admin->set.conn_max_idle_ms = data->set.conn_max_idle_ms;
++ admin->set.conn_max_age_ms = data->set.conn_max_age_ms;
++ admin->set.upkeep_interval_ms = data->set.upkeep_interval_ms;
++ admin->set.timeout = data->set.timeout;
++ admin->set.server_response_timeout = data->set.server_response_timeout;
++ admin->set.no_signal = data->set.no_signal;
++ }
++ return admin;
++}
++
+ CURLcode Curl_1st_fatal(CURLcode r1, CURLcode r2)
+ {
+ if(r1 && (r1 != CURLE_AGAIN))
+diff --git a/lib/url.h b/lib/url.h
+index ddac784e75..3796a1f899 100644
+--- a/lib/url.h
++++ b/lib/url.h
+@@ -75,6 +75,12 @@ const struct Curl_handler *Curl_get_scheme_handler(const char *scheme);
+ const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme,
+ size_t len);
+
++/* Get an admin handle for internal operations from the given
++ * easy handle, if possible. The admin handle inherits certain
++ * properties from `data`. If no admin handle is available (not multi
++ * or share attached), the easy handle itself is returned. */
++struct Curl_easy *Curl_get_admin(struct Curl_easy *data);
++
+ #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
+ #define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
+ specified */
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 318dfdb84c..1e527826ca 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -931,9 +931,7 @@ struct UrlState {
+ /* buffers to store authentication data in, as parsed from input options */
+ struct curltime keeps_speed; /* for the progress meter really */
+
+- curl_off_t lastconnect_id; /* The last connection, -1 if undefined */
+- curl_off_t recent_conn_id; /* The most recent connection used, might no
+- * longer exist */
++ curl_off_t lastconnect_id; /* The last assigned connection or -1 */
+ struct dynbuf headerb; /* buffer to store headers in */
+ struct curl_slist *hstslist; /* list of HSTS files set by
+ curl_easy_setopt(HSTS) calls */
+diff --git a/tests/data/test1554 b/tests/data/test1554
+index fa071b09b2..54d6065387 100644
+--- a/tests/data/test1554
++++ b/tests/data/test1554
+@@ -68,6 +68,8 @@ run 1: foobar and so on fun!
+ -] Mutex lock SHARE
+ [- Mutex unlock SHARE
+ -] Mutex lock SHARE
++-] Mutex lock CONNECT
++[- Mutex unlock CONNECT
+ [- Mutex unlock SHARE
+ </datacheck>
+ </reply>
diff --git a/0030-curl-8.18.0-CVE-2026-8932.patch b/0030-curl-8.18.0-CVE-2026-8932.patch
deleted file mode 100644
index ddc2ff0..0000000
--- a/0030-curl-8.18.0-CVE-2026-8932.patch
+++ /dev/null
@@ -1,1221 +0,0 @@
-From 0cc1b643f82ebc98b15395d5d4aaddeb119deb1f Mon Sep 17 00:00:00 2001
-From: Joshua Rogers <MegaManSec@users.noreply.github.com>
-Date: Tue, 19 May 2026 11:47:50 +0200
-Subject: [PATCH 1/3] tls: fix incomplete mTLS config in conn reuse and session
- cache
-
-cert_type, key, key_type, key_passwd and key_blob lived in
-ssl_config_data but not in ssl_primary_config, so they were invisible to
-match_ssl_primary_config() and to the TLS session cache peer key.
-
-Two easy handles sharing a connection pool could reuse each other's
-authenticated connections when they differed only on SSLKEY, SSLKEYTYPE,
-KEYPASSWD, SSLCERTTYPE or SSLKEYBLOB. The second handle would silently
-inherit the first handle's authenticated identity.
-
-Promote all five fields into ssl_primary_config so the conn-reuse
-predicate and session cache key cover the complete client credential
-set. Also replace the fixed ":CCERT" session cache marker with the
-actual clientcert path so sessions are not shared across different
-client certificates.
-
-Verified by test 3303 and 3304
-
-Reported-By: Joshua Rogers (AISLE Research)
-Closes #21667
-
-(cherry picked from commit 7541ae569d82fb308a5e2d94916027da4fa3ba3e)
----
- lib/ldap.c | 4 +-
- lib/urldata.h | 10 +-
- lib/vssh/libssh.c | 6 +-
- lib/vssh/libssh2.c | 2 +-
- lib/vtls/gtls.c | 14 +--
- lib/vtls/mbedtls.c | 24 ++---
- lib/vtls/openssl.c | 7 +-
- lib/vtls/rustls.c | 13 +--
- lib/vtls/schannel.c | 10 +-
- lib/vtls/vtls.c | 37 +++++--
- lib/vtls/vtls_scache.c | 217 ++++++++++++++++++++++++++++++++++++++--
- lib/vtls/vtls_scache.h | 14 +++
- lib/vtls/wolfssl.c | 14 +--
- tests/data/Makefile.am | 2 +
- tests/data/test3303 | 20 ++++
- tests/data/test3304 | 20 ++++
- tests/unit/Makefile.inc | 3 +-
- tests/unit/unit3303.c | 127 +++++++++++++++++++++++
- tests/unit/unit3304.c | 163 ++++++++++++++++++++++++++++++
- 19 files changed, 635 insertions(+), 72 deletions(-)
- create mode 100644 tests/data/test3303
- create mode 100644 tests/data/test3304
- create mode 100644 tests/unit/unit3303.c
- create mode 100644 tests/unit/unit3304.c
-
-diff --git a/lib/ldap.c b/lib/ldap.c
-index 95a982f353..6c2885ca28 100644
---- a/lib/ldap.c
-+++ b/lib/ldap.c
-@@ -402,8 +402,8 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- #ifdef LDAP_OPT_X_TLS
- if(conn->ssl_config.verifypeer) {
- /* OpenLDAP SDK supports BASE64 files. */
-- if(data->set.ssl.cert_type &&
-- !curl_strequal(data->set.ssl.cert_type, "PEM")) {
-+ if(data->set.ssl.primary.cert_type &&
-+ !curl_strequal(data->set.ssl.primary.cert_type, "PEM")) {
- failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type");
- result = CURLE_SSL_CERTPROBLEM;
- goto quit;
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 1e527826ca..c31073c951 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -238,9 +238,14 @@ struct ssl_primary_config {
- char *signature_algorithms; /* list of signature algorithms to use */
- char *pinned_key;
- char *CRLfile; /* CRL to check certificate revocation */
-+ char *cert_type; /* format for certificate (default: PEM) */
-+ char *key; /* private key filename */
-+ char *key_type; /* format for private key (default: PEM) */
-+ char *key_passwd; /* plain text private key password */
- struct curl_blob *cert_blob;
- struct curl_blob *ca_info_blob;
- struct curl_blob *issuercert_blob;
-+ struct curl_blob *key_blob;
- #ifdef USE_TLS_SRP
- char *username; /* TLS username (for, e.g., SRP) */
- char *password; /* TLS password (for, e.g., SRP) */
-@@ -260,11 +265,6 @@ struct ssl_config_data {
- long certverifyresult; /* result from the certificate verification */
- curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
- void *fsslctxp; /* parameter for call back */
-- char *cert_type; /* format for certificate (default: PEM) */
-- char *key; /* private key filename */
-- struct curl_blob *key_blob;
-- char *key_type; /* format for private key (default: PEM) */
-- char *key_passwd; /* plain text private key password */
- BIT(certinfo); /* gather lots of certificate info */
- BIT(earlydata); /* use TLS 1.3 early data */
- BIT(enable_beast); /* allow this flaw for interoperability's sake */
-diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
-index 199e97bd3f..31b379ff6c 100644
---- a/lib/vssh/libssh.c
-+++ b/lib/vssh/libssh.c
-@@ -958,7 +958,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
- /* Two choices, (1) private key was given on CMD,
- * (2) use the "default" keys. */
- if(data->set.str[STRING_SSH_PRIVATE_KEY]) {
-- if(sshc->pubkey && !data->set.ssl.key_passwd) {
-+ if(sshc->pubkey && !data->set.ssl.primary.key_passwd) {
- rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL, sshc->pubkey);
- if(rc == SSH_AUTH_AGAIN)
- return SSH_AGAIN;
-@@ -971,7 +971,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
-
- rc = ssh_pki_import_privkey_file(data->
- set.str[STRING_SSH_PRIVATE_KEY],
-- data->set.ssl.key_passwd, NULL,
-+ data->set.ssl.primary.key_passwd, NULL,
- NULL, &sshc->privkey);
- if(rc != SSH_OK) {
- failf(data, "Could not load private key file %s",
-@@ -984,7 +984,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
- }
- else {
- rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL,
-- data->set.ssl.key_passwd);
-+ data->set.ssl.primary.key_passwd);
- if(rc == SSH_AUTH_AGAIN)
- return SSH_AGAIN;
-
-diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
-index 5b2b337289..1d778da533 100644
---- a/lib/vssh/libssh2.c
-+++ b/lib/vssh/libssh2.c
-@@ -1260,7 +1260,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data,
- return CURLE_OUT_OF_MEMORY;
- }
-
-- sshc->passphrase = data->set.ssl.key_passwd;
-+ sshc->passphrase = data->set.ssl.primary.key_passwd;
- if(!sshc->passphrase)
- sshc->passphrase = "";
-
-diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
-index 934273e0ee..1b3f89aca0 100644
---- a/lib/vtls/gtls.c
-+++ b/lib/vtls/gtls.c
-@@ -986,10 +986,11 @@ static CURLcode gtls_client_init(struct Curl_cfilter *cf,
- if(result)
- return result;
- }
-- if(ssl_config->cert_type && curl_strequal(ssl_config->cert_type, "P12")) {
-+ if(ssl_config->primary.cert_type &&
-+ curl_strequal(ssl_config->primary.cert_type, "P12")) {
- rc = gnutls_certificate_set_x509_simple_pkcs12_file(
- gtls->shared_creds->creds, config->clientcert, GNUTLS_X509_FMT_DER,
-- ssl_config->key_passwd ? ssl_config->key_passwd : "");
-+ ssl_config->primary.key_passwd ? ssl_config->primary.key_passwd : "");
- if(rc != GNUTLS_E_SUCCESS) {
- failf(data,
- "error reading X.509 potentially-encrypted key or certificate "
-@@ -1007,14 +1008,15 @@ static CURLcode gtls_client_init(struct Curl_cfilter *cf,
- rc = gnutls_certificate_set_x509_key_file2(
- gtls->shared_creds->creds,
- config->clientcert,
-- ssl_config->key ? ssl_config->key : config->clientcert,
-- gnutls_do_file_type(ssl_config->cert_type),
-- ssl_config->key_passwd,
-+ ssl_config->primary.key ? ssl_config->primary.key :
-+ config->clientcert,
-+ gnutls_do_file_type(ssl_config->primary.cert_type),
-+ ssl_config->primary.key_passwd,
- supported_key_encryption_algorithms);
- if(rc != GNUTLS_E_SUCCESS) {
- failf(data,
- "error reading X.509 %skey file: %s",
-- ssl_config->key_passwd ? "potentially-encrypted " : "",
-+ ssl_config->primary.key_passwd ? "potentially-encrypted " : "",
- gnutls_strerror(rc));
- return CURLE_SSL_CONNECT_ERROR;
- }
-diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
-index dff45a3299..3035dcb68e 100644
---- a/lib/vtls/mbedtls.c
-+++ b/lib/vtls/mbedtls.c
-@@ -485,7 +485,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- char * const ssl_cert = ssl_config->primary.clientcert;
- const struct curl_blob *ssl_cert_blob = ssl_config->primary.cert_blob;
- #ifdef MBEDTLS_PEM_PARSE_C
-- const char * const ssl_cert_type = ssl_config->cert_type;
-+ const char * const ssl_cert_type = ssl_config->primary.cert_type;
- #endif
- const char * const ssl_crlfile = ssl_config->primary.CRLfile;
- const char *hostname = connssl->peer.hostname;
-@@ -642,7 +642,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- if(ret) {
- mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
- failf(data, "mbedTLS: error reading client cert data %s: (-0x%04X) %s",
-- ssl_config->key, -ret, errorbuf);
-+ ssl_config->primary.key, -ret, errorbuf);
- return CURLE_SSL_CERTPROBLEM;
- }
- }
-@@ -650,12 +650,12 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- /* Load the client private key */
- mbedtls_pk_init(&backend->pk);
-
-- if(ssl_config->key || ssl_config->key_blob) {
-- if(ssl_config->key) {
-+ if(ssl_config->primary.key || ssl_config->primary.key_blob) {
-+ if(ssl_config->primary.key) {
- #ifdef MBEDTLS_FS_IO
- #if MBEDTLS_VERSION_NUMBER >= 0x04000000
-- ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->key,
-- ssl_config->key_passwd);
-+ ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->primary.key,
-+ ssl_config->primary.key_passwd);
- if(ret == 0 && !(mbedtls_pk_can_do_psa(&backend->pk,
- PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH),
- PSA_KEY_USAGE_SIGN_HASH) ||
-@@ -664,8 +664,8 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- PSA_KEY_USAGE_SIGN_HASH)))
- ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
- #else
-- ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->key,
-- ssl_config->key_passwd,
-+ ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->primary.key,
-+ ssl_config->primary.key_passwd,
- mbedtls_ctr_drbg_random,
- &rng.drbg);
- if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
-@@ -676,7 +676,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- if(ret) {
- mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
- failf(data, "mbedTLS: error reading private key %s: (-0x%04X) %s",
-- ssl_config->key, -ret, errorbuf);
-+ ssl_config->primary.key, -ret, errorbuf);
- return CURLE_SSL_CERTPROBLEM;
- }
- #else
-@@ -685,10 +685,10 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- #endif
- }
- else {
-- const struct curl_blob *ssl_key_blob = ssl_config->key_blob;
-+ const struct curl_blob *ssl_key_blob = ssl_config->primary.key_blob;
- const unsigned char *key_data =
- (const unsigned char *)ssl_key_blob->data;
-- const char *passwd = ssl_config->key_passwd;
-+ const char *passwd = ssl_config->primary.key_passwd;
- #if MBEDTLS_VERSION_NUMBER >= 0x04000000
- ret = mbedtls_pk_parse_key(&backend->pk, key_data, ssl_key_blob->len,
- (const unsigned char *)passwd,
-@@ -881,7 +881,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
- NULL);
- #endif
-
-- if(ssl_config->key || ssl_config->key_blob) {
-+ if(ssl_config->primary.key || ssl_config->primary.key_blob) {
- mbedtls_ssl_conf_own_cert(&backend->config,
- &backend->clicert, &backend->pk);
- }
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 600a64ca6a..9168d27b78 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -3688,7 +3688,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
- struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
- char * const ssl_cert = ssl_config->primary.clientcert;
- const struct curl_blob *ssl_cert_blob = ssl_config->primary.cert_blob;
-- const char * const ssl_cert_type = ssl_config->cert_type;
-+ const char * const ssl_cert_type = ssl_config->primary.cert_type;
- unsigned int ssl_version_min;
- char error_buffer[256];
-
-@@ -3857,8 +3857,9 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
- if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
- result = client_cert(data, octx->ssl_ctx,
- ssl_cert, ssl_cert_blob, ssl_cert_type,
-- ssl_config->key, ssl_config->key_blob,
-- ssl_config->key_type, ssl_config->key_passwd);
-+ ssl_config->primary.key, ssl_config->primary.key_blob,
-+ ssl_config->primary.key_type,
-+ ssl_config->primary.key_passwd);
- if(result)
- /* failf() is already done in client_cert() */
- return result;
-diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
-index fc380b062b..0401185145 100644
---- a/lib/vtls/rustls.c
-+++ b/lib/vtls/rustls.c
-@@ -840,14 +840,14 @@ init_config_builder_client_auth(struct Curl_easy *data,
- const struct rustls_certified_key *certified_key = NULL;
- CURLcode result = CURLE_OK;
-
-- if(conn_config->clientcert && !ssl_config->key) {
-+ if(conn_config->clientcert && !ssl_config->primary.key) {
- failf(data, "rustls: must provide key with certificate '%s'",
- conn_config->clientcert);
- return CURLE_SSL_CERTPROBLEM;
- }
-- else if(!conn_config->clientcert && ssl_config->key) {
-+ else if(!conn_config->clientcert && ssl_config->primary.key) {
- failf(data, "rustls: must provide certificate with key '%s'",
-- ssl_config->key);
-+ ssl_config->primary.key);
- return CURLE_SSL_CERTPROBLEM;
- }
-
-@@ -861,8 +861,9 @@ init_config_builder_client_auth(struct Curl_easy *data,
- goto cleanup;
- }
-
-- if(!read_file_into(ssl_config->key, &key_contents)) {
-- failf(data, "rustls: failed to read key file: '%s'", ssl_config->key);
-+ if(!read_file_into(ssl_config->primary.key, &key_contents)) {
-+ failf(data, "rustls: failed to read key file: '%s'",
-+ ssl_config->primary.key);
- result = CURLE_SSL_CERTPROBLEM;
- goto cleanup;
- }
-@@ -1052,7 +1053,7 @@ static CURLcode cr_init_backend(struct Curl_cfilter *cf,
- }
- }
-
-- if(conn_config->clientcert || ssl_config->key) {
-+ if(conn_config->clientcert || ssl_config->primary.key) {
- result = init_config_builder_client_auth(data,
- conn_config,
- ssl_config,
-diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
-index 891dfc4e73..9989bcde9b 100644
---- a/lib/vtls/schannel.c
-+++ b/lib/vtls/schannel.c
-@@ -547,8 +547,8 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
- }
- }
-
-- if((fInCert || blob) && data->set.ssl.cert_type &&
-- !curl_strequal(data->set.ssl.cert_type, "P12")) {
-+ if((fInCert || blob) && data->set.ssl.primary.cert_type &&
-+ !curl_strequal(data->set.ssl.primary.cert_type, "P12")) {
- failf(data, "schannel: certificate format compatibility error "
- " for %s",
- blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
-@@ -601,14 +601,14 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
- datablob.pbData = (BYTE *)certdata;
- datablob.cbData = (DWORD)certsize;
-
-- if(data->set.ssl.key_passwd)
-- pwd_len = strlen(data->set.ssl.key_passwd);
-+ if(data->set.ssl.primary.key_passwd)
-+ pwd_len = strlen(data->set.ssl.primary.key_passwd);
- pszPassword = (WCHAR *)curlx_malloc(sizeof(WCHAR) * (pwd_len + 1));
- if(pszPassword) {
- if(pwd_len > 0)
- str_w_len = MultiByteToWideChar(CP_UTF8,
- MB_ERR_INVALID_CHARS,
-- data->set.ssl.key_passwd,
-+ data->set.ssl.primary.key_passwd,
- (int)pwd_len,
- pszPassword, (int)(pwd_len + 1));
-
-diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
-index 851bc341a9..0bdab12f07 100644
---- a/lib/vtls/vtls.c
-+++ b/lib/vtls/vtls.c
-@@ -199,6 +199,7 @@ static bool match_ssl_primary_config(struct Curl_easy *data,
- blobcmp(c1->cert_blob, c2->cert_blob) &&
- blobcmp(c1->ca_info_blob, c2->ca_info_blob) &&
- blobcmp(c1->issuercert_blob, c2->issuercert_blob) &&
-+ blobcmp(c1->key_blob, c2->key_blob) &&
- Curl_safecmp(c1->CApath, c2->CApath) &&
- Curl_safecmp(c1->CAfile, c2->CAfile) &&
- Curl_safecmp(c1->issuercert, c2->issuercert) &&
-@@ -212,7 +213,11 @@ static bool match_ssl_primary_config(struct Curl_easy *data,
- curl_strequal(c1->curves, c2->curves) &&
- curl_strequal(c1->signature_algorithms, c2->signature_algorithms) &&
- curl_strequal(c1->CRLfile, c2->CRLfile) &&
-- curl_strequal(c1->pinned_key, c2->pinned_key))
-+ curl_strequal(c1->pinned_key, c2->pinned_key) &&
-+ curl_strequal(c1->cert_type, c2->cert_type) &&
-+ Curl_safecmp(c1->key, c2->key) &&
-+ curl_strequal(c1->key_type, c2->key_type) &&
-+ !Curl_timestrcmp(c1->key_passwd, c2->key_passwd))
- return TRUE;
-
- return FALSE;
-@@ -247,6 +252,7 @@ static bool clone_ssl_primary_config(struct ssl_primary_config *source,
- CLONE_BLOB(cert_blob);
- CLONE_BLOB(ca_info_blob);
- CLONE_BLOB(issuercert_blob);
-+ CLONE_BLOB(key_blob);
- CLONE_STRING(CApath);
- CLONE_STRING(CAfile);
- CLONE_STRING(issuercert);
-@@ -257,6 +263,10 @@ static bool clone_ssl_primary_config(struct ssl_primary_config *source,
- CLONE_STRING(curves);
- CLONE_STRING(signature_algorithms);
- CLONE_STRING(CRLfile);
-+ CLONE_STRING(cert_type);
-+ CLONE_STRING(key);
-+ CLONE_STRING(key_type);
-+ CLONE_STRING(key_passwd);
- #ifdef USE_TLS_SRP
- CLONE_STRING(username);
- CLONE_STRING(password);
-@@ -277,9 +287,14 @@ static void free_primary_ssl_config(struct ssl_primary_config *sslc)
- Curl_safefree(sslc->cert_blob);
- Curl_safefree(sslc->ca_info_blob);
- Curl_safefree(sslc->issuercert_blob);
-+ Curl_safefree(sslc->key_blob);
- Curl_safefree(sslc->curves);
- Curl_safefree(sslc->signature_algorithms);
- Curl_safefree(sslc->CRLfile);
-+ Curl_safefree(sslc->cert_type);
-+ Curl_safefree(sslc->key);
-+ Curl_safefree(sslc->key_type);
-+ Curl_safefree(sslc->key_passwd);
- #ifdef USE_TLS_SRP
- Curl_safefree(sslc->username);
- Curl_safefree(sslc->password);
-@@ -348,12 +363,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- sslc->primary.username = data->set.str[STRING_TLSAUTH_USERNAME];
- sslc->primary.password = data->set.str[STRING_TLSAUTH_PASSWORD];
- #endif
-- sslc->cert_type = data->set.str[STRING_CERT_TYPE];
-- sslc->key = data->set.str[STRING_KEY];
-- sslc->key_type = data->set.str[STRING_KEY_TYPE];
-- sslc->key_passwd = data->set.str[STRING_KEY_PASSWD];
-+ sslc->primary.cert_type = data->set.str[STRING_CERT_TYPE];
-+ sslc->primary.key = data->set.str[STRING_KEY];
-+ sslc->primary.key_type = data->set.str[STRING_KEY_TYPE];
-+ sslc->primary.key_passwd = data->set.str[STRING_KEY_PASSWD];
- sslc->primary.clientcert = data->set.str[STRING_CERT];
-- sslc->key_blob = data->set.blobs[BLOB_KEY];
-+ sslc->primary.key_blob = data->set.blobs[BLOB_KEY];
-
- #ifndef CURL_DISABLE_PROXY
- sslc = &data->set.proxy_ssl;
-@@ -391,12 +406,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- sslc->primary.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
- sslc->primary.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY];
- sslc->primary.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
-- sslc->cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
-- sslc->key = data->set.str[STRING_KEY_PROXY];
-- sslc->key_type = data->set.str[STRING_KEY_TYPE_PROXY];
-- sslc->key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
-+ sslc->primary.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
-+ sslc->primary.key = data->set.str[STRING_KEY_PROXY];
-+ sslc->primary.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
-+ sslc->primary.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
- sslc->primary.clientcert = data->set.str[STRING_CERT_PROXY];
-- sslc->key_blob = data->set.blobs[BLOB_KEY_PROXY];
-+ sslc->primary.key_blob = data->set.blobs[BLOB_KEY_PROXY];
- #ifdef USE_TLS_SRP
- sslc->primary.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
- sslc->primary.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
-diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c
-index df04ec7e00..47bf655b71 100644
---- a/lib/vtls/vtls_scache.c
-+++ b/lib/vtls/vtls_scache.c
-@@ -52,6 +52,7 @@ static bool cf_ssl_peer_key_is_global(const char *peer_key);
- struct Curl_ssl_scache_peer {
- char *ssl_peer_key; /* id for peer + relevant TLS configuration */
- char *clientcert;
-+ char *key_passwd;
- char *srp_username;
- char *srp_password;
- struct Curl_llist sessions;
-@@ -176,6 +177,7 @@ static void cf_ssl_scache_clear_peer(struct Curl_ssl_scache_peer *peer)
- }
- peer->sobj_free = NULL;
- Curl_safefree(peer->clientcert);
-+ Curl_safefree(peer->key_passwd);
- #ifdef USE_TLS_SRP
- Curl_safefree(peer->srp_username);
- Curl_safefree(peer->srp_password);
-@@ -204,8 +206,8 @@ static void cf_ssl_cache_peer_update(struct Curl_ssl_scache_peer *peer)
- * - its peer key is not yet known, because sessions were
- * imported using only the salt+hmac
- * - the peer key is global, e.g. carrying no relative paths */
-- peer->exportable = (!peer->clientcert && !peer->srp_username &&
-- !peer->srp_password &&
-+ peer->exportable = (!peer->clientcert && !peer->key_passwd &&
-+ !peer->srp_username && !peer->srp_password &&
- (!peer->ssl_peer_key ||
- cf_ssl_peer_key_is_global(peer->ssl_peer_key)));
- }
-@@ -214,6 +216,7 @@ static CURLcode
- cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
- const char *ssl_peer_key,
- const char *clientcert,
-+ const char *key_passwd,
- const char *srp_username,
- const char *srp_password,
- const unsigned char *salt,
-@@ -242,6 +245,11 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
- if(!peer->clientcert)
- goto out;
- }
-+ if(key_passwd) {
-+ peer->key_passwd = curlx_strdup(key_passwd);
-+ if(!peer->key_passwd)
-+ goto out;
-+ }
- if(srp_username) {
- peer->srp_username = curlx_strdup(srp_username);
- if(!peer->srp_username)
-@@ -425,6 +433,48 @@ out:
- return r;
- }
-
-+static CURLcode cf_ssl_peer_key_add_mtls(struct dynbuf *buf,
-+ struct ssl_primary_config *ssl,
-+ bool *is_local)
-+{
-+ CURLcode r = CURLE_OK;
-+ if(ssl->clientcert && ssl->clientcert[0]) {
-+ r = cf_ssl_peer_key_add_path(buf, "CCERT", ssl->clientcert, is_local);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->key && ssl->key[0]) {
-+ r = cf_ssl_peer_key_add_path(buf, "KEY", ssl->key, is_local);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->key_blob) {
-+ r = cf_ssl_peer_key_add_hash(buf, "KEYBlob", ssl->key_blob);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->cert_type && ssl->cert_type[0]) {
-+ size_t i;
-+ r = curlx_dyn_add(buf, ":CT-");
-+ for(i = 0; !r && ssl->cert_type[i]; i++) {
-+ char c = Curl_raw_toupper(ssl->cert_type[i]);
-+ r = curlx_dyn_addn(buf, &c, 1);
-+ }
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->key_type && ssl->key_type[0]) {
-+ size_t i;
-+ r = curlx_dyn_add(buf, ":KT-");
-+ for(i = 0; !r && ssl->key_type[i]; i++) {
-+ char c = Curl_raw_toupper(ssl->key_type[i]);
-+ r = curlx_dyn_addn(buf, &c, 1);
-+ }
-+ }
-+out:
-+ return r;
-+}
-+
- #define CURL_SSLS_LOCAL_SUFFIX ":L"
- #define CURL_SSLS_GLOBAL_SUFFIX ":G"
-
-@@ -436,6 +486,152 @@ static bool cf_ssl_peer_key_is_global(const char *peer_key)
- (peer_key[len - 2] == ':');
- }
-
-+CURLcode Curl_ssl_peer_key_build(struct ssl_primary_config *ssl,
-+ const struct ssl_peer *peer,
-+ const char *tls_id,
-+ char **ppeer_key)
-+{
-+ struct dynbuf buf;
-+ size_t key_len;
-+ bool is_local = FALSE;
-+ CURLcode r;
-+
-+ *ppeer_key = NULL;
-+ curlx_dyn_init(&buf, 10 * 1024);
-+
-+ r = curlx_dyn_addf(&buf, "%s:%d", peer->hostname, peer->port);
-+ if(r)
-+ goto out;
-+
-+ switch(peer->transport) {
-+ case TRNSPRT_TCP:
-+ break;
-+ case TRNSPRT_UDP:
-+ r = curlx_dyn_add(&buf, ":UDP");
-+ break;
-+ case TRNSPRT_QUIC:
-+ r = curlx_dyn_add(&buf, ":QUIC");
-+ break;
-+ case TRNSPRT_UNIX:
-+ r = curlx_dyn_add(&buf, ":UNIX");
-+ break;
-+ default:
-+ r = curlx_dyn_addf(&buf, ":TRNSPRT-%d", peer->transport);
-+ break;
-+ }
-+ if(r)
-+ goto out;
-+
-+ if(!ssl->verifypeer) {
-+ r = curlx_dyn_add(&buf, ":NO-VRFY-PEER");
-+ if(r)
-+ goto out;
-+ }
-+ if(!ssl->verifyhost) {
-+ r = curlx_dyn_add(&buf, ":NO-VRFY-HOST");
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->verifystatus) {
-+ r = curlx_dyn_add(&buf, ":VRFY-STATUS");
-+ if(r)
-+ goto out;
-+ }
-+
-+ if(ssl->version || ssl->version_max) {
-+ r = curlx_dyn_addf(&buf, ":TLSVER-%d-%d", ssl->version,
-+ (ssl->version_max >> 16));
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->ssl_options) {
-+ r = curlx_dyn_addf(&buf, ":TLSOPT-%x", ssl->ssl_options);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->cipher_list) {
-+ r = curlx_dyn_addf(&buf, ":CIPHER-%s", ssl->cipher_list);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->cipher_list13) {
-+ r = curlx_dyn_addf(&buf, ":CIPHER13-%s", ssl->cipher_list13);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->curves) {
-+ r = curlx_dyn_addf(&buf, ":CURVES-%s", ssl->curves);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->verifypeer) {
-+ r = cf_ssl_peer_key_add_path(&buf, "CA", ssl->CAfile, &is_local);
-+ if(r)
-+ goto out;
-+ r = cf_ssl_peer_key_add_path(&buf, "CApath", ssl->CApath, &is_local);
-+ if(r)
-+ goto out;
-+ r = cf_ssl_peer_key_add_path(&buf, "CRL", ssl->CRLfile, &is_local);
-+ if(r)
-+ goto out;
-+ r = cf_ssl_peer_key_add_path(&buf, "Issuer", ssl->issuercert, &is_local);
-+ if(r)
-+ goto out;
-+ if(ssl->cert_blob) {
-+ r = cf_ssl_peer_key_add_hash(&buf, "CertBlob", ssl->cert_blob);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->ca_info_blob) {
-+ r = cf_ssl_peer_key_add_hash(&buf, "CAInfoBlob", ssl->ca_info_blob);
-+ if(r)
-+ goto out;
-+ }
-+ if(ssl->issuercert_blob) {
-+ r = cf_ssl_peer_key_add_hash(&buf, "IssuerBlob", ssl->issuercert_blob);
-+ if(r)
-+ goto out;
-+ }
-+ }
-+ if(ssl->pinned_key && ssl->pinned_key[0]) {
-+ r = curlx_dyn_addf(&buf, ":Pinned-%s", ssl->pinned_key);
-+ if(r)
-+ goto out;
-+ }
-+
-+ r = cf_ssl_peer_key_add_mtls(&buf, ssl, &is_local);
-+ if(r)
-+ goto out;
-+#ifdef USE_TLS_SRP
-+ if(ssl->username || ssl->password) {
-+ r = curlx_dyn_add(&buf, ":SRP-AUTH");
-+ if(r)
-+ goto out;
-+ }
-+#endif
-+
-+ if(!tls_id || !tls_id[0]) {
-+ r = CURLE_FAILED_INIT;
-+ goto out;
-+ }
-+ r = curlx_dyn_addf(&buf, ":IMPL-%s", tls_id);
-+ if(r)
-+ goto out;
-+
-+ r = curlx_dyn_addf(&buf, is_local ?
-+ CURL_SSLS_LOCAL_SUFFIX : CURL_SSLS_GLOBAL_SUFFIX);
-+ if(r)
-+ goto out;
-+
-+ *ppeer_key = curlx_dyn_take(&buf, &key_len);
-+ /* we just added printable char, and dynbuf always null-terminates, no need
-+ * to track length */
-+
-+out:
-+ curlx_dyn_free(&buf);
-+ return r;
-+}
-+
- CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
- const struct ssl_peer *peer,
- const char *tls_id,
-@@ -562,11 +758,9 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
- goto out;
- }
-
-- if(ssl->clientcert && ssl->clientcert[0]) {
-- r = curlx_dyn_add(&buf, ":CCERT");
-- if(r)
-- goto out;
-- }
-+ r = cf_ssl_peer_key_add_mtls(&buf, ssl, &is_local);
-+ if(r)
-+ goto out;
- #ifdef USE_TLS_SRP
- if(ssl->username || ssl->password) {
- r = curlx_dyn_add(&buf, ":SRP-AUTH");
-@@ -601,7 +795,7 @@ static bool cf_ssl_scache_match_auth(struct Curl_ssl_scache_peer *peer,
- struct ssl_primary_config *conn_config)
- {
- if(!conn_config) {
-- if(peer->clientcert)
-+ if(peer->clientcert || peer->key_passwd)
- return FALSE;
- #ifdef USE_TLS_SRP
- if(peer->srp_username || peer->srp_password)
-@@ -611,6 +805,8 @@ static bool cf_ssl_scache_match_auth(struct Curl_ssl_scache_peer *peer,
- }
- else if(!Curl_safecmp(peer->clientcert, conn_config->clientcert))
- return FALSE;
-+ if(Curl_timestrcmp(peer->key_passwd, conn_config->key_passwd))
-+ return FALSE;
- #ifdef USE_TLS_SRP
- if(Curl_timestrcmp(peer->srp_username, conn_config->username) ||
- Curl_timestrcmp(peer->srp_password, conn_config->password))
-@@ -738,12 +934,13 @@ static CURLcode cf_ssl_add_peer(struct Curl_easy *data,
- peer = cf_ssl_get_free_peer(scache);
- if(peer) {
- const char *ccert = conn_config ? conn_config->clientcert : NULL;
-+ const char *kpasswd = conn_config ? conn_config->key_passwd : NULL;
- const char *username = NULL, *password = NULL;
- #ifdef USE_TLS_SRP
- username = conn_config ? conn_config->username : NULL;
- password = conn_config ? conn_config->password : NULL;
- #endif
-- result = cf_ssl_scache_peer_init(peer, ssl_peer_key, ccert,
-+ result = cf_ssl_scache_peer_init(peer, ssl_peer_key, ccert, kpasswd,
- username, password, NULL, NULL);
- if(result)
- goto out;
-@@ -1118,7 +1315,7 @@ CURLcode Curl_ssl_session_import(struct Curl_easy *data,
- if(!peer) {
- peer = cf_ssl_get_free_peer(scache);
- if(peer) {
-- r = cf_ssl_scache_peer_init(peer, ssl_peer_key, NULL,
-+ r = cf_ssl_scache_peer_init(peer, ssl_peer_key, NULL, NULL,
- NULL, NULL, salt, hmac);
- if(r)
- goto out;
-diff --git a/lib/vtls/vtls_scache.h b/lib/vtls/vtls_scache.h
-index 2a99e779e5..e84b6e799a 100644
---- a/lib/vtls/vtls_scache.h
-+++ b/lib/vtls/vtls_scache.h
-@@ -66,6 +66,20 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
- const char *tls_id,
- char **ppeer_key);
-
-+/**
-+ * Like Curl_ssl_peer_key_make() but takes the primary config and peer
-+ * descriptors directly, without requiring a Curl_cfilter. Exposed for
-+ * unit testing.
-+ * @param ssl the primary SSL config to key on
-+ * @param peer the peer the filter wants to talk to
-+ * @param tls_id identifier of TLS implementation for sessions
-+ * @param ppeer_key on successful return, the key generated
-+ */
-+CURLcode Curl_ssl_peer_key_build(struct ssl_primary_config *ssl,
-+ const struct ssl_peer *peer,
-+ const char *tls_id,
-+ char **ppeer_key);
-+
- /* Return if there is a session cache shall be used.
- * An ssl session might not be configured or not available for
- * "connect-only" transfers.
-diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c
-index 510378886d..6f3c5b2697 100644
---- a/lib/vtls/wolfssl.c
-+++ b/lib/vtls/wolfssl.c
-@@ -937,10 +937,10 @@ static CURLcode client_certificate(struct Curl_easy *data,
- #ifndef NO_FILESYSTEM
- if(ssl_config->primary.cert_blob || ssl_config->primary.clientcert) {
- const char *cert_file = ssl_config->primary.clientcert;
-- const char *key_file = ssl_config->key;
-+ const char *key_file = ssl_config->primary.key;
- const struct curl_blob *cert_blob = ssl_config->primary.cert_blob;
-- const struct curl_blob *key_blob = ssl_config->key_blob;
-- int file_type = wssl_do_file_type(ssl_config->cert_type);
-+ const struct curl_blob *key_blob = ssl_config->primary.key_blob;
-+ int file_type = wssl_do_file_type(ssl_config->primary.cert_type);
- int rc;
-
- switch(file_type) {
-@@ -971,7 +971,7 @@ static CURLcode client_certificate(struct Curl_easy *data,
- key_file = cert_file;
- }
- else
-- file_type = wssl_do_file_type(ssl_config->key_type);
-+ file_type = wssl_do_file_type(ssl_config->primary.key_type);
-
- rc = key_blob ?
- wolfSSL_CTX_use_PrivateKey_buffer(wctx->ssl_ctx, key_blob->data,
-@@ -985,8 +985,8 @@ static CURLcode client_certificate(struct Curl_easy *data,
- #else /* NO_FILESYSTEM */
- if(ssl_config->primary.cert_blob) {
- const struct curl_blob *cert_blob = ssl_config->primary.cert_blob;
-- const struct curl_blob *key_blob = ssl_config->key_blob;
-- int file_type = wssl_do_file_type(ssl_config->cert_type);
-+ const struct curl_blob *key_blob = ssl_config->primary.key_blob;
-+ int file_type = wssl_do_file_type(ssl_config->primary.cert_type);
- int rc;
-
- switch(file_type) {
-@@ -1011,7 +1011,7 @@ static CURLcode client_certificate(struct Curl_easy *data,
- if(!key_blob)
- key_blob = cert_blob;
- else
-- file_type = wssl_do_file_type(ssl_config->key_type);
-+ file_type = wssl_do_file_type(ssl_config->primary.key_type);
-
- if(wolfSSL_CTX_use_PrivateKey_buffer(wctx->ssl_ctx, key_blob->data,
- (long)key_blob->len,
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 8b448cfcca..7b7dcf0e93 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -284,6 +284,8 @@ test3032 test3033 test3034 test3035 \
- \
- test3100 test3101 test3102 test3103 test3104 test3105 \
- \
-+test3303 test3304 \
-+\
- test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 \
- test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \
- test4000 test4001
-diff --git a/tests/data/test3303 b/tests/data/test3303
-new file mode 100644
-index 0000000000..697049f013
---- /dev/null
-+++ b/tests/data/test3303
-@@ -0,0 +1,20 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+unittest
-+TLS
-+mTLS
-+</keywords>
-+</info>
-+
-+# Client-side
-+<client>
-+<features>
-+unittest
-+</features>
-+<name>
-+conn-reuse match distinguishes mTLS key, cert_type, key_type and key_passwd fields
-+</name>
-+</client>
-+</testcase>
-diff --git a/tests/data/test3304 b/tests/data/test3304
-new file mode 100644
-index 0000000000..4380c0819f
---- /dev/null
-+++ b/tests/data/test3304
-@@ -0,0 +1,20 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+unittest
-+TLS
-+mTLS
-+</keywords>
-+</info>
-+
-+# Client-side
-+<client>
-+<features>
-+unittest
-+</features>
-+<name>
-+TLS session cache peer key discriminates on mTLS key, key_type and cert_type fields
-+</name>
-+</client>
-+</testcase>
-diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc
-index 149636cbcc..bba30f6706 100644
---- a/tests/unit/Makefile.inc
-+++ b/tests/unit/Makefile.inc
-@@ -43,4 +43,5 @@ TESTS_C = \
- unit1979.c unit1980.c \
- unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c unit2605.c \
- unit3200.c unit3205.c \
-- unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c
-+ unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c \
-+ unit3303.c unit3304.c
-diff --git a/tests/unit/unit3303.c b/tests/unit/unit3303.c
-new file mode 100644
-index 0000000000..41bced542d
---- /dev/null
-+++ b/tests/unit/unit3303.c
-@@ -0,0 +1,127 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+#include "unitcheck.h"
-+#include "urldata.h"
-+
-+#ifdef USE_SSL
-+#include "vtls/vtls.h"
-+#endif
-+
-+static CURLcode test_unit3303(const char *arg)
-+{
-+ UNITTEST_BEGIN_SIMPLE
-+
-+#ifdef USE_SSL
-+ {
-+ CURL *curl;
-+ struct connectdata *conn;
-+ struct ssl_primary_config *primary;
-+ char *saved;
-+ static char alt_passwd[] = "wrong";
-+ static char alt_key[] = "other.key";
-+ static char alt_ktype[] = "DER";
-+ static char alt_ctype[] = "P12";
-+
-+ curl_global_init(CURL_GLOBAL_ALL);
-+ curl = curl_easy_init();
-+ if(!curl) {
-+ curl_global_cleanup();
-+ goto unit_test_abort;
-+ }
-+
-+ curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
-+ curl_easy_setopt(curl, CURLOPT_SSLKEY, "client.key");
-+ curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "secret");
-+ curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
-+ curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
-+
-+ if(Curl_ssl_easy_config_complete((struct Curl_easy *)curl)) {
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ goto unit_test_abort;
-+ }
-+
-+ conn = curlx_calloc(1, sizeof(*conn));
-+ if(!conn || Curl_ssl_conn_config_init((struct Curl_easy *)curl, conn)) {
-+ if(conn)
-+ Curl_ssl_conn_config_cleanup(conn);
-+ curlx_free(conn);
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ goto unit_test_abort;
-+ }
-+
-+ /* Baseline: identical config must match. */
-+ fail_unless(Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "identical mTLS config should match");
-+
-+ primary = &((struct Curl_easy *)curl)->set.ssl.primary;
-+
-+ /* Different key_passwd must not match. */
-+ saved = primary->key_passwd;
-+ primary->key_passwd = alt_passwd;
-+ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "different key_passwd must not reuse conn");
-+ primary->key_passwd = saved;
-+
-+ /* Different key path must not match. */
-+ saved = primary->key;
-+ primary->key = alt_key;
-+ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "different key must not reuse conn");
-+ primary->key = saved;
-+
-+ /* Different key type must not match. */
-+ saved = primary->key_type;
-+ primary->key_type = alt_ktype;
-+ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "different key_type must not reuse conn");
-+ primary->key_type = saved;
-+
-+ /* Different cert type must not match. */
-+ saved = primary->cert_type;
-+ primary->cert_type = alt_ctype;
-+ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "different cert_type must not reuse conn");
-+ primary->cert_type = saved;
-+
-+ /* All fields restored: must match again. */
-+ fail_unless(Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
-+ FALSE),
-+ "restored mTLS config should match");
-+
-+ Curl_ssl_conn_config_cleanup(conn);
-+ curlx_free(conn);
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ }
-+#endif /* USE_SSL */
-+
-+ UNITTEST_END_SIMPLE
-+}
-diff --git a/tests/unit/unit3304.c b/tests/unit/unit3304.c
-new file mode 100644
-index 0000000000..f99a211507
---- /dev/null
-+++ b/tests/unit/unit3304.c
-@@ -0,0 +1,163 @@
-+/***************************************************************************
-+ * _ _ ____ _
-+ * Project ___| | | | _ \| |
-+ * / __| | | | |_) | |
-+ * | (__| |_| | _ <| |___
-+ * \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+
-+/* Unit tests for TLS session cache peer key discrimination on mTLS fields.
-+ * Verifies that Curl_ssl_peer_key_build() produces distinct keys when two
-+ * handles differ only on key, key_type or cert_type. key_passwd is NOT
-+ * embedded in the peer key; it is compared separately at session lookup via
-+ * cf_ssl_scache_match_auth(), following the same pattern as SRP
-+ * credentials. */
-+
-+#include "unitcheck.h"
-+#include "urldata.h"
-+
-+#ifdef USE_SSL
-+#include "vtls/vtls.h"
-+#include "vtls/vtls_scache.h"
-+#endif
-+
-+static CURLcode test_unit3304(const char *arg)
-+{
-+ UNITTEST_BEGIN_SIMPLE
-+
-+#ifdef USE_SSL
-+ {
-+ struct ssl_peer peer;
-+ struct ssl_primary_config ssl;
-+ char *key1 = NULL;
-+ char *key2 = NULL;
-+ static char base_hostname[] = "example.com";
-+ static char base_cert[] = "client.pem";
-+ static char base_key[] = "client.key";
-+ static char base_passwd[] = "secret";
-+ static char base_ctype[] = "PEM";
-+ static char base_ktype[] = "PEM";
-+ static char alt_key[] = "other.key";
-+ static char alt_ktype[] = "DER";
-+ static char alt_ctype[] = "P12";
-+ static char lc_ctype[] = "pem";
-+ static char lc_ktype[] = "pem";
-+
-+ memset(&peer, 0, sizeof(peer));
-+ peer.hostname = base_hostname;
-+ peer.port = 443;
-+ peer.transport = TRNSPRT_TCP;
-+
-+ memset(&ssl, 0, sizeof(ssl));
-+ ssl.verifypeer = TRUE;
-+ ssl.verifyhost = TRUE;
-+ ssl.clientcert = base_cert;
-+ ssl.key = base_key;
-+ ssl.key_passwd = base_passwd;
-+ ssl.cert_type = base_ctype;
-+ ssl.key_type = base_ktype;
-+
-+ /* Baseline: same config produces same key. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && !strcmp(key1, key2),
-+ "identical config should produce identical peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+
-+ /* key_passwd is NOT in the peer key: lookup uses timing-safe comparison
-+ * via cf_ssl_scache_match_auth(), same as SRP credentials. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.key_passwd = NULL;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && !strcmp(key1, key2),
-+ "key_passwd must not affect the peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ ssl.key_passwd = base_passwd;
-+
-+ /* Different key path must produce a different peer key. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.key = alt_key;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && strcmp(key1, key2),
-+ "different key must produce different peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ ssl.key = base_key;
-+
-+ /* Different key_type must produce a different peer key. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.key_type = alt_ktype;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && strcmp(key1, key2),
-+ "different key_type must produce different peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ ssl.key_type = base_ktype;
-+
-+ /* Different cert_type must produce a different peer key. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.cert_type = alt_ctype;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && strcmp(key1, key2),
-+ "different cert_type must produce different peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ ssl.cert_type = base_ctype;
-+
-+ /* cert_type is case-insensitive: "PEM" and "pem" must produce the
-+ * same peer key, consistent with the conn-reuse comparison. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.cert_type = lc_ctype;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && !strcmp(key1, key2),
-+ "cert_type case must not affect peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ ssl.cert_type = base_ctype;
-+
-+ /* key_type is case-insensitive: "PEM" and "pem" must produce the
-+ * same peer key. */
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
-+ "peer key build failed");
-+ ssl.key_type = lc_ktype;
-+ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
-+ "peer key build failed");
-+ fail_unless(key1 && key2 && !strcmp(key1, key2),
-+ "key_type case must not affect peer key");
-+ curlx_free(key1); key1 = NULL;
-+ curlx_free(key2); key2 = NULL;
-+ }
-+#endif /* USE_SSL */
-+
-+ UNITTEST_END_SIMPLE
-+}
---
-2.56.0
-
diff --git a/0031-curl-8.18.0-CVE-2026-13608.patch b/0031-curl-8.18.0-CVE-2026-13608.patch
deleted file mode 100644
index 5cb0dff..0000000
--- a/0031-curl-8.18.0-CVE-2026-13608.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From d284cb9018a0f360cc007c17b06b3d41a3d9d251 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 29 Jun 2026 10:44:47 +0200
-Subject: [PATCH 2/3] openldap: handle Curl_sasl_continue() returns better
-
-Similar to how it gets treated already in other protocol handlers.
-
-Follow-up to eeca818b1e8d1e61c2d4
-
-Reported-by: Eunsoo Kim
-Closes #22213
-
-(cherry picked from commit ea71c3b6b60e563651ea8596a975aef0c8199519)
----
- lib/openldap.c | 15 +++++++++++++--
- 1 file changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/lib/openldap.c b/lib/openldap.c
-index f826a4d006..400c4b00c0 100644
---- a/lib/openldap.c
-+++ b/lib/openldap.c
-@@ -781,8 +781,19 @@ static CURLcode oldap_state_sasl_resp(struct Curl_easy *data,
- }
- else {
- result = Curl_sasl_continue(&li->sasl, data, code, &progress);
-- if(!result && progress != SASL_INPROGRESS)
-- oldap_state(data, li, OLDAP_STOP);
-+ if(!result) {
-+ switch(progress) {
-+ case SASL_DONE:
-+ oldap_state(data, li, OLDAP_STOP); /* Authenticated */
-+ break;
-+ case SASL_IDLE: /* No mechanism left after cancellation */
-+ failf(data, "Authentication cancelled");
-+ result = CURLE_LOGIN_DENIED;
-+ break;
-+ default:
-+ break;
-+ }
-+ }
- }
-
- if(li->servercred)
---
-2.56.0
-
diff --git a/0031-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch b/0031-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
new file mode 100644
index 0000000..314d2a5
--- /dev/null
+++ b/0031-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
@@ -0,0 +1,1218 @@
+From 3367c2fd54fbd2eb05fd97b73e5b78acd57ca1e7 Mon Sep 17 00:00:00 2001
+From: Joshua Rogers <MegaManSec@users.noreply.github.com>
+Date: Tue, 19 May 2026 11:47:50 +0200
+Subject: [PATCH] tls: fix incomplete mTLS config in conn reuse and session
+ cache
+
+cert_type, key, key_type, key_passwd and key_blob lived in
+ssl_config_data but not in ssl_primary_config, so they were invisible to
+match_ssl_primary_config() and to the TLS session cache peer key.
+
+Two easy handles sharing a connection pool could reuse each other's
+authenticated connections when they differed only on SSLKEY, SSLKEYTYPE,
+KEYPASSWD, SSLCERTTYPE or SSLKEYBLOB. The second handle would silently
+inherit the first handle's authenticated identity.
+
+Promote all five fields into ssl_primary_config so the conn-reuse
+predicate and session cache key cover the complete client credential
+set. Also replace the fixed ":CCERT" session cache marker with the
+actual clientcert path so sessions are not shared across different
+client certificates.
+
+Verified by test 3303 and 3304
+
+Reported-By: Joshua Rogers (AISLE Research)
+Closes #21667
+
+(cherry picked from commit 7541ae569d82fb308a5e2d94916027da4fa3ba3e)
+---
+ lib/ldap.c | 4 +-
+ lib/urldata.h | 10 +-
+ lib/vssh/libssh.c | 6 +-
+ lib/vssh/libssh2.c | 2 +-
+ lib/vtls/gtls.c | 14 +--
+ lib/vtls/mbedtls.c | 24 ++---
+ lib/vtls/openssl.c | 7 +-
+ lib/vtls/rustls.c | 13 +--
+ lib/vtls/schannel.c | 10 +-
+ lib/vtls/vtls.c | 37 +++++--
+ lib/vtls/vtls_scache.c | 217 ++++++++++++++++++++++++++++++++++++++--
+ lib/vtls/vtls_scache.h | 14 +++
+ lib/vtls/wolfssl.c | 14 +--
+ tests/data/Makefile.am | 2 +
+ tests/data/test3303 | 20 ++++
+ tests/data/test3304 | 20 ++++
+ tests/unit/Makefile.inc | 3 +-
+ tests/unit/unit3303.c | 127 +++++++++++++++++++++++
+ tests/unit/unit3304.c | 163 ++++++++++++++++++++++++++++++
+ 19 files changed, 635 insertions(+), 72 deletions(-)
+ create mode 100644 tests/data/test3303
+ create mode 100644 tests/data/test3304
+ create mode 100644 tests/unit/unit3303.c
+ create mode 100644 tests/unit/unit3304.c
+
+diff --git a/lib/ldap.c b/lib/ldap.c
+index 95a982f353..6c2885ca28 100644
+--- a/lib/ldap.c
++++ b/lib/ldap.c
+@@ -402,8 +402,8 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ #ifdef LDAP_OPT_X_TLS
+ if(conn->ssl_config.verifypeer) {
+ /* OpenLDAP SDK supports BASE64 files. */
+- if(data->set.ssl.cert_type &&
+- !curl_strequal(data->set.ssl.cert_type, "PEM")) {
++ if(data->set.ssl.primary.cert_type &&
++ !curl_strequal(data->set.ssl.primary.cert_type, "PEM")) {
+ failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type");
+ result = CURLE_SSL_CERTPROBLEM;
+ goto quit;
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 1e527826ca..c31073c951 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -238,9 +238,14 @@ struct ssl_primary_config {
+ char *signature_algorithms; /* list of signature algorithms to use */
+ char *pinned_key;
+ char *CRLfile; /* CRL to check certificate revocation */
++ char *cert_type; /* format for certificate (default: PEM) */
++ char *key; /* private key filename */
++ char *key_type; /* format for private key (default: PEM) */
++ char *key_passwd; /* plain text private key password */
+ struct curl_blob *cert_blob;
+ struct curl_blob *ca_info_blob;
+ struct curl_blob *issuercert_blob;
++ struct curl_blob *key_blob;
+ #ifdef USE_TLS_SRP
+ char *username; /* TLS username (for, e.g., SRP) */
+ char *password; /* TLS password (for, e.g., SRP) */
+@@ -260,11 +265,6 @@ struct ssl_config_data {
+ long certverifyresult; /* result from the certificate verification */
+ curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
+ void *fsslctxp; /* parameter for call back */
+- char *cert_type; /* format for certificate (default: PEM) */
+- char *key; /* private key filename */
+- struct curl_blob *key_blob;
+- char *key_type; /* format for private key (default: PEM) */
+- char *key_passwd; /* plain text private key password */
+ BIT(certinfo); /* gather lots of certificate info */
+ BIT(earlydata); /* use TLS 1.3 early data */
+ BIT(enable_beast); /* allow this flaw for interoperability's sake */
+diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c
+index 199e97bd3f..31b379ff6c 100644
+--- a/lib/vssh/libssh.c
++++ b/lib/vssh/libssh.c
+@@ -958,7 +958,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
+ /* Two choices, (1) private key was given on CMD,
+ * (2) use the "default" keys. */
+ if(data->set.str[STRING_SSH_PRIVATE_KEY]) {
+- if(sshc->pubkey && !data->set.ssl.key_passwd) {
++ if(sshc->pubkey && !data->set.ssl.primary.key_passwd) {
+ rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL, sshc->pubkey);
+ if(rc == SSH_AUTH_AGAIN)
+ return SSH_AGAIN;
+@@ -971,7 +971,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
+
+ rc = ssh_pki_import_privkey_file(data->
+ set.str[STRING_SSH_PRIVATE_KEY],
+- data->set.ssl.key_passwd, NULL,
++ data->set.ssl.primary.key_passwd, NULL,
+ NULL, &sshc->privkey);
+ if(rc != SSH_OK) {
+ failf(data, "Could not load private key file %s",
+@@ -984,7 +984,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data,
+ }
+ else {
+ rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL,
+- data->set.ssl.key_passwd);
++ data->set.ssl.primary.key_passwd);
+ if(rc == SSH_AUTH_AGAIN)
+ return SSH_AGAIN;
+
+diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
+index 5b2b337289..1d778da533 100644
+--- a/lib/vssh/libssh2.c
++++ b/lib/vssh/libssh2.c
+@@ -1260,7 +1260,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data,
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+- sshc->passphrase = data->set.ssl.key_passwd;
++ sshc->passphrase = data->set.ssl.primary.key_passwd;
+ if(!sshc->passphrase)
+ sshc->passphrase = "";
+
+diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
+index 934273e0ee..1b3f89aca0 100644
+--- a/lib/vtls/gtls.c
++++ b/lib/vtls/gtls.c
+@@ -986,10 +986,11 @@ static CURLcode gtls_client_init(struct Curl_cfilter *cf,
+ if(result)
+ return result;
+ }
+- if(ssl_config->cert_type && curl_strequal(ssl_config->cert_type, "P12")) {
++ if(ssl_config->primary.cert_type &&
++ curl_strequal(ssl_config->primary.cert_type, "P12")) {
+ rc = gnutls_certificate_set_x509_simple_pkcs12_file(
+ gtls->shared_creds->creds, config->clientcert, GNUTLS_X509_FMT_DER,
+- ssl_config->key_passwd ? ssl_config->key_passwd : "");
++ ssl_config->primary.key_passwd ? ssl_config->primary.key_passwd : "");
+ if(rc != GNUTLS_E_SUCCESS) {
+ failf(data,
+ "error reading X.509 potentially-encrypted key or certificate "
+@@ -1007,14 +1008,15 @@ static CURLcode gtls_client_init(struct Curl_cfilter *cf,
+ rc = gnutls_certificate_set_x509_key_file2(
+ gtls->shared_creds->creds,
+ config->clientcert,
+- ssl_config->key ? ssl_config->key : config->clientcert,
+- gnutls_do_file_type(ssl_config->cert_type),
+- ssl_config->key_passwd,
++ ssl_config->primary.key ? ssl_config->primary.key :
++ config->clientcert,
++ gnutls_do_file_type(ssl_config->primary.cert_type),
++ ssl_config->primary.key_passwd,
+ supported_key_encryption_algorithms);
+ if(rc != GNUTLS_E_SUCCESS) {
+ failf(data,
+ "error reading X.509 %skey file: %s",
+- ssl_config->key_passwd ? "potentially-encrypted " : "",
++ ssl_config->primary.key_passwd ? "potentially-encrypted " : "",
+ gnutls_strerror(rc));
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
+index dff45a3299..3035dcb68e 100644
+--- a/lib/vtls/mbedtls.c
++++ b/lib/vtls/mbedtls.c
+@@ -485,7 +485,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ char * const ssl_cert = ssl_config->primary.clientcert;
+ const struct curl_blob *ssl_cert_blob = ssl_config->primary.cert_blob;
+ #ifdef MBEDTLS_PEM_PARSE_C
+- const char * const ssl_cert_type = ssl_config->cert_type;
++ const char * const ssl_cert_type = ssl_config->primary.cert_type;
+ #endif
+ const char * const ssl_crlfile = ssl_config->primary.CRLfile;
+ const char *hostname = connssl->peer.hostname;
+@@ -642,7 +642,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ if(ret) {
+ mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
+ failf(data, "mbedTLS: error reading client cert data %s: (-0x%04X) %s",
+- ssl_config->key, -ret, errorbuf);
++ ssl_config->primary.key, -ret, errorbuf);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ }
+@@ -650,12 +650,12 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ /* Load the client private key */
+ mbedtls_pk_init(&backend->pk);
+
+- if(ssl_config->key || ssl_config->key_blob) {
+- if(ssl_config->key) {
++ if(ssl_config->primary.key || ssl_config->primary.key_blob) {
++ if(ssl_config->primary.key) {
+ #ifdef MBEDTLS_FS_IO
+ #if MBEDTLS_VERSION_NUMBER >= 0x04000000
+- ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->key,
+- ssl_config->key_passwd);
++ ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->primary.key,
++ ssl_config->primary.key_passwd);
+ if(ret == 0 && !(mbedtls_pk_can_do_psa(&backend->pk,
+ PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_ANY_HASH),
+ PSA_KEY_USAGE_SIGN_HASH) ||
+@@ -664,8 +664,8 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ PSA_KEY_USAGE_SIGN_HASH)))
+ ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
+ #else
+- ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->key,
+- ssl_config->key_passwd,
++ ret = mbedtls_pk_parse_keyfile(&backend->pk, ssl_config->primary.key,
++ ssl_config->primary.key_passwd,
+ mbedtls_ctr_drbg_random,
+ &rng.drbg);
+ if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
+@@ -676,7 +676,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ if(ret) {
+ mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
+ failf(data, "mbedTLS: error reading private key %s: (-0x%04X) %s",
+- ssl_config->key, -ret, errorbuf);
++ ssl_config->primary.key, -ret, errorbuf);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ #else
+@@ -685,10 +685,10 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ #endif
+ }
+ else {
+- const struct curl_blob *ssl_key_blob = ssl_config->key_blob;
++ const struct curl_blob *ssl_key_blob = ssl_config->primary.key_blob;
+ const unsigned char *key_data =
+ (const unsigned char *)ssl_key_blob->data;
+- const char *passwd = ssl_config->key_passwd;
++ const char *passwd = ssl_config->primary.key_passwd;
+ #if MBEDTLS_VERSION_NUMBER >= 0x04000000
+ ret = mbedtls_pk_parse_key(&backend->pk, key_data, ssl_key_blob->len,
+ (const unsigned char *)passwd,
+@@ -881,7 +881,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf,
+ NULL);
+ #endif
+
+- if(ssl_config->key || ssl_config->key_blob) {
++ if(ssl_config->primary.key || ssl_config->primary.key_blob) {
+ mbedtls_ssl_conf_own_cert(&backend->config,
+ &backend->clicert, &backend->pk);
+ }
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 600a64ca6a..9168d27b78 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -3688,7 +3688,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+ struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
+ char * const ssl_cert = ssl_config->primary.clientcert;
+ const struct curl_blob *ssl_cert_blob = ssl_config->primary.cert_blob;
+- const char * const ssl_cert_type = ssl_config->cert_type;
++ const char * const ssl_cert_type = ssl_config->primary.cert_type;
+ unsigned int ssl_version_min;
+ char error_buffer[256];
+
+@@ -3857,8 +3857,9 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+ if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
+ result = client_cert(data, octx->ssl_ctx,
+ ssl_cert, ssl_cert_blob, ssl_cert_type,
+- ssl_config->key, ssl_config->key_blob,
+- ssl_config->key_type, ssl_config->key_passwd);
++ ssl_config->primary.key, ssl_config->primary.key_blob,
++ ssl_config->primary.key_type,
++ ssl_config->primary.key_passwd);
+ if(result)
+ /* failf() is already done in client_cert() */
+ return result;
+diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
+index fc380b062b..0401185145 100644
+--- a/lib/vtls/rustls.c
++++ b/lib/vtls/rustls.c
+@@ -840,14 +840,14 @@ init_config_builder_client_auth(struct Curl_easy *data,
+ const struct rustls_certified_key *certified_key = NULL;
+ CURLcode result = CURLE_OK;
+
+- if(conn_config->clientcert && !ssl_config->key) {
++ if(conn_config->clientcert && !ssl_config->primary.key) {
+ failf(data, "rustls: must provide key with certificate '%s'",
+ conn_config->clientcert);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+- else if(!conn_config->clientcert && ssl_config->key) {
++ else if(!conn_config->clientcert && ssl_config->primary.key) {
+ failf(data, "rustls: must provide certificate with key '%s'",
+- ssl_config->key);
++ ssl_config->primary.key);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
+@@ -861,8 +861,9 @@ init_config_builder_client_auth(struct Curl_easy *data,
+ goto cleanup;
+ }
+
+- if(!read_file_into(ssl_config->key, &key_contents)) {
+- failf(data, "rustls: failed to read key file: '%s'", ssl_config->key);
++ if(!read_file_into(ssl_config->primary.key, &key_contents)) {
++ failf(data, "rustls: failed to read key file: '%s'",
++ ssl_config->primary.key);
+ result = CURLE_SSL_CERTPROBLEM;
+ goto cleanup;
+ }
+@@ -1052,7 +1053,7 @@ static CURLcode cr_init_backend(struct Curl_cfilter *cf,
+ }
+ }
+
+- if(conn_config->clientcert || ssl_config->key) {
++ if(conn_config->clientcert || ssl_config->primary.key) {
+ result = init_config_builder_client_auth(data,
+ conn_config,
+ ssl_config,
+diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
+index 891dfc4e73..9989bcde9b 100644
+--- a/lib/vtls/schannel.c
++++ b/lib/vtls/schannel.c
+@@ -547,8 +547,8 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
+ }
+ }
+
+- if((fInCert || blob) && data->set.ssl.cert_type &&
+- !curl_strequal(data->set.ssl.cert_type, "P12")) {
++ if((fInCert || blob) && data->set.ssl.primary.cert_type &&
++ !curl_strequal(data->set.ssl.primary.cert_type, "P12")) {
+ failf(data, "schannel: certificate format compatibility error "
+ " for %s",
+ blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
+@@ -601,14 +601,14 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf,
+ datablob.pbData = (BYTE *)certdata;
+ datablob.cbData = (DWORD)certsize;
+
+- if(data->set.ssl.key_passwd)
+- pwd_len = strlen(data->set.ssl.key_passwd);
++ if(data->set.ssl.primary.key_passwd)
++ pwd_len = strlen(data->set.ssl.primary.key_passwd);
+ pszPassword = (WCHAR *)curlx_malloc(sizeof(WCHAR) * (pwd_len + 1));
+ if(pszPassword) {
+ if(pwd_len > 0)
+ str_w_len = MultiByteToWideChar(CP_UTF8,
+ MB_ERR_INVALID_CHARS,
+- data->set.ssl.key_passwd,
++ data->set.ssl.primary.key_passwd,
+ (int)pwd_len,
+ pszPassword, (int)(pwd_len + 1));
+
+diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
+index 851bc341a9..0bdab12f07 100644
+--- a/lib/vtls/vtls.c
++++ b/lib/vtls/vtls.c
+@@ -199,6 +199,7 @@ static bool match_ssl_primary_config(struct Curl_easy *data,
+ blobcmp(c1->cert_blob, c2->cert_blob) &&
+ blobcmp(c1->ca_info_blob, c2->ca_info_blob) &&
+ blobcmp(c1->issuercert_blob, c2->issuercert_blob) &&
++ blobcmp(c1->key_blob, c2->key_blob) &&
+ Curl_safecmp(c1->CApath, c2->CApath) &&
+ Curl_safecmp(c1->CAfile, c2->CAfile) &&
+ Curl_safecmp(c1->issuercert, c2->issuercert) &&
+@@ -212,7 +213,11 @@ static bool match_ssl_primary_config(struct Curl_easy *data,
+ curl_strequal(c1->curves, c2->curves) &&
+ curl_strequal(c1->signature_algorithms, c2->signature_algorithms) &&
+ curl_strequal(c1->CRLfile, c2->CRLfile) &&
+- curl_strequal(c1->pinned_key, c2->pinned_key))
++ curl_strequal(c1->pinned_key, c2->pinned_key) &&
++ curl_strequal(c1->cert_type, c2->cert_type) &&
++ Curl_safecmp(c1->key, c2->key) &&
++ curl_strequal(c1->key_type, c2->key_type) &&
++ !Curl_timestrcmp(c1->key_passwd, c2->key_passwd))
+ return TRUE;
+
+ return FALSE;
+@@ -247,6 +252,7 @@ static bool clone_ssl_primary_config(struct ssl_primary_config *source,
+ CLONE_BLOB(cert_blob);
+ CLONE_BLOB(ca_info_blob);
+ CLONE_BLOB(issuercert_blob);
++ CLONE_BLOB(key_blob);
+ CLONE_STRING(CApath);
+ CLONE_STRING(CAfile);
+ CLONE_STRING(issuercert);
+@@ -257,6 +263,10 @@ static bool clone_ssl_primary_config(struct ssl_primary_config *source,
+ CLONE_STRING(curves);
+ CLONE_STRING(signature_algorithms);
+ CLONE_STRING(CRLfile);
++ CLONE_STRING(cert_type);
++ CLONE_STRING(key);
++ CLONE_STRING(key_type);
++ CLONE_STRING(key_passwd);
+ #ifdef USE_TLS_SRP
+ CLONE_STRING(username);
+ CLONE_STRING(password);
+@@ -277,9 +287,14 @@ static void free_primary_ssl_config(struct ssl_primary_config *sslc)
+ Curl_safefree(sslc->cert_blob);
+ Curl_safefree(sslc->ca_info_blob);
+ Curl_safefree(sslc->issuercert_blob);
++ Curl_safefree(sslc->key_blob);
+ Curl_safefree(sslc->curves);
+ Curl_safefree(sslc->signature_algorithms);
+ Curl_safefree(sslc->CRLfile);
++ Curl_safefree(sslc->cert_type);
++ Curl_safefree(sslc->key);
++ Curl_safefree(sslc->key_type);
++ Curl_safefree(sslc->key_passwd);
+ #ifdef USE_TLS_SRP
+ Curl_safefree(sslc->username);
+ Curl_safefree(sslc->password);
+@@ -348,12 +363,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ sslc->primary.username = data->set.str[STRING_TLSAUTH_USERNAME];
+ sslc->primary.password = data->set.str[STRING_TLSAUTH_PASSWORD];
+ #endif
+- sslc->cert_type = data->set.str[STRING_CERT_TYPE];
+- sslc->key = data->set.str[STRING_KEY];
+- sslc->key_type = data->set.str[STRING_KEY_TYPE];
+- sslc->key_passwd = data->set.str[STRING_KEY_PASSWD];
++ sslc->primary.cert_type = data->set.str[STRING_CERT_TYPE];
++ sslc->primary.key = data->set.str[STRING_KEY];
++ sslc->primary.key_type = data->set.str[STRING_KEY_TYPE];
++ sslc->primary.key_passwd = data->set.str[STRING_KEY_PASSWD];
+ sslc->primary.clientcert = data->set.str[STRING_CERT];
+- sslc->key_blob = data->set.blobs[BLOB_KEY];
++ sslc->primary.key_blob = data->set.blobs[BLOB_KEY];
+
+ #ifndef CURL_DISABLE_PROXY
+ sslc = &data->set.proxy_ssl;
+@@ -391,12 +406,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ sslc->primary.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
+ sslc->primary.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY];
+ sslc->primary.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
+- sslc->cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
+- sslc->key = data->set.str[STRING_KEY_PROXY];
+- sslc->key_type = data->set.str[STRING_KEY_TYPE_PROXY];
+- sslc->key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
++ sslc->primary.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
++ sslc->primary.key = data->set.str[STRING_KEY_PROXY];
++ sslc->primary.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
++ sslc->primary.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
+ sslc->primary.clientcert = data->set.str[STRING_CERT_PROXY];
+- sslc->key_blob = data->set.blobs[BLOB_KEY_PROXY];
++ sslc->primary.key_blob = data->set.blobs[BLOB_KEY_PROXY];
+ #ifdef USE_TLS_SRP
+ sslc->primary.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
+ sslc->primary.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
+diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c
+index df04ec7e00..47bf655b71 100644
+--- a/lib/vtls/vtls_scache.c
++++ b/lib/vtls/vtls_scache.c
+@@ -52,6 +52,7 @@ static bool cf_ssl_peer_key_is_global(const char *peer_key);
+ struct Curl_ssl_scache_peer {
+ char *ssl_peer_key; /* id for peer + relevant TLS configuration */
+ char *clientcert;
++ char *key_passwd;
+ char *srp_username;
+ char *srp_password;
+ struct Curl_llist sessions;
+@@ -176,6 +177,7 @@ static void cf_ssl_scache_clear_peer(struct Curl_ssl_scache_peer *peer)
+ }
+ peer->sobj_free = NULL;
+ Curl_safefree(peer->clientcert);
++ Curl_safefree(peer->key_passwd);
+ #ifdef USE_TLS_SRP
+ Curl_safefree(peer->srp_username);
+ Curl_safefree(peer->srp_password);
+@@ -204,8 +206,8 @@ static void cf_ssl_cache_peer_update(struct Curl_ssl_scache_peer *peer)
+ * - its peer key is not yet known, because sessions were
+ * imported using only the salt+hmac
+ * - the peer key is global, e.g. carrying no relative paths */
+- peer->exportable = (!peer->clientcert && !peer->srp_username &&
+- !peer->srp_password &&
++ peer->exportable = (!peer->clientcert && !peer->key_passwd &&
++ !peer->srp_username && !peer->srp_password &&
+ (!peer->ssl_peer_key ||
+ cf_ssl_peer_key_is_global(peer->ssl_peer_key)));
+ }
+@@ -214,6 +216,7 @@ static CURLcode
+ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
+ const char *ssl_peer_key,
+ const char *clientcert,
++ const char *key_passwd,
+ const char *srp_username,
+ const char *srp_password,
+ const unsigned char *salt,
+@@ -242,6 +245,11 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
+ if(!peer->clientcert)
+ goto out;
+ }
++ if(key_passwd) {
++ peer->key_passwd = curlx_strdup(key_passwd);
++ if(!peer->key_passwd)
++ goto out;
++ }
+ if(srp_username) {
+ peer->srp_username = curlx_strdup(srp_username);
+ if(!peer->srp_username)
+@@ -425,6 +433,48 @@ out:
+ return r;
+ }
+
++static CURLcode cf_ssl_peer_key_add_mtls(struct dynbuf *buf,
++ struct ssl_primary_config *ssl,
++ bool *is_local)
++{
++ CURLcode r = CURLE_OK;
++ if(ssl->clientcert && ssl->clientcert[0]) {
++ r = cf_ssl_peer_key_add_path(buf, "CCERT", ssl->clientcert, is_local);
++ if(r)
++ goto out;
++ }
++ if(ssl->key && ssl->key[0]) {
++ r = cf_ssl_peer_key_add_path(buf, "KEY", ssl->key, is_local);
++ if(r)
++ goto out;
++ }
++ if(ssl->key_blob) {
++ r = cf_ssl_peer_key_add_hash(buf, "KEYBlob", ssl->key_blob);
++ if(r)
++ goto out;
++ }
++ if(ssl->cert_type && ssl->cert_type[0]) {
++ size_t i;
++ r = curlx_dyn_add(buf, ":CT-");
++ for(i = 0; !r && ssl->cert_type[i]; i++) {
++ char c = Curl_raw_toupper(ssl->cert_type[i]);
++ r = curlx_dyn_addn(buf, &c, 1);
++ }
++ if(r)
++ goto out;
++ }
++ if(ssl->key_type && ssl->key_type[0]) {
++ size_t i;
++ r = curlx_dyn_add(buf, ":KT-");
++ for(i = 0; !r && ssl->key_type[i]; i++) {
++ char c = Curl_raw_toupper(ssl->key_type[i]);
++ r = curlx_dyn_addn(buf, &c, 1);
++ }
++ }
++out:
++ return r;
++}
++
+ #define CURL_SSLS_LOCAL_SUFFIX ":L"
+ #define CURL_SSLS_GLOBAL_SUFFIX ":G"
+
+@@ -436,6 +486,152 @@ static bool cf_ssl_peer_key_is_global(const char *peer_key)
+ (peer_key[len - 2] == ':');
+ }
+
++CURLcode Curl_ssl_peer_key_build(struct ssl_primary_config *ssl,
++ const struct ssl_peer *peer,
++ const char *tls_id,
++ char **ppeer_key)
++{
++ struct dynbuf buf;
++ size_t key_len;
++ bool is_local = FALSE;
++ CURLcode r;
++
++ *ppeer_key = NULL;
++ curlx_dyn_init(&buf, 10 * 1024);
++
++ r = curlx_dyn_addf(&buf, "%s:%d", peer->hostname, peer->port);
++ if(r)
++ goto out;
++
++ switch(peer->transport) {
++ case TRNSPRT_TCP:
++ break;
++ case TRNSPRT_UDP:
++ r = curlx_dyn_add(&buf, ":UDP");
++ break;
++ case TRNSPRT_QUIC:
++ r = curlx_dyn_add(&buf, ":QUIC");
++ break;
++ case TRNSPRT_UNIX:
++ r = curlx_dyn_add(&buf, ":UNIX");
++ break;
++ default:
++ r = curlx_dyn_addf(&buf, ":TRNSPRT-%d", peer->transport);
++ break;
++ }
++ if(r)
++ goto out;
++
++ if(!ssl->verifypeer) {
++ r = curlx_dyn_add(&buf, ":NO-VRFY-PEER");
++ if(r)
++ goto out;
++ }
++ if(!ssl->verifyhost) {
++ r = curlx_dyn_add(&buf, ":NO-VRFY-HOST");
++ if(r)
++ goto out;
++ }
++ if(ssl->verifystatus) {
++ r = curlx_dyn_add(&buf, ":VRFY-STATUS");
++ if(r)
++ goto out;
++ }
++
++ if(ssl->version || ssl->version_max) {
++ r = curlx_dyn_addf(&buf, ":TLSVER-%d-%d", ssl->version,
++ (ssl->version_max >> 16));
++ if(r)
++ goto out;
++ }
++ if(ssl->ssl_options) {
++ r = curlx_dyn_addf(&buf, ":TLSOPT-%x", ssl->ssl_options);
++ if(r)
++ goto out;
++ }
++ if(ssl->cipher_list) {
++ r = curlx_dyn_addf(&buf, ":CIPHER-%s", ssl->cipher_list);
++ if(r)
++ goto out;
++ }
++ if(ssl->cipher_list13) {
++ r = curlx_dyn_addf(&buf, ":CIPHER13-%s", ssl->cipher_list13);
++ if(r)
++ goto out;
++ }
++ if(ssl->curves) {
++ r = curlx_dyn_addf(&buf, ":CURVES-%s", ssl->curves);
++ if(r)
++ goto out;
++ }
++ if(ssl->verifypeer) {
++ r = cf_ssl_peer_key_add_path(&buf, "CA", ssl->CAfile, &is_local);
++ if(r)
++ goto out;
++ r = cf_ssl_peer_key_add_path(&buf, "CApath", ssl->CApath, &is_local);
++ if(r)
++ goto out;
++ r = cf_ssl_peer_key_add_path(&buf, "CRL", ssl->CRLfile, &is_local);
++ if(r)
++ goto out;
++ r = cf_ssl_peer_key_add_path(&buf, "Issuer", ssl->issuercert, &is_local);
++ if(r)
++ goto out;
++ if(ssl->cert_blob) {
++ r = cf_ssl_peer_key_add_hash(&buf, "CertBlob", ssl->cert_blob);
++ if(r)
++ goto out;
++ }
++ if(ssl->ca_info_blob) {
++ r = cf_ssl_peer_key_add_hash(&buf, "CAInfoBlob", ssl->ca_info_blob);
++ if(r)
++ goto out;
++ }
++ if(ssl->issuercert_blob) {
++ r = cf_ssl_peer_key_add_hash(&buf, "IssuerBlob", ssl->issuercert_blob);
++ if(r)
++ goto out;
++ }
++ }
++ if(ssl->pinned_key && ssl->pinned_key[0]) {
++ r = curlx_dyn_addf(&buf, ":Pinned-%s", ssl->pinned_key);
++ if(r)
++ goto out;
++ }
++
++ r = cf_ssl_peer_key_add_mtls(&buf, ssl, &is_local);
++ if(r)
++ goto out;
++#ifdef USE_TLS_SRP
++ if(ssl->username || ssl->password) {
++ r = curlx_dyn_add(&buf, ":SRP-AUTH");
++ if(r)
++ goto out;
++ }
++#endif
++
++ if(!tls_id || !tls_id[0]) {
++ r = CURLE_FAILED_INIT;
++ goto out;
++ }
++ r = curlx_dyn_addf(&buf, ":IMPL-%s", tls_id);
++ if(r)
++ goto out;
++
++ r = curlx_dyn_addf(&buf, is_local ?
++ CURL_SSLS_LOCAL_SUFFIX : CURL_SSLS_GLOBAL_SUFFIX);
++ if(r)
++ goto out;
++
++ *ppeer_key = curlx_dyn_take(&buf, &key_len);
++ /* we just added printable char, and dynbuf always null-terminates, no need
++ * to track length */
++
++out:
++ curlx_dyn_free(&buf);
++ return r;
++}
++
+ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
+ const struct ssl_peer *peer,
+ const char *tls_id,
+@@ -562,11 +758,9 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
+ goto out;
+ }
+
+- if(ssl->clientcert && ssl->clientcert[0]) {
+- r = curlx_dyn_add(&buf, ":CCERT");
+- if(r)
+- goto out;
+- }
++ r = cf_ssl_peer_key_add_mtls(&buf, ssl, &is_local);
++ if(r)
++ goto out;
+ #ifdef USE_TLS_SRP
+ if(ssl->username || ssl->password) {
+ r = curlx_dyn_add(&buf, ":SRP-AUTH");
+@@ -601,7 +795,7 @@ static bool cf_ssl_scache_match_auth(struct Curl_ssl_scache_peer *peer,
+ struct ssl_primary_config *conn_config)
+ {
+ if(!conn_config) {
+- if(peer->clientcert)
++ if(peer->clientcert || peer->key_passwd)
+ return FALSE;
+ #ifdef USE_TLS_SRP
+ if(peer->srp_username || peer->srp_password)
+@@ -611,6 +805,8 @@ static bool cf_ssl_scache_match_auth(struct Curl_ssl_scache_peer *peer,
+ }
+ else if(!Curl_safecmp(peer->clientcert, conn_config->clientcert))
+ return FALSE;
++ if(Curl_timestrcmp(peer->key_passwd, conn_config->key_passwd))
++ return FALSE;
+ #ifdef USE_TLS_SRP
+ if(Curl_timestrcmp(peer->srp_username, conn_config->username) ||
+ Curl_timestrcmp(peer->srp_password, conn_config->password))
+@@ -738,12 +934,13 @@ static CURLcode cf_ssl_add_peer(struct Curl_easy *data,
+ peer = cf_ssl_get_free_peer(scache);
+ if(peer) {
+ const char *ccert = conn_config ? conn_config->clientcert : NULL;
++ const char *kpasswd = conn_config ? conn_config->key_passwd : NULL;
+ const char *username = NULL, *password = NULL;
+ #ifdef USE_TLS_SRP
+ username = conn_config ? conn_config->username : NULL;
+ password = conn_config ? conn_config->password : NULL;
+ #endif
+- result = cf_ssl_scache_peer_init(peer, ssl_peer_key, ccert,
++ result = cf_ssl_scache_peer_init(peer, ssl_peer_key, ccert, kpasswd,
+ username, password, NULL, NULL);
+ if(result)
+ goto out;
+@@ -1118,7 +1315,7 @@ CURLcode Curl_ssl_session_import(struct Curl_easy *data,
+ if(!peer) {
+ peer = cf_ssl_get_free_peer(scache);
+ if(peer) {
+- r = cf_ssl_scache_peer_init(peer, ssl_peer_key, NULL,
++ r = cf_ssl_scache_peer_init(peer, ssl_peer_key, NULL, NULL,
+ NULL, NULL, salt, hmac);
+ if(r)
+ goto out;
+diff --git a/lib/vtls/vtls_scache.h b/lib/vtls/vtls_scache.h
+index 2a99e779e5..e84b6e799a 100644
+--- a/lib/vtls/vtls_scache.h
++++ b/lib/vtls/vtls_scache.h
+@@ -66,6 +66,20 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf,
+ const char *tls_id,
+ char **ppeer_key);
+
++/**
++ * Like Curl_ssl_peer_key_make() but takes the primary config and peer
++ * descriptors directly, without requiring a Curl_cfilter. Exposed for
++ * unit testing.
++ * @param ssl the primary SSL config to key on
++ * @param peer the peer the filter wants to talk to
++ * @param tls_id identifier of TLS implementation for sessions
++ * @param ppeer_key on successful return, the key generated
++ */
++CURLcode Curl_ssl_peer_key_build(struct ssl_primary_config *ssl,
++ const struct ssl_peer *peer,
++ const char *tls_id,
++ char **ppeer_key);
++
+ /* Return if there is a session cache shall be used.
+ * An ssl session might not be configured or not available for
+ * "connect-only" transfers.
+diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c
+index 510378886d..6f3c5b2697 100644
+--- a/lib/vtls/wolfssl.c
++++ b/lib/vtls/wolfssl.c
+@@ -937,10 +937,10 @@ static CURLcode client_certificate(struct Curl_easy *data,
+ #ifndef NO_FILESYSTEM
+ if(ssl_config->primary.cert_blob || ssl_config->primary.clientcert) {
+ const char *cert_file = ssl_config->primary.clientcert;
+- const char *key_file = ssl_config->key;
++ const char *key_file = ssl_config->primary.key;
+ const struct curl_blob *cert_blob = ssl_config->primary.cert_blob;
+- const struct curl_blob *key_blob = ssl_config->key_blob;
+- int file_type = wssl_do_file_type(ssl_config->cert_type);
++ const struct curl_blob *key_blob = ssl_config->primary.key_blob;
++ int file_type = wssl_do_file_type(ssl_config->primary.cert_type);
+ int rc;
+
+ switch(file_type) {
+@@ -971,7 +971,7 @@ static CURLcode client_certificate(struct Curl_easy *data,
+ key_file = cert_file;
+ }
+ else
+- file_type = wssl_do_file_type(ssl_config->key_type);
++ file_type = wssl_do_file_type(ssl_config->primary.key_type);
+
+ rc = key_blob ?
+ wolfSSL_CTX_use_PrivateKey_buffer(wctx->ssl_ctx, key_blob->data,
+@@ -985,8 +985,8 @@ static CURLcode client_certificate(struct Curl_easy *data,
+ #else /* NO_FILESYSTEM */
+ if(ssl_config->primary.cert_blob) {
+ const struct curl_blob *cert_blob = ssl_config->primary.cert_blob;
+- const struct curl_blob *key_blob = ssl_config->key_blob;
+- int file_type = wssl_do_file_type(ssl_config->cert_type);
++ const struct curl_blob *key_blob = ssl_config->primary.key_blob;
++ int file_type = wssl_do_file_type(ssl_config->primary.cert_type);
+ int rc;
+
+ switch(file_type) {
+@@ -1011,7 +1011,7 @@ static CURLcode client_certificate(struct Curl_easy *data,
+ if(!key_blob)
+ key_blob = cert_blob;
+ else
+- file_type = wssl_do_file_type(ssl_config->key_type);
++ file_type = wssl_do_file_type(ssl_config->primary.key_type);
+
+ if(wolfSSL_CTX_use_PrivateKey_buffer(wctx->ssl_ctx, key_blob->data,
+ (long)key_blob->len,
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 8b448cfcca..7b7dcf0e93 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -284,6 +284,8 @@ test3032 test3033 test3034 test3035 \
+ \
+ test3100 test3101 test3102 test3103 test3104 test3105 \
+ \
++test3303 test3304 \
++\
+ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 \
+ test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \
+ test4000 test4001
+diff --git a/tests/data/test3303 b/tests/data/test3303
+new file mode 100644
+index 0000000000..697049f013
+--- /dev/null
++++ b/tests/data/test3303
+@@ -0,0 +1,20 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++unittest
++TLS
++mTLS
++</keywords>
++</info>
++
++# Client-side
++<client>
++<features>
++unittest
++</features>
++<name>
++conn-reuse match distinguishes mTLS key, cert_type, key_type and key_passwd fields
++</name>
++</client>
++</testcase>
+diff --git a/tests/data/test3304 b/tests/data/test3304
+new file mode 100644
+index 0000000000..4380c0819f
+--- /dev/null
++++ b/tests/data/test3304
+@@ -0,0 +1,20 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++unittest
++TLS
++mTLS
++</keywords>
++</info>
++
++# Client-side
++<client>
++<features>
++unittest
++</features>
++<name>
++TLS session cache peer key discriminates on mTLS key, key_type and cert_type fields
++</name>
++</client>
++</testcase>
+diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc
+index 149636cbcc..bba30f6706 100644
+--- a/tests/unit/Makefile.inc
++++ b/tests/unit/Makefile.inc
+@@ -43,4 +43,5 @@ TESTS_C = \
+ unit1979.c unit1980.c \
+ unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c unit2605.c \
+ unit3200.c unit3205.c \
+- unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c
++ unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c \
++ unit3303.c unit3304.c
+diff --git a/tests/unit/unit3303.c b/tests/unit/unit3303.c
+new file mode 100644
+index 0000000000..41bced542d
+--- /dev/null
++++ b/tests/unit/unit3303.c
+@@ -0,0 +1,127 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++#include "unitcheck.h"
++#include "urldata.h"
++
++#ifdef USE_SSL
++#include "vtls/vtls.h"
++#endif
++
++static CURLcode test_unit3303(const char *arg)
++{
++ UNITTEST_BEGIN_SIMPLE
++
++#ifdef USE_SSL
++ {
++ CURL *curl;
++ struct connectdata *conn;
++ struct ssl_primary_config *primary;
++ char *saved;
++ static char alt_passwd[] = "wrong";
++ static char alt_key[] = "other.key";
++ static char alt_ktype[] = "DER";
++ static char alt_ctype[] = "P12";
++
++ curl_global_init(CURL_GLOBAL_ALL);
++ curl = curl_easy_init();
++ if(!curl) {
++ curl_global_cleanup();
++ goto unit_test_abort;
++ }
++
++ curl_easy_setopt(curl, CURLOPT_SSLCERT, "client.pem");
++ curl_easy_setopt(curl, CURLOPT_SSLKEY, "client.key");
++ curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "secret");
++ curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
++ curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
++
++ if(Curl_ssl_easy_config_complete((struct Curl_easy *)curl)) {
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ goto unit_test_abort;
++ }
++
++ conn = curlx_calloc(1, sizeof(*conn));
++ if(!conn || Curl_ssl_conn_config_init((struct Curl_easy *)curl, conn)) {
++ if(conn)
++ Curl_ssl_conn_config_cleanup(conn);
++ curlx_free(conn);
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ goto unit_test_abort;
++ }
++
++ /* Baseline: identical config must match. */
++ fail_unless(Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "identical mTLS config should match");
++
++ primary = &((struct Curl_easy *)curl)->set.ssl.primary;
++
++ /* Different key_passwd must not match. */
++ saved = primary->key_passwd;
++ primary->key_passwd = alt_passwd;
++ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "different key_passwd must not reuse conn");
++ primary->key_passwd = saved;
++
++ /* Different key path must not match. */
++ saved = primary->key;
++ primary->key = alt_key;
++ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "different key must not reuse conn");
++ primary->key = saved;
++
++ /* Different key type must not match. */
++ saved = primary->key_type;
++ primary->key_type = alt_ktype;
++ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "different key_type must not reuse conn");
++ primary->key_type = saved;
++
++ /* Different cert type must not match. */
++ saved = primary->cert_type;
++ primary->cert_type = alt_ctype;
++ fail_unless(!Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "different cert_type must not reuse conn");
++ primary->cert_type = saved;
++
++ /* All fields restored: must match again. */
++ fail_unless(Curl_ssl_conn_config_match((struct Curl_easy *)curl, conn,
++ FALSE),
++ "restored mTLS config should match");
++
++ Curl_ssl_conn_config_cleanup(conn);
++ curlx_free(conn);
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ }
++#endif /* USE_SSL */
++
++ UNITTEST_END_SIMPLE
++}
+diff --git a/tests/unit/unit3304.c b/tests/unit/unit3304.c
+new file mode 100644
+index 0000000000..f99a211507
+--- /dev/null
++++ b/tests/unit/unit3304.c
+@@ -0,0 +1,163 @@
++/***************************************************************************
++ * _ _ ____ _
++ * Project ___| | | | _ \| |
++ * / __| | | | |_) | |
++ * | (__| |_| | _ <| |___
++ * \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++
++/* Unit tests for TLS session cache peer key discrimination on mTLS fields.
++ * Verifies that Curl_ssl_peer_key_build() produces distinct keys when two
++ * handles differ only on key, key_type or cert_type. key_passwd is NOT
++ * embedded in the peer key; it is compared separately at session lookup via
++ * cf_ssl_scache_match_auth(), following the same pattern as SRP
++ * credentials. */
++
++#include "unitcheck.h"
++#include "urldata.h"
++
++#ifdef USE_SSL
++#include "vtls/vtls.h"
++#include "vtls/vtls_scache.h"
++#endif
++
++static CURLcode test_unit3304(const char *arg)
++{
++ UNITTEST_BEGIN_SIMPLE
++
++#ifdef USE_SSL
++ {
++ struct ssl_peer peer;
++ struct ssl_primary_config ssl;
++ char *key1 = NULL;
++ char *key2 = NULL;
++ static char base_hostname[] = "example.com";
++ static char base_cert[] = "client.pem";
++ static char base_key[] = "client.key";
++ static char base_passwd[] = "secret";
++ static char base_ctype[] = "PEM";
++ static char base_ktype[] = "PEM";
++ static char alt_key[] = "other.key";
++ static char alt_ktype[] = "DER";
++ static char alt_ctype[] = "P12";
++ static char lc_ctype[] = "pem";
++ static char lc_ktype[] = "pem";
++
++ memset(&peer, 0, sizeof(peer));
++ peer.hostname = base_hostname;
++ peer.port = 443;
++ peer.transport = TRNSPRT_TCP;
++
++ memset(&ssl, 0, sizeof(ssl));
++ ssl.verifypeer = TRUE;
++ ssl.verifyhost = TRUE;
++ ssl.clientcert = base_cert;
++ ssl.key = base_key;
++ ssl.key_passwd = base_passwd;
++ ssl.cert_type = base_ctype;
++ ssl.key_type = base_ktype;
++
++ /* Baseline: same config produces same key. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && !strcmp(key1, key2),
++ "identical config should produce identical peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++
++ /* key_passwd is NOT in the peer key: lookup uses timing-safe comparison
++ * via cf_ssl_scache_match_auth(), same as SRP credentials. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.key_passwd = NULL;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && !strcmp(key1, key2),
++ "key_passwd must not affect the peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ ssl.key_passwd = base_passwd;
++
++ /* Different key path must produce a different peer key. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.key = alt_key;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && strcmp(key1, key2),
++ "different key must produce different peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ ssl.key = base_key;
++
++ /* Different key_type must produce a different peer key. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.key_type = alt_ktype;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && strcmp(key1, key2),
++ "different key_type must produce different peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ ssl.key_type = base_ktype;
++
++ /* Different cert_type must produce a different peer key. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.cert_type = alt_ctype;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && strcmp(key1, key2),
++ "different cert_type must produce different peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ ssl.cert_type = base_ctype;
++
++ /* cert_type is case-insensitive: "PEM" and "pem" must produce the
++ * same peer key, consistent with the conn-reuse comparison. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.cert_type = lc_ctype;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && !strcmp(key1, key2),
++ "cert_type case must not affect peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ ssl.cert_type = base_ctype;
++
++ /* key_type is case-insensitive: "PEM" and "pem" must produce the
++ * same peer key. */
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key1),
++ "peer key build failed");
++ ssl.key_type = lc_ktype;
++ fail_unless(!Curl_ssl_peer_key_build(&ssl, &peer, "test", &key2),
++ "peer key build failed");
++ fail_unless(key1 && key2 && !strcmp(key1, key2),
++ "key_type case must not affect peer key");
++ curlx_free(key1); key1 = NULL;
++ curlx_free(key2); key2 = NULL;
++ }
++#endif /* USE_SSL */
++
++ UNITTEST_END_SIMPLE
++}
diff --git a/0032-curl-8.18.0-CVE-2026-80230.patch b/0032-curl-8.18.0-CVE-2026-80230.patch
deleted file mode 100644
index 8c697db..0000000
--- a/0032-curl-8.18.0-CVE-2026-80230.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From d17047ae08b3467513f4eaba90a5d3348f74ef48 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 24 Aug 2026 23:37:49 +0200
-Subject: [PATCH 3/3] openssl: no server cert is only okay if also not pinned
-
-Reported-by: Stanislav Fort
-Closes #22660
-
-(cherry picked from commit 5267ed859d545534d0c21675a2b70af5a3b6e3ef)
----
- lib/vtls/openssl.c | 26 +++++++++++++++-----------
- 1 file changed, 15 insertions(+), 11 deletions(-)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 9168d27b78..edcb661440 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4578,21 +4578,24 @@ out:
- return result;
- }
-
--static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
-- struct Curl_easy *data,
-- X509 *server_cert)
-+static const char *pinned(struct Curl_cfilter *cf,
-+ struct Curl_easy *data)
- {
-- const char *ptr;
-- CURLcode result = CURLE_OK;
--
- (void)cf;
-+ return
- #ifndef CURL_DISABLE_PROXY
-- ptr = Curl_ssl_cf_is_proxy(cf) ?
-+ Curl_ssl_cf_is_proxy(cf) ?
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
-- data->set.str[STRING_SSL_PINNEDPUBLICKEY];
--#else
-- ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY];
- #endif
-+ data->set.str[STRING_SSL_PINNEDPUBLICKEY];
-+}
-+
-+static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
-+ struct Curl_easy *data,
-+ X509 *server_cert)
-+{
-+ CURLcode result = CURLE_OK;
-+ const char *ptr = pinned(cf, data);
- if(ptr) {
- result = ossl_pkp_pin_peer_pubkey(data, server_cert, ptr);
- if(result)
-@@ -4767,7 +4770,8 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
- server_cert = SSL_get1_peer_certificate(octx->ssl);
- if(!server_cert) {
- /* no verification at all, this maybe acceptable */
-- if(!(conn_config->verifypeer || conn_config->verifyhost))
-+ if(!(conn_config->verifypeer || conn_config->verifyhost) &&
-+ !pinned(cf, data))
- goto out;
-
- failf(data, "SSL: could not get peer certificate");
---
-2.56.0
-
diff --git a/0032-openldap-handle-Curl_sasl_continue-returns-better.patch b/0032-openldap-handle-Curl_sasl_continue-returns-better.patch
new file mode 100644
index 0000000..16d3503
--- /dev/null
+++ b/0032-openldap-handle-Curl_sasl_continue-returns-better.patch
@@ -0,0 +1,43 @@
+From 80aa21b167a3cba2dd5ee4b9090df009ae188d36 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 29 Jun 2026 10:44:47 +0200
+Subject: [PATCH] openldap: handle Curl_sasl_continue() returns better
+
+Similar to how it gets treated already in other protocol handlers.
+
+Follow-up to eeca818b1e8d1e61c2d4
+
+Reported-by: Eunsoo Kim
+Closes #22213
+
+(cherry picked from commit ea71c3b6b60e563651ea8596a975aef0c8199519)
+---
+ lib/openldap.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/lib/openldap.c b/lib/openldap.c
+index f826a4d006..400c4b00c0 100644
+--- a/lib/openldap.c
++++ b/lib/openldap.c
+@@ -781,8 +781,19 @@ static CURLcode oldap_state_sasl_resp(struct Curl_easy *data,
+ }
+ else {
+ result = Curl_sasl_continue(&li->sasl, data, code, &progress);
+- if(!result && progress != SASL_INPROGRESS)
+- oldap_state(data, li, OLDAP_STOP);
++ if(!result) {
++ switch(progress) {
++ case SASL_DONE:
++ oldap_state(data, li, OLDAP_STOP); /* Authenticated */
++ break;
++ case SASL_IDLE: /* No mechanism left after cancellation */
++ failf(data, "Authentication cancelled");
++ result = CURLE_LOGIN_DENIED;
++ break;
++ default:
++ break;
++ }
++ }
+ }
+
+ if(li->servercred)
diff --git a/0033-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch b/0033-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
new file mode 100644
index 0000000..d7cea37
--- /dev/null
+++ b/0033-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
@@ -0,0 +1,62 @@
+From eddd0a8d29cbbb57bd2539a0aca5ff9d9fcda9fb Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 24 Aug 2026 23:37:49 +0200
+Subject: [PATCH] openssl: no server cert is only okay if also not pinned
+
+Reported-by: Stanislav Fort
+Closes #22660
+
+(cherry picked from commit 5267ed859d545534d0c21675a2b70af5a3b6e3ef)
+---
+ lib/vtls/openssl.c | 26 +++++++++++++++-----------
+ 1 file changed, 15 insertions(+), 11 deletions(-)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 9168d27b78..edcb661440 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4578,21 +4578,24 @@ out:
+ return result;
+ }
+
+-static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
+- struct Curl_easy *data,
+- X509 *server_cert)
++static const char *pinned(struct Curl_cfilter *cf,
++ struct Curl_easy *data)
+ {
+- const char *ptr;
+- CURLcode result = CURLE_OK;
+-
+ (void)cf;
++ return
+ #ifndef CURL_DISABLE_PROXY
+- ptr = Curl_ssl_cf_is_proxy(cf) ?
++ Curl_ssl_cf_is_proxy(cf) ?
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
+- data->set.str[STRING_SSL_PINNEDPUBLICKEY];
+-#else
+- ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY];
+ #endif
++ data->set.str[STRING_SSL_PINNEDPUBLICKEY];
++}
++
++static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
++ struct Curl_easy *data,
++ X509 *server_cert)
++{
++ CURLcode result = CURLE_OK;
++ const char *ptr = pinned(cf, data);
+ if(ptr) {
+ result = ossl_pkp_pin_peer_pubkey(data, server_cert, ptr);
+ if(result)
+@@ -4767,7 +4770,8 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
+ server_cert = SSL_get1_peer_certificate(octx->ssl);
+ if(!server_cert) {
+ /* no verification at all, this maybe acceptable */
+- if(!(conn_config->verifypeer || conn_config->verifyhost))
++ if(!(conn_config->verifypeer || conn_config->verifyhost) &&
++ !pinned(cf, data))
+ goto out;
+
+ failf(data, "SSL: could not get peer certificate");
diff --git a/0034-ci-setup-packit.patch b/0034-ci-setup-packit.patch
new file mode 100644
index 0000000..c0409d9
--- /dev/null
+++ b/0034-ci-setup-packit.patch
@@ -0,0 +1,59 @@
+From 3ef2735caac031b84c66fbaf2549e9d87e488423 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Wed, 21 Oct 2026 09:53:07 +0200
+Subject: [PATCH] ci: setup packit
+
+inspired by systemd's .packit.yml
+
+fedora-only
+---
+ .packit.yml | 40 ++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 40 insertions(+)
+ create mode 100644 .packit.yml
+
+diff --git a/.packit.yml b/.packit.yml
+new file mode 100644
+index 0000000000..8faaa57d49
+--- /dev/null
++++ b/.packit.yml
+@@ -0,0 +1,40 @@
++specfile_path: .packit_rpm/curl.spec
++files_to_sync:
++ - .packit.yml
++ - src: .packit_rpm/curl.spec
++ dest: curl.spec
++upstream_package_name: curl
++downstream_package_name: curl
++upstream_tag_template: curl-{version}
++srpm_build_deps: []
++
++actions:
++ get-current-version:
++ # Show the closest matching tag for the checked out revision, otherwise
++ # Packit tries to get the latest tag by creation date, which doesn't work well.
++ - "bash -ec 'git describe --tags --abbrev=0 | cut -d- -f1'"
++
++ post-upstream-clone:
++ # Use the Fedora specfile
++ - "git clone -b f44 https://src.fedoraproject.org/rpms/curl.git .packit_rpm --depth=1"
++ # Drop the "sources" file so rebase-helper doesn't think we're a dist-git
++ - "rm -fv .packit_rpm/sources"
++ # Drop all patches, since they're already included in the tarball
++ - "sed -ri '/^Patch[0-9]+:/d' .packit_rpm/curl.spec"
++ # Replace dynamic %(pkg-config ...) version macros with 0 — the
++ # specfile library's rpm.spec() call cannot evaluate %(...) shell
++ # expansions, causing Requires lines to end with bare '>='
++ - "sed -ri 's/^(%global \\S+_version )\\%\\(.*/\\1 0/' .packit_rpm/curl.spec"
++ # Drop GPG signature verification — packit generates its own tarball
++ # from git, so it will never match the upstream-signed archive
++ - "sed -ri '/gpgverify/d' .packit_rpm/curl.spec"
++
++# Available targets can be listed via `copr-cli list-chroots`
++jobs:
++- job: copr_build
++ trigger: pull_request
++ targets:
++ - fedora-f44-aarch64
++ - fedora-f44-ppc64le
++ - fedora-f44-s390x
++ - fedora-f44-x86_64
diff --git a/0035-multi-adjust-the-cleanup-order-in-multi_done.patch b/0035-multi-adjust-the-cleanup-order-in-multi_done.patch
new file mode 100644
index 0000000..adad4dd
--- /dev/null
+++ b/0035-multi-adjust-the-cleanup-order-in-multi_done.patch
@@ -0,0 +1,47 @@
+From 6a1c02c67cb102f4e31470768449ebbd38cd0fe4 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 12 Oct 2026 07:40:45 +0200
+Subject: [PATCH] multi: adjust the cleanup order in multi_done
+
+Closes #23370
+
+(cherry picked from commit 8b0744af5b1b631da5b938ca31c3f9895ad5a321)
+
+Resolves: CVE-2026-92392
+
+Assisted-by: Cursor <cursoragent@cursor.com>
+---
+ lib/multi.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/lib/multi.c b/lib/multi.c
+index 7691c92629..c17ff26256 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -712,19 +712,21 @@ static CURLcode multi_done(struct Curl_easy *data,
+ /* Make sure that transfer client writes are really done now. */
+ result = Curl_1st_err(result, Curl_xfer_write_done(data, premature));
+
+- /* Inform connection filters that this transfer is done */
+- Curl_conn_ev_data_done(data, premature);
+-
+- process_pending_handles(data->multi); /* connection / multiplex */
+-
+ if(!result)
+ result = Curl_req_done(&data->req, data, premature);
+
++ /* Inform connection filters that this transfer is done and they
++ * need to give up any references to `data`. */
++ Curl_conn_ev_data_done(data, premature);
++
+ /* Under the potential connection pool's share lock, decide what to
+ * do with the transfer's connection. */
+ mdctx.premature = premature;
+ Curl_cpool_do_locked(data, data->conn, multi_done_locked, &mdctx);
+
++ if(data->multi)
++ process_pending_handles(data->multi); /* connection / multiplex */
++
+ /* flush the netrc cache */
+ Curl_netrc_cleanup(&data->state.netrc);
+ return result;
diff --git a/0101-curl-7.32.0-multilib.patch b/0101-curl-7.32.0-multilib.patch
deleted file mode 100644
index f7f66e6..0000000
--- a/0101-curl-7.32.0-multilib.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 6bb4e674cdc953f5c0048aa84172539900725166 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Tue, 16 Dec 2025 10:04:40 +0100
-Subject: [PATCH] prevent multilib conflicts on the curl-config script
-
----
- curl-config.in | 23 +++++------------------
- docs/curl-config.md | 4 +++-
- libcurl.pc.in | 1 +
- 3 files changed, 9 insertions(+), 19 deletions(-)
-
-diff --git a/curl-config.in b/curl-config.in
-index a1c8185875..bb43ca8335 100644
---- a/curl-config.in
-+++ b/curl-config.in
-@@ -74,7 +74,7 @@ while test "$#" -gt 0; do
- ;;
-
- --cc)
-- echo '@CC@'
-+ echo 'gcc'
- ;;
-
- --prefix)
-@@ -149,16 +149,7 @@ while test "$#" -gt 0; do
- ;;
-
- --libs)
-- if test "@libdir@" != '/usr/lib' && test "@libdir@" != '/usr/lib64'; then
-- curllibdir="-L@libdir@ "
-- else
-- curllibdir=''
-- fi
-- if test '@ENABLE_SHARED@' = 'no'; then
-- echo "${curllibdir}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
-- else
-- echo "${curllibdir}-lcurl"
-- fi
-+ echo '-lcurl'
- ;;
-
- --ssl-backends)
-@@ -166,16 +157,12 @@ while test "$#" -gt 0; do
- ;;
-
- --static-libs)
-- if test '@ENABLE_STATIC@' != 'no'; then
-- echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
-- else
-- echo 'curl was built with static libraries disabled' >&2
-- exit 1
-- fi
-+ echo 'curl was built with static libraries disabled' >&2
-+ exit 1
- ;;
-
- --configure)
-- echo @CONFIGURE_OPTIONS@
-+ pkg-config libcurl --variable=configure_options | sed 's/^"//;s/"$//'
- ;;
-
- *)
-diff --git a/docs/curl-config.md b/docs/curl-config.md
-index 12ad245b79..fa0e03d273 100644
---- a/docs/curl-config.md
-+++ b/docs/curl-config.md
-@@ -87,7 +87,9 @@ no, one or several names. If more than one name, they appear comma-separated.
- ## `--static-libs`
-
- Shows the complete set of libs and other linker options you need in order to
--link your application with libcurl statically. (Added in 7.17.1)
-+link your application with libcurl statically. Note that Fedora/RHEL libcurl
-+packages do not provide any static libraries, thus cannot be linked statically.
-+(Added in 7.17.1)
-
- ## `--version`
-
-diff --git a/libcurl.pc.in b/libcurl.pc.in
-index c0ba5244a8..f3645e1748 100644
---- a/libcurl.pc.in
-+++ b/libcurl.pc.in
-@@ -28,6 +28,7 @@ libdir=@libdir@
- includedir=@includedir@
- supported_protocols="@SUPPORT_PROTOCOLS@"
- supported_features="@SUPPORT_FEATURES@"
-+configure_options=@CONFIGURE_OPTIONS@
-
- Name: libcurl
- URL: https://curl.se/
---
-2.52.0
-
diff --git a/curl.spec b/curl.spec
index a9785ad..bde42ae 100644
--- a/curl.spec
+++ b/curl.spec
@@ -12,7 +12,7 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 8.18.0
-Release: 14%{?dist}
+Release: 15%{?dist}
License: curl
Source0: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz
Source1: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz.asc
@@ -22,107 +22,41 @@ Source1: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz.asc
Source2: mykey.asc
# Fedora-specific
-# update timer unconditionally in multi_remove_handle
-# rubygem-ethon: FTBFS in Fedora Rawhide
-# https://bugzilla.redhat.com/show_bug.cgi?id=2405328
-Patch001: 0001-curl-8.18.0-multi-update-timer-unconditionally-in-multi_remove_h.patch
-
-# Fix `Could not find digest algorithm UNDEF (NID 0)`
-# https://bugzilla.redhat.com/show_bug.cgi?id=2438170
-Patch002: 0002-curl-8.18.0-openssl-channel_binding-lookup-digest-algorithm-with.patch
-
-# Fix bad reuse of HTTP Negotiate connection (CVE-2026-1965)
-Patch003: 0003-curl-8.18.0-CVE-2026-1965.patch
-
-# Fix token leak with redirect and netrc (CVE-2026-3783)
-Patch004: 0004-curl-8.18.0-CVE-2026-3783.patch
-
-# Fix wrong proxy connection reuse with credentials (CVE-2026-3784)
-Patch005: 0005-curl-8.18.0-CVE-2026-3784.patch
-
-# Fix use after free in SMB connection reuse (CVE-2026-3805)
-Patch006: 0006-curl-8.18.0-CVE-2026-3805.patch
-
-# Fix trailing dot domain super cookie (CVE-2026-8924)
-Patch007: 0007-curl-8.18.0-CVE-2026-8924.patch
-
-# Fix SSH improper host validation (CVE-2026-9547)
-Patch008: 0008-curl-8.18.0-CVE-2026-9547.patch
-
-# Fix password leak with netrc and user in URL (CVE-2026-8926)
-Patch009: 0009-curl-8.18.0-CVE-2026-8926.patch
-
-# Fix cross-origin Digest auth state leak (CVE-2026-11856)
-Patch010: 0010-curl-8.18.0-CVE-2026-11856.patch
-
-# Fix cross-proxy Digest auth state leak (CVE-2026-7168)
-Patch011: 0011-curl-8.18.0-CVE-2026-7168.patch
-
-# Fix OCSP stapling bypass with Apple SecTrust (CVE-2026-7009)
-Patch012: 0012-curl-8.18.0-CVE-2026-7009.patch
-
-# Fix QUIC zero-length UDP datagrams busy-loop (CVE-2026-11352)
-Patch013: 0013-curl-8.18.0-CVE-2026-11352.patch
-
-# Fix WS Auto-PONG memory exhaustion (CVE-2026-11586)
-Patch014: 0014-curl-8.18.0-CVE-2026-11586.patch
-
-# Fix proto-default skips SSH verification (CVE-2026-12064)
-Patch015: 0015-curl-8.18.0-CVE-2026-12064.patch
-
-# Fix wrong STARTTLS connection reuse (CVE-2026-8286)
-Patch016: 0016-curl-8.18.0-CVE-2026-8286.patch
-
-# Fix SASL double-free (CVE-2026-8925)
-Patch017: 0017-curl-8.18.0-CVE-2026-8925.patch
-
-# Fix env-set cross-proxy Digest auth state leak (CVE-2026-8927)
-Patch018: 0018-curl-8.18.0-CVE-2026-8927.patch
-
-# Fix sending old referer (CVE-2026-9546)
-Patch019: 0019-curl-8.18.0-CVE-2026-9546.patch
-
-# Fix exposing HTTP/3 early data (CVE-2026-9545)
-Patch020: 0020-curl-8.18.0-CVE-2026-9545.patch
-
-# Fix UAF after pause in socket callback (CVE-2026-9080)
-Patch021: 0021-curl-8.18.0-CVE-2026-9080.patch
-
-# Fix HTTP/2 stream-dependency tree UAF (CVE-2026-10536)
-Patch022: 0022-curl-8.18.0-CVE-2026-10536.patch
-
-# Fix Native CA trust persist (CVE-2026-11564)
-Patch023: 0023-curl-8.18.0-CVE-2026-11564.patch
-
-# Fix stale proxy password leak (CVE-2026-9079)
-Patch024: 0024-curl-8.18.0-CVE-2026-9079.patch
-
-# Fix wrong reuse for different services (CVE-2026-8458)
-Patch025: 0025-curl-8.18.0-CVE-2026-8458.patch
-
-# Fix HTTP/2 server push UAF (CVE-2026-18924)
-Patch026: 0026-curl-8.18.0-CVE-2026-18924.patch
-
-# Fix secure cookie attribute bypass with tab (CVE-2026-80255)
-Patch027: 0027-curl-8.18.0-CVE-2026-80255.patch
-
-# Fix OpenSSL provider use-after-free (CVE-2026-80229)
-Patch028: 0028-curl-8.18.0-CVE-2026-80229.patch
-
-# Fix Negotiate ambient user conn reuse (CVE-2026-19931)
-Patch029: 0029-curl-8.18.0-CVE-2026-19931.patch
-
-# Fix incomplete mTLS config matching in conn reuse (CVE-2026-8932)
-Patch030: 0030-curl-8.18.0-CVE-2026-8932.patch
-
-# Fix OpenLDAP SASL authentication bypass (CVE-2026-13608)
-Patch031: 0031-curl-8.18.0-CVE-2026-13608.patch
-
-# Fix OpenSSL pinning bypass (CVE-2026-80230)
-Patch032: 0032-curl-8.18.0-CVE-2026-80230.patch
-
-# patch making libcurl multilib ready
-Patch101: 0101-curl-7.32.0-multilib.patch
+Patch0001: 0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
+Patch0002: 0002-multi-update-timer-unconditionally-in-multi_remove_h.patch
+Patch0003: 0003-openssl-channel_binding-lookup-digest-algorithm-with.patch
+Patch0004: 0004-CVE-2026-1965.patch
+Patch0005: 0005-CVE-2026-3783.patch
+Patch0006: 0006-CVE-2026-3784.patch
+Patch0007: 0007-CVE-2026-3805.patch
+Patch0008: 0008-cookie-trim-trailing-dots-when-checking-PSL.patch
+Patch0009: 0009-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
+Patch0010: 0010-netrc-scanner-refactor.patch
+Patch0011: 0011-digest-flush-state-on-origin-or-credential-change.patch
+Patch0012: 0012-setopt-clear-proxy-auth-properties-when-switching.patch
+Patch0013: 0013-sectrust-fail-on-missing-OCSP-stapling.patch
+Patch0014: 0014-quic-count-zero-length-packets-against-max.patch
+Patch0015: 0015-ws-make-pong-sending-lazy.patch
+Patch0016: 0016-config2setopts-use-default-protocol-properly.patch
+Patch0017: 0017-CVE-2026-8286.patch
+Patch0018: 0018-gsasl-fix-potential-double-free.patch
+Patch0019: 0019-url-detect-proxy-changes-read-from-environment.patch
+Patch0020: 0020-CVE-2026-9546.patch
+Patch0021: 0021-ngtcp2-fail-handshake-directly.patch
+Patch0022: 0022-multi-handle-pause-in-multi-socket-callback.patch
+Patch0023: 0023-http2-remove-stream-dependency-tracking.patch
+Patch0024: 0024-ssl-native_ca_store-always-reinit.patch
+Patch0025: 0025-setopt-clear-proxy-auth-properly-on-NULL.patch
+Patch0026: 0026-creds-add-sasl-service-name.patch
+Patch0027: 0027-http2-make-server-push-transfers-inherit-share-from-.patch
+Patch0028: 0028-cookie-improve-TAB-handling.patch
+Patch0029: 0029-openssl-avoid-conn-reuse-if-provider-is-used.patch
+Patch0030: 0030-connections-use-admin-handles-only-for-maintenance.patch
+Patch0031: 0031-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
+Patch0032: 0032-openldap-handle-Curl_sasl_continue-returns-better.patch
+Patch0033: 0033-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
+Patch0034: 0034-ci-setup-packit.patch
+Patch0035: 0035-multi-adjust-the-cleanup-order-in-multi_done.patch
Provides: curl-full = %{version}-%{release}
# do not fail when trying to install curl-minimal after drop
@@ -547,6 +481,12 @@ rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/wcurl.1*
%{_libdir}/libcurl.so.4.[0-9].[0-9].minimal
%changelog
+* Fri Nov 27 2026 Jan Macku <jamacku@redhat.com> - 8.18.0-15
+- ci: enable upstream ci on src-git
+- ci: setup packit
+- ci: setup source-git automation
+- multi: adjust the cleanup order in multi_done (CVE-2026-92392)
+
* Mon Oct 12 2026 Jan Macku <jamacku@redhat.com> - 8.18.0-14
- Fix incomplete mTLS config matching in conn reuse (CVE-2026-8932)
- Fix OpenLDAP SASL authentication bypass (CVE-2026-13608)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-27 13:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 13:15 [rpms/curl] f44: curl-8.18.0-15 Jan Macku
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox