public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jan Macku <jamacku@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/curl] f43: curl-8.15.0-13
Date: Tue, 01 Dec 2026 14:27:10 GMT [thread overview]
Message-ID: <179613523051.1.3046621245190851268.rpms-curl-c9f36f91c920@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/curl
Branch : f43
Commit : c9f36f91c92080ed79b31f7162178682238f416a
Author : Jan Macku <jamacku@redhat.com>
Date : 2026-12-01T12:46:59+01:00
Stats : +6597/-6632 in 63 file(s)
URL : https://src.fedoraproject.org/rpms/curl/c/c9f36f91c92080ed79b31f7162178682238f416a?branch=f43
Log:
curl-8.15.0-13
Resolves: CVE-2026-92392
---
diff --git a/0001-curl-8.15.0-curl-tool_read_cb-fix-of-segfault.patch b/0001-curl-8.15.0-curl-tool_read_cb-fix-of-segfault.patch
deleted file mode 100644
index 03d4586..0000000
--- a/0001-curl-8.15.0-curl-tool_read_cb-fix-of-segfault.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 4bdb4d2f9eaad5d75094e6f6e8441c6844333963 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Mon, 21 Jul 2025 15:56:19 +0200
-Subject: [PATCH] curl: tool_read_cb fix of segfault
-
-When transfers read client input without an upload file, the check if
-upload file is '.' strcompared a NULL.
-
-Add test 1548 to reproduce and verify fix.
-
-Reported-by: d1r3ct0r
-Fixes #17978
-Closes #17987
-
-(cherry picked from commit 9657a2041e7745aecd5b16c5c6d812424edfc6fd)
----
- src/tool_cb_rea.c | 2 +-
- tests/data/Makefile.am | 2 +-
- tests/data/test1548 | 43 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 45 insertions(+), 2 deletions(-)
- create mode 100644 tests/data/test1548
-
-diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c
-index 2ceca242b..8268d0a1a 100644
---- a/src/tool_cb_rea.c
-+++ b/src/tool_cb_rea.c
-@@ -90,7 +90,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
- Make sure we are in non-blocking mode and infd is not regular stdin
- On Linux per->infd should be stdin (0) and the block below should not
- execute */
-- if(!strcmp(per->uploadfile, ".") && per->infd > 0) {
-+ if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) {
- #if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
- rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0);
- if(rc < 0) {
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index a72f6740f..7d8e8c7fc 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -203,7 +203,7 @@ test1516 test1517 test1518 test1519 test1520 test1521 test1522 test1523 \
- test1524 test1525 test1526 test1527 test1528 test1529 test1530 test1531 \
- test1532 test1533 test1534 test1535 test1536 test1537 test1538 test1539 \
- test1540 test1541 test1542 test1543 test1544 test1545 test1546 test1547 \
--\
-+test1548 \
- test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 \
- test1558 test1559 test1560 test1561 test1562 test1563 test1564 test1565 \
- test1566 test1567 test1568 test1569 test1570 test1571 test1572 test1573 \
-diff --git a/tests/data/test1548 b/tests/data/test1548
-new file mode 100644
-index 000000000..e888b5563
---- /dev/null
-+++ b/tests/data/test1548
-@@ -0,0 +1,43 @@
-+<testcase>
-+<info>
-+<keywords>
-+TELNET
-+</keywords>
-+</info>
-+
-+#
-+# Server-side
-+<reply>
-+<data>
-+</data>
-+</reply>
-+
-+#
-+# Client-side
-+<client>
-+<server>
-+http
-+</server>
-+<features>
-+telnet
-+</features>
-+<name>
-+TELNET read stdin without upload file
-+</name>
-+<stdin>
-+GET /we/want/%TESTNUMBER HTTP/1.0
-+
-+</stdin>
-+<command>
-+-m 1 telnet://%HOSTIP:%HTTPPORT
-+</command>
-+</client>
-+
-+#
-+# Verify data after the test has been "shot"
-+<verify>
-+<errorcode>
-+28
-+</errorcode>
-+</verify>
-+</testcase>
---
-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..083c333
--- /dev/null
+++ b/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
@@ -0,0 +1,90 @@
+From aa1c0caeb5461f60f9d662e7ce99b4b021098231 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 31ea30b24a..e4314234b9 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 "X@libdir@" != 'X/usr/lib' -a "X@libdir@" != 'X/usr/lib64'; then
+- curllibdir="-L@libdir@ "
+- else
+- curllibdir=''
+- fi
+- if test 'X@ENABLE_SHARED@' = 'Xno'; 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 'X@ENABLE_STATIC@' != 'Xno'; 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.15.0-CVE-2025-14017.patch b/0002-curl-8.15.0-CVE-2025-14017.patch
deleted file mode 100644
index 1628701..0000000
--- a/0002-curl-8.15.0-CVE-2025-14017.patch
+++ /dev/null
@@ -1,115 +0,0 @@
-From 5089cc785d0f04f66fe27e941fa142d1a99ce654 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 4 Dec 2025 00:14:20 +0100
-Subject: [PATCH] ldap: call ldap_init() before setting the options
-
-Closes #19830
-
-(cherry picked from commit 39d1976b7f709a516e3243338ebc0443bdd8d56d)
----
- lib/ldap.c | 48 ++++++++++++++++++------------------------------
- 1 file changed, 18 insertions(+), 30 deletions(-)
-
-diff --git a/lib/ldap.c b/lib/ldap.c
-index 40e72af0d7..f6da886242 100644
---- a/lib/ldap.c
-+++ b/lib/ldap.c
-@@ -374,16 +374,29 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- passwd = conn->passwd;
- }
-
-+#ifdef USE_WIN32_LDAP
-+ if(ldap_ssl)
-+ server = ldap_sslinit(host, (curl_ldap_num_t)ipquad.remote_port, 1);
-+ else
-+#else
-+ server = ldap_init(host, (curl_ldap_num_t)ipquad.remote_port);
-+#endif
-+ if(!server) {
-+ failf(data, "LDAP: cannot setup connect to %s:%u",
-+ conn->host.dispname, ipquad.remote_port);
-+ result = CURLE_COULDNT_CONNECT;
-+ goto quit;
-+ }
-+
- #ifdef LDAP_OPT_NETWORK_TIMEOUT
-- ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
-+ ldap_set_option(server, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
- #endif
-- ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-+ ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-
- if(ldap_ssl) {
- #ifdef HAVE_LDAP_SSL
- #ifdef USE_WIN32_LDAP
- /* Win32 LDAP SDK does not support insecure mode without CA! */
-- server = ldap_sslinit(host, (curl_ldap_num_t)conn->primary.remote_port, 1);
- ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
- #else
- int ldap_option;
-@@ -403,7 +416,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- goto quit;
- }
- infof(data, "LDAP local: using PEM CA cert: %s", ldap_ca);
-- rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
-+ rc = ldap_set_option(server, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
- if(rc != LDAP_SUCCESS) {
- failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
- ldap_err2string(rc));
-@@ -415,20 +428,13 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- else
- ldap_option = LDAP_OPT_X_TLS_NEVER;
-
-- rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
-+ rc = ldap_set_option(server, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
- if(rc != LDAP_SUCCESS) {
- failf(data, "LDAP local: ERROR setting cert verify mode: %s",
- ldap_err2string(rc));
- result = CURLE_SSL_CERTPROBLEM;
- goto quit;
- }
-- server = ldap_init(host, conn->primary.remote_port);
-- if(!server) {
-- failf(data, "LDAP local: Cannot connect to %s:%u",
-- conn->host.dispname, conn->primary.remote_port);
-- result = CURLE_COULDNT_CONNECT;
-- goto quit;
-- }
- ldap_option = LDAP_OPT_X_TLS_HARD;
- rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
- if(rc != LDAP_SUCCESS) {
-@@ -437,15 +443,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- result = CURLE_SSL_CERTPROBLEM;
- goto quit;
- }
--/*
-- rc = ldap_start_tls_s(server, NULL, NULL);
-- if(rc != LDAP_SUCCESS) {
-- failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
-- ldap_err2string(rc));
-- result = CURLE_SSL_CERTPROBLEM;
-- goto quit;
-- }
--*/
- #else
- (void)ldap_option;
- (void)ldap_ca;
-@@ -464,15 +461,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
- result = CURLE_NOT_BUILT_IN;
- goto quit;
- }
-- else {
-- server = ldap_init(host, (curl_ldap_num_t)conn->primary.remote_port);
-- if(!server) {
-- failf(data, "LDAP local: Cannot connect to %s:%u",
-- conn->host.dispname, conn->primary.remote_port);
-- result = CURLE_COULDNT_CONNECT;
-- goto quit;
-- }
-- }
- #ifdef USE_WIN32_LDAP
- ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
- rc = ldap_win_bind(data, server, user, passwd);
---
-2.52.0
-
diff --git a/0002-test616-disable-valgrind.patch b/0002-test616-disable-valgrind.patch
new file mode 100644
index 0000000..b308233
--- /dev/null
+++ b/0002-test616-disable-valgrind.patch
@@ -0,0 +1,45 @@
+From cabb8ac6fc666677f474f1a3442edfca93f9cea7 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Wed, 11 Dec 2024 13:16:12 +0100
+Subject: [PATCH] test616: disable valgrind
+
+Valgrind disable was removed in upstream in https://github.com/curl/curl/commit/c91c37b6e87ceee760b7bb334c8e97e03ee93e93#diff-e01fd8774cf5b26329c7dc7dc03ec49745469205f3d501ced72c9d133455d5e7L35
+But test 616 is still failing under valgrind, so disable valgrind for this test.
+
+```
+ valgrind ERROR ==188588== 144 bytes in 1 blocks are definitely lost in loss record 1 of 1
+==188588== at 0x484B133: calloc (vg_replace_malloc.c:1675)
+==188588== by 0x4BB7575: ??? (in /usr/lib64/libssh.so.4.10.1)
+==188588== by 0x4BB8CC6: sftp_fstat (in /usr/lib64/libssh.so.4.10.1)
+==188588== by 0x48EEAFB: myssh_statemach_act (libssh.c:1610)
+==188588== by 0x48F1B9D: myssh_multi_statemach.lto_priv.0 (libssh.c:2095)
+==188588== by 0x48BA971: UnknownInlinedFun (multi.c:1643)
+==188588== by 0x48BA971: UnknownInlinedFun (multi.c:2314)
+==188588== by 0x48BA971: multi_runsingle (multi.c:2768)
+==188588== by 0x48BCCA4: curl_multi_perform (multi.c:3016)
+==188588== by 0x4884E4A: UnknownInlinedFun (easy.c:701)
+==188588== by 0x4884E4A: UnknownInlinedFun (easy.c:796)
+==188588== by 0x4884E4A: curl_easy_perform (easy.c:815)
+==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:2902)
+==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:3127)
+==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:3249)
+==188588== by 0x10C12B: main (tool_main.c:271)
+==188588==
+```
+---
+ tests/data/test616 | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/tests/data/test616 b/tests/data/test616
+index 13bf00263d..b7628634a5 100644
+--- a/tests/data/test616
++++ b/tests/data/test616
+@@ -32,5 +32,8 @@ SFTP retrieval of empty file
+ #
+ # Verify data after the test has been "shot"
+ <verify>
++<valgrind>
++disable
++</valgrind>
+ </verify>
+ </testcase>
diff --git a/0003-curl-8.15.0-CVE-2026-1965.patch b/0003-curl-8.15.0-CVE-2026-1965.patch
deleted file mode 100644
index 07a00c9..0000000
--- a/0003-curl-8.15.0-CVE-2026-1965.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-From 3dcb1b4ea3505ac7368843feb0401d9b1076465c Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 5 Feb 2026 08:34:21 +0100
-Subject: [PATCH 1/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)
-
-sws: prevent "connection monitor" to say disconnect twice
-
-(cherry picked from commit 510fdad64df7f91f605b19ffdb0c4c67891f1518)
-
-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)
----
- 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 e4f250f54a..9d109f2005 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -820,6 +820,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);
-@@ -1242,6 +1244,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;
-@@ -1284,6 +1343,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;
-
-@@ -1350,13 +1414,26 @@ 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 7b90e510b4..4f3d71b4a6 100644
---- a/tests/server/sws.c
-+++ b/tests/server/sws.c
-@@ -2394,6 +2394,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)
---
-2.53.0
-
diff --git a/0003-curl-tool_read_cb-fix-of-segfault.patch b/0003-curl-tool_read_cb-fix-of-segfault.patch
new file mode 100644
index 0000000..5b243bd
--- /dev/null
+++ b/0003-curl-tool_read_cb-fix-of-segfault.patch
@@ -0,0 +1,97 @@
+From 31bf962a6d1c4cf63b170daee30b797b0afc291c Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 21 Jul 2025 15:56:19 +0200
+Subject: [PATCH] curl: tool_read_cb fix of segfault
+
+When transfers read client input without an upload file, the check if
+upload file is '.' strcompared a NULL.
+
+Add test 1548 to reproduce and verify fix.
+
+Reported-by: d1r3ct0r
+Fixes #17978
+Closes #17987
+
+(cherry picked from commit 9657a2041e7745aecd5b16c5c6d812424edfc6fd)
+---
+ src/tool_cb_rea.c | 2 +-
+ tests/data/Makefile.am | 2 +-
+ tests/data/test1548 | 43 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 45 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test1548
+
+diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c
+index 2ceca242b6..8268d0a1a3 100644
+--- a/src/tool_cb_rea.c
++++ b/src/tool_cb_rea.c
+@@ -90,7 +90,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
+ Make sure we are in non-blocking mode and infd is not regular stdin
+ On Linux per->infd should be stdin (0) and the block below should not
+ execute */
+- if(!strcmp(per->uploadfile, ".") && per->infd > 0) {
++ if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) {
+ #if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
+ rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0);
+ if(rc < 0) {
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index a72f6740f8..7d8e8c7fc5 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -203,7 +203,7 @@ test1516 test1517 test1518 test1519 test1520 test1521 test1522 test1523 \
+ test1524 test1525 test1526 test1527 test1528 test1529 test1530 test1531 \
+ test1532 test1533 test1534 test1535 test1536 test1537 test1538 test1539 \
+ test1540 test1541 test1542 test1543 test1544 test1545 test1546 test1547 \
+-\
++test1548 \
+ test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 \
+ test1558 test1559 test1560 test1561 test1562 test1563 test1564 test1565 \
+ test1566 test1567 test1568 test1569 test1570 test1571 test1572 test1573 \
+diff --git a/tests/data/test1548 b/tests/data/test1548
+new file mode 100644
+index 0000000000..e888b55639
+--- /dev/null
++++ b/tests/data/test1548
+@@ -0,0 +1,43 @@
++<testcase>
++<info>
++<keywords>
++TELNET
++</keywords>
++</info>
++
++#
++# Server-side
++<reply>
++<data>
++</data>
++</reply>
++
++#
++# Client-side
++<client>
++<server>
++http
++</server>
++<features>
++telnet
++</features>
++<name>
++TELNET read stdin without upload file
++</name>
++<stdin>
++GET /we/want/%TESTNUMBER HTTP/1.0
++
++</stdin>
++<command>
++-m 1 telnet://%HOSTIP:%HTTPPORT
++</command>
++</client>
++
++#
++# Verify data after the test has been "shot"
++<verify>
++<errorcode>
++28
++</errorcode>
++</verify>
++</testcase>
diff --git a/0004-curl-8.15.0-CVE-2026-3783.patch b/0004-curl-8.15.0-CVE-2026-3783.patch
deleted file mode 100644
index a1c379a..0000000
--- a/0004-curl-8.15.0-CVE-2026-3783.patch
+++ /dev/null
@@ -1,151 +0,0 @@
-From cd43259865e8ecb48383cc0533768f9ba640a6ed Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Fri, 6 Mar 2026 23:13:07 +0100
-Subject: [PATCH 2/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 | 1 +
- tests/data/Makefile.am | 2 +-
- tests/data/test2006 | 98 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 100 insertions(+), 1 deletion(-)
- create mode 100644 tests/data/test2006
-
-diff --git a/lib/http.c b/lib/http.c
-index e5a0696274..5feb99ef4b 100644
---- a/lib/http.c
-+++ b/lib/http.c
-@@ -697,6 +697,7 @@ output_auth_headers(struct Curl_easy *data,
- if(authstatus->picked == CURLAUTH_BEARER) {
- /* Bearer */
- 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);
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 7d8e8c7fc5..46b97e2913 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -240,7 +240,7 @@ test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
- test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
- test1978 test1979 test1980 \
- \
--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="yes">
-+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="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: 7
-+Connection: close
-+
-+target
-+</data2>
-+
-+<datacheck crlf="yes">
-+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="yes">
-+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/0004-ldap-call-ldap_init-before-setting-the-options.patch b/0004-ldap-call-ldap_init-before-setting-the-options.patch
new file mode 100644
index 0000000..2021fb9
--- /dev/null
+++ b/0004-ldap-call-ldap_init-before-setting-the-options.patch
@@ -0,0 +1,112 @@
+From 17202862fbea756b89968f599755a0c969abdc6c Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Thu, 4 Dec 2025 00:14:20 +0100
+Subject: [PATCH] ldap: call ldap_init() before setting the options
+
+Closes #19830
+
+(cherry picked from commit 39d1976b7f709a516e3243338ebc0443bdd8d56d)
+---
+ lib/ldap.c | 48 ++++++++++++++++++------------------------------
+ 1 file changed, 18 insertions(+), 30 deletions(-)
+
+diff --git a/lib/ldap.c b/lib/ldap.c
+index 40e72af0d7..f6da886242 100644
+--- a/lib/ldap.c
++++ b/lib/ldap.c
+@@ -374,16 +374,29 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ passwd = conn->passwd;
+ }
+
++#ifdef USE_WIN32_LDAP
++ if(ldap_ssl)
++ server = ldap_sslinit(host, (curl_ldap_num_t)ipquad.remote_port, 1);
++ else
++#else
++ server = ldap_init(host, (curl_ldap_num_t)ipquad.remote_port);
++#endif
++ if(!server) {
++ failf(data, "LDAP: cannot setup connect to %s:%u",
++ conn->host.dispname, ipquad.remote_port);
++ result = CURLE_COULDNT_CONNECT;
++ goto quit;
++ }
++
+ #ifdef LDAP_OPT_NETWORK_TIMEOUT
+- ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
++ ldap_set_option(server, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
+ #endif
+- ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
++ ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
+
+ if(ldap_ssl) {
+ #ifdef HAVE_LDAP_SSL
+ #ifdef USE_WIN32_LDAP
+ /* Win32 LDAP SDK does not support insecure mode without CA! */
+- server = ldap_sslinit(host, (curl_ldap_num_t)conn->primary.remote_port, 1);
+ ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
+ #else
+ int ldap_option;
+@@ -403,7 +416,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ goto quit;
+ }
+ infof(data, "LDAP local: using PEM CA cert: %s", ldap_ca);
+- rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
++ rc = ldap_set_option(server, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
+ if(rc != LDAP_SUCCESS) {
+ failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
+ ldap_err2string(rc));
+@@ -415,20 +428,13 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ else
+ ldap_option = LDAP_OPT_X_TLS_NEVER;
+
+- rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
++ rc = ldap_set_option(server, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
+ if(rc != LDAP_SUCCESS) {
+ failf(data, "LDAP local: ERROR setting cert verify mode: %s",
+ ldap_err2string(rc));
+ result = CURLE_SSL_CERTPROBLEM;
+ goto quit;
+ }
+- server = ldap_init(host, conn->primary.remote_port);
+- if(!server) {
+- failf(data, "LDAP local: Cannot connect to %s:%u",
+- conn->host.dispname, conn->primary.remote_port);
+- result = CURLE_COULDNT_CONNECT;
+- goto quit;
+- }
+ ldap_option = LDAP_OPT_X_TLS_HARD;
+ rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
+ if(rc != LDAP_SUCCESS) {
+@@ -437,15 +443,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ result = CURLE_SSL_CERTPROBLEM;
+ goto quit;
+ }
+-/*
+- rc = ldap_start_tls_s(server, NULL, NULL);
+- if(rc != LDAP_SUCCESS) {
+- failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
+- ldap_err2string(rc));
+- result = CURLE_SSL_CERTPROBLEM;
+- goto quit;
+- }
+-*/
+ #else
+ (void)ldap_option;
+ (void)ldap_ca;
+@@ -464,15 +461,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
+ result = CURLE_NOT_BUILT_IN;
+ goto quit;
+ }
+- else {
+- server = ldap_init(host, (curl_ldap_num_t)conn->primary.remote_port);
+- if(!server) {
+- failf(data, "LDAP local: Cannot connect to %s:%u",
+- conn->host.dispname, conn->primary.remote_port);
+- result = CURLE_COULDNT_CONNECT;
+- goto quit;
+- }
+- }
+ #ifdef USE_WIN32_LDAP
+ ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
+ rc = ldap_win_bind(data, server, user, passwd);
diff --git a/0005-CVE-2026-1965.patch b/0005-CVE-2026-1965.patch
new file mode 100644
index 0000000..63c2011
--- /dev/null
+++ b/0005-CVE-2026-1965.patch
@@ -0,0 +1,163 @@
+From d0eab851b19381baed0e7f8385e95a5414be3b6b 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)
+
+sws: prevent "connection monitor" to say disconnect twice
+
+(cherry picked from commit 510fdad64df7f91f605b19ffdb0c4c67891f1518)
+
+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)
+---
+ 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 e4f250f54a..9d109f2005 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -820,6 +820,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);
+@@ -1242,6 +1244,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;
+@@ -1284,6 +1343,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;
+
+@@ -1350,13 +1414,26 @@ 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 7b90e510b4..4f3d71b4a6 100644
+--- a/tests/server/sws.c
++++ b/tests/server/sws.c
+@@ -2394,6 +2394,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/0005-curl-8.15.0-CVE-2026-3784.patch b/0005-curl-8.15.0-CVE-2026-3784.patch
deleted file mode 100644
index 6321fc9..0000000
--- a/0005-curl-8.15.0-CVE-2026-3784.patch
+++ /dev/null
@@ -1,170 +0,0 @@
-From 9c7160641607813c799d42ea0c2ea1f7bb1a5b8c Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 6 Mar 2026 14:54:09 +0100
-Subject: [PATCH 3/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 | 34 +++++++-------------------------
- tests/http/test_13_proxy_auth.py | 20 +++++++++++++++++++
- tests/http/testenv/curl.py | 18 ++++++++++++++---
- 3 files changed, 42 insertions(+), 30 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index 9d109f2005..fd3bb575c7 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -643,34 +643,15 @@ 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'
-@@ -985,8 +966,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 6a9a7e6a84..727557a682 100644
---- a/tests/http/test_13_proxy_auth.py
-+++ b/tests/http/test_13_proxy_auth.py
-@@ -167,3 +167,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 fb28cd7fa7..4ea67e6a1d 100644
---- a/tests/http/testenv/curl.py
-+++ b/tests/http/testenv/curl.py
-@@ -580,7 +580,8 @@ class CurlClient:
- with_profile: bool = False,
- with_tcpdump: bool = False,
- no_save: bool = False,
-- 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:
-@@ -600,6 +601,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)
-@@ -870,6 +872,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,
-@@ -879,7 +882,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:
-@@ -889,8 +893,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]
-
-@@ -910,7 +916,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-3783.patch b/0006-CVE-2026-3783.patch
new file mode 100644
index 0000000..307c292
--- /dev/null
+++ b/0006-CVE-2026-3783.patch
@@ -0,0 +1,148 @@
+From a2365884cf31493c3acc99cb5792f67fbb07af36 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 | 1 +
+ tests/data/Makefile.am | 2 +-
+ tests/data/test2006 | 98 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 100 insertions(+), 1 deletion(-)
+ create mode 100644 tests/data/test2006
+
+diff --git a/lib/http.c b/lib/http.c
+index e5a0696274..5feb99ef4b 100644
+--- a/lib/http.c
++++ b/lib/http.c
+@@ -697,6 +697,7 @@ output_auth_headers(struct Curl_easy *data,
+ if(authstatus->picked == CURLAUTH_BEARER) {
+ /* Bearer */
+ 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);
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 7d8e8c7fc5..46b97e2913 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -240,7 +240,7 @@ test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
+ test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
+ test1978 test1979 test1980 \
+ \
+-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..4b8b2694b5
+--- /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="yes">
++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="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: 7
++Connection: close
++
++target
++</data2>
++
++<datacheck crlf="yes">
++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="yes">
++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/0006-curl-8.15.0-CVE-2026-3805.patch b/0006-curl-8.15.0-CVE-2026-3805.patch
deleted file mode 100644
index a39d20f..0000000
--- a/0006-curl-8.15.0-CVE-2026-3805.patch
+++ /dev/null
@@ -1,1856 +0,0 @@
-From 1db75fdaff8af5f9b0feac43e6c3990782af120f Mon Sep 17 00:00:00 2001
-From: Viktor Szakats <commit@vsz.me>
-Date: Sun, 21 Dec 2025 16:19:52 +0100
-Subject: [PATCH 4/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 | 98 +++---
- lib/gopher.c | 125 ++++---
- lib/http.c | 203 ++++++------
- lib/mqtt.c | 72 ++--
- lib/smb.c | 217 ++++++------
- lib/tftp.c | 727 ++++++++++++++++++++---------------------
- tests/data/Makefile.am | 2 +-
- tests/data/test1850 | 39 +++
- 9 files changed, 754 insertions(+), 793 deletions(-)
- create mode 100644 tests/data/test1850
-
-diff --git a/lib/dict.c b/lib/dict.c
-index 7f13e6f7ea..12198f0770 100644
---- a/lib/dict.c
-+++ b/lib/dict.c
-@@ -73,41 +73,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_getsock */
-- ZERO_NULL, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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)
- {
-@@ -314,4 +279,33 @@ error:
- 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_getsock */
-+ ZERO_NULL, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 b88f612305..c8e0e50c9a 100644
---- a/lib/file.c
-+++ b/lib/file.c
-@@ -93,50 +93,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_getsock */
-- ZERO_NULL, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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);
-@@ -170,6 +126,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
-@@ -288,19 +257,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; /* not used */
-- (void)premature; /* not used */
--
-- if(file)
-- file_cleanup(file);
--
-- return CURLE_OK;
--}
--
- static CURLcode file_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- bool dead_connection)
-@@ -667,4 +623,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_getsock */
-+ ZERO_NULL, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 68ccb59e40..b0ee51be55 100644
---- a/lib/gopher.c
-+++ b/lib/gopher.c
-@@ -45,73 +45,7 @@
- /* The last #include file should be: */
- #include "memdebug.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_getsock */
-- ZERO_NULL, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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_getsock */
-- ZERO_NULL, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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;
-@@ -243,4 +177,63 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
- Curl_xfer_setup1(data, CURL_XFER_RECV, -1, FALSE);
- 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_getsock */
-+ ZERO_NULL, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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_getsock */
-+ ZERO_NULL, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 5feb99ef4b..77f1fd6d41 100644
---- a/lib/http.c
-+++ b/lib/http.c
-@@ -519,13 +519,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;
-@@ -1084,77 +1154,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 +1532,33 @@ int Curl_http_getsock_do(struct Curl_easy *data,
- return GETSOCK_WRITESOCK(0);
- }
-
-+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.
-@@ -3660,33 +3686,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,
-diff --git a/lib/mqtt.c b/lib/mqtt.c
-index 90f857dca5..20cafb62bf 100644
---- a/lib/mqtt.c
-+++ b/lib/mqtt.c
-@@ -98,49 +98,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 int mqtt_getsock(struct Curl_easy *data, struct connectdata *conn,
-- curl_socket_t *sock);
--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_getsock */
-- mqtt_getsock, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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;
-@@ -982,4 +939,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_getsock */
-+ mqtt_getsock, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 3eee16468d..23afb51b22 100644
---- a/lib/smb.c
-+++ b/lib/smb.c
-@@ -291,77 +291,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 int smb_getsock(struct Curl_easy *data, struct connectdata *conn,
-- curl_socket_t *socks);
--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_getsock, /* proto_getsock */
-- smb_getsock, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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_NONE /* 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_getsock, /* proto_getsock */
-- smb_getsock, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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 /* flags */
--};
--#endif
--
- #define MAX_PAYLOAD_SIZE 0x8000
- #define MAX_MESSAGE_SIZE (MAX_PAYLOAD_SIZE + 0x1000)
- #define CLIENTNAME "curl"
-@@ -448,9 +377,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);
- free(req);
- }
-
-@@ -466,6 +393,52 @@ static void smb_conn_dtor(void *key, size_t klen, void *entry)
- 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 = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
-+ 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 = 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,
-@@ -1225,47 +1198,63 @@ 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 = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
-- 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_getsock, /* proto_getsock */
-+ smb_getsock, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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_NONE /* 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_getsock, /* proto_getsock */
-+ smb_getsock, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 /* 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 5ea986dbb4..0fecd93645 100644
---- a/lib/tftp.c
-+++ b/lib/tftp.c
-@@ -148,52 +148,6 @@ struct tftp_conn {
- struct tftp_packet spacket;
- };
-
--
--/* 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 int tftp_getsock(struct Curl_easy *data, struct connectdata *conn,
-- curl_socket_t *socks);
--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_getsock, /* proto_getsock */
-- tftp_getsock, /* doing_getsock */
-- ZERO_NULL, /* domore_getsock */
-- ZERO_NULL, /* perform_getsock */
-- 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 -
-@@ -390,190 +344,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. */
-- 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",
-+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ result = CURLE_SEND_ERROR;
-+ }
-+ }
-
-- if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
-- failf(data, "TFTP filename too long");
-- 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 */
-
-- msnprintf((char *)state->spacket.data + 2,
-- state->blksize,
-- "%s%c%s%c", filename, '\0', mode, '\0');
-- sbytes = 4 + strlen(filename) + strlen(mode);
--
-- /* optional addition of TFTP options */
-- if(!data->set.tftp_no_options) {
-- char buf[64];
-- /* add tsize option */
-- msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
-- data->state.upload && (data->state.infilesize != -1) ?
-- data->state.infilesize : 0);
--
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes,
-- TFTP_OPTION_TSIZE);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes, buf);
--
-- /* add blksize option */
-- msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes,
-- TFTP_OPTION_BLKSIZE);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes, buf);
--
-- /* add timeout option */
-- msnprintf(buf, sizeof(buf), "%d", state->retry_time);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes,
-- TFTP_OPTION_INTERVAL);
-- if(result == CURLE_OK)
-- result = tftp_option_add(state, &sbytes,
-- (char *)state->spacket.data + sbytes, buf);
--
-- if(result != CURLE_OK) {
-- failf(data, "TFTP buffer too small for options");
-- free(filename);
-- 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];
-- failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ 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", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ return CURLE_SEND_ERROR;
- }
-- free(filename);
-+ /* Update the progress meter */
-+ k->writebytecount += state->sbytes;
-+ Curl_pgrsSetUploadCounter(data, k->writebytecount);
- 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", Curl_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");
-+ 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);
-+}
-
- /**********************************************************
- *
-@@ -620,7 +559,7 @@ static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
- (struct sockaddr *)&state->remote_addr,
- state->remote_addrlen);
- if(sbytes < 0) {
-- failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
- return CURLE_SEND_ERROR;
- }
-
-@@ -629,209 +568,59 @@ static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
- 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", Curl_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", Curl_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", Curl_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++;
-+ state->state = TFTP_STATE_RX;
- }
-- else
-- state->block = 1; /* first data block is 1 when using OACK */
-+ 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_DATA);
-+ setpacketevent(&state->spacket, TFTP_EVENT_ACK);
- setpacketblock(&state->spacket, state->block);
-- if(state->block > 1 && state->sbytes < state->blksize) {
-- state->state = TFTP_STATE_FIN;
-- return CURLE_OK;
-- }
--
-- /* 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);
--
-- sbytes = sendto(state->sockfd, (void *) state->spacket.data,
-- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
-+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
-+ 4, SEND_4TH_ARG,
- (struct sockaddr *)&state->remote_addr,
- state->remote_addrlen);
-- /* Check all sbytes were sent */
- if(sbytes < 0) {
-- failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
- return CURLE_SEND_ERROR;
- }
-- /* Update the progress meter */
-- k->writebytecount += state->sbytes;
-- Curl_pgrsSetUploadCounter(data, k->writebytecount);
-+
-+ /* 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", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ failf(data, "%s", Curl_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
-@@ -840,7 +629,172 @@ 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. */
-+ 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");
-+ free(filename);
-+ return CURLE_TFTP_ILLEGAL; /* too long filename field */
-+ }
-+
-+ msnprintf((char *)state->spacket.data + 2,
-+ state->blksize,
-+ "%s%c%s%c", filename, '\0', mode, '\0');
-+ sbytes = 4 + strlen(filename) + strlen(mode);
-+
-+ /* optional addition of TFTP options */
-+ if(!data->set.tftp_no_options) {
-+ char buf[64];
-+ /* add tsize option */
-+ msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
-+ data->state.upload && (data->state.infilesize != -1) ?
-+ data->state.infilesize : 0);
-+
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes,
-+ TFTP_OPTION_TSIZE);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes, buf);
-+
-+ /* add blksize option */
-+ msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes,
-+ TFTP_OPTION_BLKSIZE);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes, buf);
-+
-+ /* add timeout option */
-+ msnprintf(buf, sizeof(buf), "%d", state->retry_time);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes,
-+ TFTP_OPTION_INTERVAL);
-+ if(result == CURLE_OK)
-+ result = tftp_option_add(state, &sbytes,
-+ (char *)state->spacket.data + sbytes, buf);
-+
-+ if(result != CURLE_OK) {
-+ failf(data, "TFTP buffer too small for options");
-+ free(filename);
-+ 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", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
-+ }
-+ free(filename);
-+ 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");
- break;
- }
-
-@@ -1400,4 +1354,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_getsock, /* proto_getsock */
-+ tftp_getsock, /* doing_getsock */
-+ ZERO_NULL, /* domore_getsock */
-+ ZERO_NULL, /* perform_getsock */
-+ 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 46b97e2913..ca1a0c52f8 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -228,7 +228,7 @@ test1680 test1681 test1682 test1683 \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 \
- \
--test1800 test1801 \
-+test1800 test1801 test1850 \
- \
- test1900 test1901 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-3784.patch b/0007-CVE-2026-3784.patch
new file mode 100644
index 0000000..29defc1
--- /dev/null
+++ b/0007-CVE-2026-3784.patch
@@ -0,0 +1,167 @@
+From 5f6924892c967a585cf2519261ae4a3f070e12e9 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 | 34 +++++++-------------------------
+ tests/http/test_13_proxy_auth.py | 20 +++++++++++++++++++
+ tests/http/testenv/curl.py | 18 ++++++++++++++---
+ 3 files changed, 42 insertions(+), 30 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 9d109f2005..fd3bb575c7 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -643,34 +643,15 @@ 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'
+@@ -985,8 +966,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 6a9a7e6a84..727557a682 100644
+--- a/tests/http/test_13_proxy_auth.py
++++ b/tests/http/test_13_proxy_auth.py
+@@ -167,3 +167,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 fb28cd7fa7..4ea67e6a1d 100644
+--- a/tests/http/testenv/curl.py
++++ b/tests/http/testenv/curl.py
+@@ -580,7 +580,8 @@ class CurlClient:
+ with_profile: bool = False,
+ with_tcpdump: bool = False,
+ no_save: bool = False,
+- 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:
+@@ -600,6 +601,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)
+@@ -870,6 +872,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,
+@@ -879,7 +882,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:
+@@ -889,8 +893,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]
+
+@@ -910,7 +916,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/0007-curl-8.15.0-CVE-2025-9086.patch b/0007-curl-8.15.0-CVE-2025-9086.patch
deleted file mode 100644
index b83d38c..0000000
--- a/0007-curl-8.15.0-CVE-2025-9086.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From a8daa4ae31442a5ee932409a711fd65dc052c1eb Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 11 Aug 2025 20:23:05 +0200
-Subject: [PATCH] cookie: don't treat the leading slash as trailing
-
-If there is only a leading slash in the path, keep that. Also add an
-assert to make sure the path is never blank.
-
-Reported-by: Google Big Sleep
-Closes #18266
-
-(cherry picked from commit c6ae07c6a541e0e96d0040afb62b45dd37711300)
----
- lib/cookie.c | 11 ++++++-----
- 1 file changed, 6 insertions(+), 5 deletions(-)
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index 9221871e4b..2a1e59d9c6 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -296,9 +296,9 @@ static char *sanitize_cookie_path(const char *cookie_path)
- /* Let cookie-path be the default-path. */
- return strdup("/");
-
-- /* remove trailing slash */
-+ /* remove trailing slash when path is non-empty */
- /* convert /hoge/ to /hoge */
-- if(len && cookie_path[len - 1] == '/')
-+ if(len > 1 && cookie_path[len - 1] == '/')
- len--;
-
- return Curl_memdup0(cookie_path, len);
-@@ -965,7 +965,7 @@ replace_existing(struct Curl_easy *data,
- clist->spath && co->spath && /* both have paths */
- clist->secure && !co->secure && !secure) {
- size_t cllen;
-- const char *sep;
-+ const char *sep = NULL;
-
- /*
- * A non-secure cookie may not overlay an existing secure cookie.
-@@ -974,8 +974,9 @@ replace_existing(struct Curl_easy *data,
- * "/loginhelper" is ok.
- */
-
-- sep = strchr(clist->spath + 1, '/');
--
-+ DEBUGASSERT(clist->spath[0]);
-+ if(clist->spath[0])
-+ sep = strchr(clist->spath + 1, '/');
- if(sep)
- cllen = sep - clist->spath;
- else
---
-2.54.0
-
diff --git a/0008-CVE-2026-3805.patch b/0008-CVE-2026-3805.patch
new file mode 100644
index 0000000..45c8a44
--- /dev/null
+++ b/0008-CVE-2026-3805.patch
@@ -0,0 +1,1841 @@
+From a09fe790e1bd84988547bfde53cc4fa55aa98d75 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 | 98 +++---
+ lib/gopher.c | 125 ++++---
+ lib/http.c | 197 ++++++-----
+ lib/mqtt.c | 72 ++---
+ lib/smb.c | 217 ++++++-------
+ lib/tftp.c | 719 ++++++++++++++++++++---------------------
+ tests/data/Makefile.am | 2 +-
+ tests/data/test1850 | 39 +++
+ 9 files changed, 750 insertions(+), 783 deletions(-)
+ create mode 100644 tests/data/test1850
+
+diff --git a/lib/dict.c b/lib/dict.c
+index 7f13e6f7ea..12198f0770 100644
+--- a/lib/dict.c
++++ b/lib/dict.c
+@@ -73,41 +73,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_getsock */
+- ZERO_NULL, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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)
+ {
+@@ -314,4 +279,33 @@ error:
+ 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_getsock */
++ ZERO_NULL, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 b88f612305..c8e0e50c9a 100644
+--- a/lib/file.c
++++ b/lib/file.c
+@@ -93,50 +93,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_getsock */
+- ZERO_NULL, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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);
+@@ -170,6 +126,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
+@@ -288,19 +257,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; /* not used */
+- (void)premature; /* not used */
+-
+- if(file)
+- file_cleanup(file);
+-
+- return CURLE_OK;
+-}
+-
+ static CURLcode file_disconnect(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool dead_connection)
+@@ -667,4 +623,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_getsock */
++ ZERO_NULL, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 68ccb59e40..b0ee51be55 100644
+--- a/lib/gopher.c
++++ b/lib/gopher.c
+@@ -45,73 +45,7 @@
+ /* The last #include file should be: */
+ #include "memdebug.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_getsock */
+- ZERO_NULL, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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_getsock */
+- ZERO_NULL, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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;
+@@ -243,4 +177,63 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
+ Curl_xfer_setup1(data, CURL_XFER_RECV, -1, FALSE);
+ 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_getsock */
++ ZERO_NULL, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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_getsock */
++ ZERO_NULL, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 5feb99ef4b..94a649dd58 100644
+--- a/lib/http.c
++++ b/lib/http.c
+@@ -519,13 +519,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;
+@@ -1084,77 +1154,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 +1532,33 @@ int Curl_http_getsock_do(struct Curl_easy *data,
+ return GETSOCK_WRITESOCK(0);
+ }
+
++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.
+@@ -3660,33 +3686,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,
+diff --git a/lib/mqtt.c b/lib/mqtt.c
+index 90f857dca5..20cafb62bf 100644
+--- a/lib/mqtt.c
++++ b/lib/mqtt.c
+@@ -98,49 +98,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 int mqtt_getsock(struct Curl_easy *data, struct connectdata *conn,
+- curl_socket_t *sock);
+-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_getsock */
+- mqtt_getsock, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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;
+@@ -982,4 +939,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_getsock */
++ mqtt_getsock, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 3eee16468d..23afb51b22 100644
+--- a/lib/smb.c
++++ b/lib/smb.c
+@@ -291,77 +291,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 int smb_getsock(struct Curl_easy *data, struct connectdata *conn,
+- curl_socket_t *socks);
+-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_getsock, /* proto_getsock */
+- smb_getsock, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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_NONE /* 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_getsock, /* proto_getsock */
+- smb_getsock, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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 /* flags */
+-};
+-#endif
+-
+ #define MAX_PAYLOAD_SIZE 0x8000
+ #define MAX_MESSAGE_SIZE (MAX_PAYLOAD_SIZE + 0x1000)
+ #define CLIENTNAME "curl"
+@@ -448,9 +377,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);
+ free(req);
+ }
+
+@@ -466,6 +393,52 @@ static void smb_conn_dtor(void *key, size_t klen, void *entry)
+ 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 = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
++ 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 = 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,
+@@ -1225,47 +1198,63 @@ 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 = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
+- 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_getsock, /* proto_getsock */
++ smb_getsock, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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_NONE /* 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_getsock, /* proto_getsock */
++ smb_getsock, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 /* 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 5ea986dbb4..7dc5c12fa8 100644
+--- a/lib/tftp.c
++++ b/lib/tftp.c
+@@ -148,52 +148,6 @@ struct tftp_conn {
+ struct tftp_packet spacket;
+ };
+
+-
+-/* 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 int tftp_getsock(struct Curl_easy *data, struct connectdata *conn,
+- curl_socket_t *socks);
+-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_getsock, /* proto_getsock */
+- tftp_getsock, /* doing_getsock */
+- ZERO_NULL, /* domore_getsock */
+- ZERO_NULL, /* perform_getsock */
+- 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 -
+@@ -390,190 +344,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. */
+- 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",
++ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ result = CURLE_SEND_ERROR;
++ }
++ }
+
+- if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
+- failf(data, "TFTP filename too long");
+- 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 */
+
+- msnprintf((char *)state->spacket.data + 2,
+- state->blksize,
+- "%s%c%s%c", filename, '\0', mode, '\0');
+- sbytes = 4 + strlen(filename) + strlen(mode);
+-
+- /* optional addition of TFTP options */
+- if(!data->set.tftp_no_options) {
+- char buf[64];
+- /* add tsize option */
+- msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
+- data->state.upload && (data->state.infilesize != -1) ?
+- data->state.infilesize : 0);
+-
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes,
+- TFTP_OPTION_TSIZE);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes, buf);
+-
+- /* add blksize option */
+- msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes,
+- TFTP_OPTION_BLKSIZE);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes, buf);
+-
+- /* add timeout option */
+- msnprintf(buf, sizeof(buf), "%d", state->retry_time);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes,
+- TFTP_OPTION_INTERVAL);
+- if(result == CURLE_OK)
+- result = tftp_option_add(state, &sbytes,
+- (char *)state->spacket.data + sbytes, buf);
+-
+- if(result != CURLE_OK) {
+- failf(data, "TFTP buffer too small for options");
+- free(filename);
+- 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", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ return CURLE_SEND_ERROR;
+ }
+- free(filename);
++ /* Update the progress meter */
++ k->writebytecount += state->sbytes;
++ Curl_pgrsSetUploadCounter(data, k->writebytecount);
+ 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", Curl_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");
++ 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);
++}
+
+ /**********************************************************
+ *
+@@ -629,209 +568,59 @@ static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
+ 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", Curl_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", Curl_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", Curl_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++;
++ state->state = TFTP_STATE_RX;
+ }
+- else
+- state->block = 1; /* first data block is 1 when using OACK */
++ 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_DATA);
++ setpacketevent(&state->spacket, TFTP_EVENT_ACK);
+ setpacketblock(&state->spacket, state->block);
+- if(state->block > 1 && state->sbytes < state->blksize) {
+- state->state = TFTP_STATE_FIN;
+- return CURLE_OK;
+- }
+-
+- /* 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);
+-
+- sbytes = sendto(state->sockfd, (void *) state->spacket.data,
+- 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
++ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
++ 4, SEND_4TH_ARG,
+ (struct sockaddr *)&state->remote_addr,
+ state->remote_addrlen);
+- /* Check all sbytes were sent */
+ if(sbytes < 0) {
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ return CURLE_SEND_ERROR;
+ }
+- /* Update the progress meter */
+- k->writebytecount += state->sbytes;
+- Curl_pgrsSetUploadCounter(data, k->writebytecount);
++
++ /* 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", Curl_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
+@@ -840,7 +629,172 @@ 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. */
++ 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");
++ free(filename);
++ return CURLE_TFTP_ILLEGAL; /* too long filename field */
++ }
++
++ msnprintf((char *)state->spacket.data + 2,
++ state->blksize,
++ "%s%c%s%c", filename, '\0', mode, '\0');
++ sbytes = 4 + strlen(filename) + strlen(mode);
++
++ /* optional addition of TFTP options */
++ if(!data->set.tftp_no_options) {
++ char buf[64];
++ /* add tsize option */
++ msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
++ data->state.upload && (data->state.infilesize != -1) ?
++ data->state.infilesize : 0);
++
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes,
++ TFTP_OPTION_TSIZE);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes, buf);
++
++ /* add blksize option */
++ msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes,
++ TFTP_OPTION_BLKSIZE);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes, buf);
++
++ /* add timeout option */
++ msnprintf(buf, sizeof(buf), "%d", state->retry_time);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes,
++ TFTP_OPTION_INTERVAL);
++ if(result == CURLE_OK)
++ result = tftp_option_add(state, &sbytes,
++ (char *)state->spacket.data + sbytes, buf);
++
++ if(result != CURLE_OK) {
++ failf(data, "TFTP buffer too small for options");
++ free(filename);
++ 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", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
++ }
++ free(filename);
++ 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");
+ break;
+ }
+
+@@ -1400,4 +1354,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_getsock, /* proto_getsock */
++ tftp_getsock, /* doing_getsock */
++ ZERO_NULL, /* domore_getsock */
++ ZERO_NULL, /* perform_getsock */
++ 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 46b97e2913..ca1a0c52f8 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -228,7 +228,7 @@ test1680 test1681 test1682 test1683 \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 \
+ \
+-test1800 test1801 \
++test1800 test1801 test1850 \
+ \
+ test1900 test1901 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/0008-curl-8.15.0-CVE-2026-7168.patch b/0008-curl-8.15.0-CVE-2026-7168.patch
deleted file mode 100644
index 2947c1d..0000000
--- a/0008-curl-8.15.0-CVE-2026-7168.patch
+++ /dev/null
@@ -1,371 +0,0 @@
-From 9cce6194ff1d1f113518bee306e9907f2cd6cd5a Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 27 Apr 2026 09:14:51 +0200
-Subject: [PATCH 1/5] setopt: clear proxy auth properties when switching
-
-Verify with test 1588
-
-Closes #21453
-
-(cherry picked from commit c1cfdf59acbaf9504c4578d4cf56cdd7c8594507)
----
- lib/setopt.c | 17 ++++-
- 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, 275 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 1380c33db6..0ec31908a1 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -54,6 +54,7 @@
- #include "tftp.h"
- #include "strdup.h"
- #include "escape.h"
-+#include "vauth/vauth.h"
-
- /* The last 3 #include files should be in this order */
- #include "curl_printf.h"
-@@ -1661,6 +1662,20 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
- return result;
- }
-
-+#ifndef CURL_DISABLE_PROXY
-+static CURLcode setproxy(struct Curl_easy *data, const char *proxy)
-+{
-+ if((data->set.str[STRING_PROXY] && proxy) &&
-+ /* there was one set, is this a new one? */
-+ !strcmp(data->set.str[STRING_PROXY], proxy))
-+ return CURLE_OK; /* same one as before */
-+
-+ Curl_auth_digest_cleanup(&data->state.proxydigest);
-+ memset(&data->state.authproxy, 0, sizeof(data->state.authproxy));
-+ return Curl_setstropt(&data->set.str[STRING_PROXY], proxy);
-+}
-+#endif
-+
- static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
- char *ptr)
- {
-@@ -1948,7 +1963,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(&data->set.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 7d085e33fd..ddeafe39ea 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 ca1a0c52f8..369f687ecd 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -208,6 +208,7 @@ test1550 test1551 test1552 test1553 test1554 test1555 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 \
-+test1588 \
- \
- test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
- test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
-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>
-+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 8878ae85fa..c99af637dd 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -75,7 +75,7 @@ TESTS_C = \
- lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c lib1558.c \
- lib1559.c lib1560.c lib1564.c lib1565.c \
- lib1567.c lib1568.c lib1569.c lib1571.c \
-- lib1576.c \
-+ lib1576.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 res = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(res)
-+ goto init_failed;
-+#if 0
-+ res_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
-+ if(res)
-+ goto init_failed;
-+#endif
-+
-+ res_easy_setopt(curl, CURLOPT_HEADER, 1L);
-+ if(res)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return res; /* failure */
-+}
-+
-+static CURLcode run1588(CURL *curl, const char *url, const char *userpwd,
-+ const char *proxy)
-+{
-+ CURLcode res = CURLE_OK;
-+
-+ res = init1588(curl, url, userpwd, proxy);
-+ if(res)
-+ return res;
-+
-+ return curl_easy_perform(curl);
-+}
-+
-+static CURLcode test_lib1588(char *URL)
-+{
-+ CURLcode res = 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(res)
-+ return res;
-+
-+ 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);
-+
-+ res = run1588(curl, URL, proxyuserpws, proxy1_connect);
-+ if(res)
-+ goto test_cleanup;
-+
-+ curl_mfprintf(stderr, "lib1588: now we do the request again\n");
-+
-+ res = 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 res;
-+}
---
-2.55.0
-
diff --git a/0009-cookie-don-t-treat-the-leading-slash-as-trailing.patch b/0009-cookie-don-t-treat-the-leading-slash-as-trailing.patch
new file mode 100644
index 0000000..a21fd6f
--- /dev/null
+++ b/0009-cookie-don-t-treat-the-leading-slash-as-trailing.patch
@@ -0,0 +1,53 @@
+From ed26927bad2abbd2125dc8487d55d2211c5aef2b Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 11 Aug 2025 20:23:05 +0200
+Subject: [PATCH] cookie: don't treat the leading slash as trailing
+
+If there is only a leading slash in the path, keep that. Also add an
+assert to make sure the path is never blank.
+
+Reported-by: Google Big Sleep
+Closes #18266
+
+(cherry picked from commit c6ae07c6a541e0e96d0040afb62b45dd37711300)
+---
+ lib/cookie.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index 9221871e4b..2a1e59d9c6 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -296,9 +296,9 @@ static char *sanitize_cookie_path(const char *cookie_path)
+ /* Let cookie-path be the default-path. */
+ return strdup("/");
+
+- /* remove trailing slash */
++ /* remove trailing slash when path is non-empty */
+ /* convert /hoge/ to /hoge */
+- if(len && cookie_path[len - 1] == '/')
++ if(len > 1 && cookie_path[len - 1] == '/')
+ len--;
+
+ return Curl_memdup0(cookie_path, len);
+@@ -965,7 +965,7 @@ replace_existing(struct Curl_easy *data,
+ clist->spath && co->spath && /* both have paths */
+ clist->secure && !co->secure && !secure) {
+ size_t cllen;
+- const char *sep;
++ const char *sep = NULL;
+
+ /*
+ * A non-secure cookie may not overlay an existing secure cookie.
+@@ -974,8 +974,9 @@ replace_existing(struct Curl_easy *data,
+ * "/loginhelper" is ok.
+ */
+
+- sep = strchr(clist->spath + 1, '/');
+-
++ DEBUGASSERT(clist->spath[0]);
++ if(clist->spath[0])
++ sep = strchr(clist->spath + 1, '/');
+ if(sep)
+ cllen = sep - clist->spath;
+ else
diff --git a/0009-curl-8.15.0-CVE-2026-11856.patch b/0009-curl-8.15.0-CVE-2026-11856.patch
deleted file mode 100644
index 13b0b77..0000000
--- a/0009-curl-8.15.0-CVE-2026-11856.patch
+++ /dev/null
@@ -1,337 +0,0 @@
-From 449336291f5bcab4cb24e275adbc34e602a9e36c Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Mon, 3 Aug 2026 12:50:36 +0200
-Subject: [PATCH 2/5] 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 651bb83403..f82c8d0014 100644
---- a/lib/http_digest.c
-+++ b/lib/http_digest.c
-@@ -104,7 +104,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 = strdup(data->conn->host.name);
-+ digest->origin_port = data->conn->remote_port;
-+ Curl_safefree(digest->user);
-+ digest->user = strdup(data->state.aptr.user ?
-+ data->state.aptr.user : "");
-+ Curl_safefree(digest->passwd);
-+ digest->passwd = 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 e54721dd98..1873e2dc5d 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -317,14 +317,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;
- #if defined(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 898629a958..10e3cd6c69 100644
---- a/lib/vauth/digest.c
-+++ b/lib/vauth/digest.c
-@@ -997,6 +997,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 28d0b3599c..dcaaaf2616 100644
---- a/lib/vauth/digest_sspi.c
-+++ b/lib/vauth/digest_sspi.c
-@@ -678,6 +678,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 369f687ecd..49684fb735 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -224,7 +224,7 @@ test1660 test1661 test1662 test1663 test1664 \
- \
- test1670 test1671 \
- \
--test1680 test1681 test1682 test1683 \
-+test1680 test1681 test1682 test1683 test1686 \
- \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 \
-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 c99af637dd..b5760a69b0 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -79,6 +79,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 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 \
-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(char *hostip)
-+{
-+ CURL *curl = NULL;
-+ CURLcode res = 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);
-+ res = curl_easy_perform(curl);
-+
-+ easy_setopt(curl, CURLOPT_URL, secondurl);
-+ res = curl_easy_perform(curl);
-+
-+ easy_setopt(curl, CURLOPT_USERPWD, "bob:secret");
-+ easy_setopt(curl, CURLOPT_URL, secondurl);
-+ res = curl_easy_perform(curl);
-+ }
-+
-+test_cleanup:
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ curl_slist_free_all(host);
-+ return res;
-+}
---
-2.55.0
-
diff --git a/0010-curl-8.15.0-CVE-2026-8926.patch b/0010-curl-8.15.0-CVE-2026-8926.patch
deleted file mode 100644
index d2a3aa1..0000000
--- a/0010-curl-8.15.0-CVE-2026-8926.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-From 9fb03b7bb14943c2dc99d0153a922826edd48879 Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Mon, 3 Aug 2026 12:56:16 +0200
-Subject: [PATCH 3/5] 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)
----
- lib/netrc.c | 15 ++++++++++++++-
- tests/unit/unit1304.c | 23 ++++++++++++++++++++---
- 2 files changed, 34 insertions(+), 4 deletions(-)
-
-diff --git a/lib/netrc.c b/lib/netrc.c
-index bf53fc01e1..e0f0340d50 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 = strdup("");
- if(!password)
-diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
-index 0d7f04f9de..e691cadf32 100644
---- a/tests/unit/unit1304.c
-+++ b/tests/unit/unit1304.c
-@@ -61,7 +61,7 @@ static CURLcode test_unit1304(char *arg)
- 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);
-
-@@ -84,7 +84,7 @@ static CURLcode test_unit1304(char *arg)
- 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);
-
-@@ -96,7 +96,7 @@ static CURLcode test_unit1304(char *arg)
- 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);
-
-@@ -173,6 +173,23 @@ static CURLcode test_unit1304(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.
-+ */
-+ free(password);
-+ password = NULL;
-+ 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/0010-setopt-clear-proxy-auth-properties-when-switching.patch b/0010-setopt-clear-proxy-auth-properties-when-switching.patch
new file mode 100644
index 0000000..a3e87e0
--- /dev/null
+++ b/0010-setopt-clear-proxy-auth-properties-when-switching.patch
@@ -0,0 +1,368 @@
+From c1d9d83a23a25b761dac35a66c2fa98fc90ed39a 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 | 17 ++++-
+ 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, 275 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 1380c33db6..0ec31908a1 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -54,6 +54,7 @@
+ #include "tftp.h"
+ #include "strdup.h"
+ #include "escape.h"
++#include "vauth/vauth.h"
+
+ /* The last 3 #include files should be in this order */
+ #include "curl_printf.h"
+@@ -1661,6 +1662,20 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
+ return result;
+ }
+
++#ifndef CURL_DISABLE_PROXY
++static CURLcode setproxy(struct Curl_easy *data, const char *proxy)
++{
++ if((data->set.str[STRING_PROXY] && proxy) &&
++ /* there was one set, is this a new one? */
++ !strcmp(data->set.str[STRING_PROXY], proxy))
++ return CURLE_OK; /* same one as before */
++
++ Curl_auth_digest_cleanup(&data->state.proxydigest);
++ memset(&data->state.authproxy, 0, sizeof(data->state.authproxy));
++ return Curl_setstropt(&data->set.str[STRING_PROXY], proxy);
++}
++#endif
++
+ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
+ char *ptr)
+ {
+@@ -1948,7 +1963,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(&data->set.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 7d085e33fd..ddeafe39ea 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 ca1a0c52f8..369f687ecd 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -208,6 +208,7 @@ test1550 test1551 test1552 test1553 test1554 test1555 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 \
++test1588 \
+ \
+ test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
+ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+diff --git a/tests/data/test1588 b/tests/data/test1588
+new file mode 100644
+index 0000000000..58129cdaf6
+--- /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>
++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 8878ae85fa..c99af637dd 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -75,7 +75,7 @@ TESTS_C = \
+ lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c lib1558.c \
+ lib1559.c lib1560.c lib1564.c lib1565.c \
+ lib1567.c lib1568.c lib1569.c lib1571.c \
+- lib1576.c \
++ lib1576.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..2335a1dd23
+--- /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 res = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(res)
++ goto init_failed;
++#if 0
++ res_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
++ if(res)
++ goto init_failed;
++#endif
++
++ res_easy_setopt(curl, CURLOPT_HEADER, 1L);
++ if(res)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return res; /* failure */
++}
++
++static CURLcode run1588(CURL *curl, const char *url, const char *userpwd,
++ const char *proxy)
++{
++ CURLcode res = CURLE_OK;
++
++ res = init1588(curl, url, userpwd, proxy);
++ if(res)
++ return res;
++
++ return curl_easy_perform(curl);
++}
++
++static CURLcode test_lib1588(char *URL)
++{
++ CURLcode res = 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(res)
++ return res;
++
++ 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);
++
++ res = run1588(curl, URL, proxyuserpws, proxy1_connect);
++ if(res)
++ goto test_cleanup;
++
++ curl_mfprintf(stderr, "lib1588: now we do the request again\n");
++
++ res = 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 res;
++}
diff --git a/0011-curl-8.15.0-CVE-2026-9547.patch b/0011-curl-8.15.0-CVE-2026-9547.patch
deleted file mode 100644
index 8c063f5..0000000
--- a/0011-curl-8.15.0-CVE-2026-9547.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From fadde9f005855a9e3969e5cf08af16be1ea09153 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 4/5] 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 3bae943c7c..11c9c28446 100644
---- a/lib/vssh/libssh.c
-+++ b/lib/vssh/libssh.c
-@@ -423,6 +423,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/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..df2b3d6
--- /dev/null
+++ b/0011-digest-flush-state-on-origin-or-credential-change.patch
@@ -0,0 +1,334 @@
+From ac011d26e15b2b792a4cb474cd4c2ef3237bc676 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Mon, 3 Aug 2026 12:50:36 +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 651bb83403..f82c8d0014 100644
+--- a/lib/http_digest.c
++++ b/lib/http_digest.c
+@@ -104,7 +104,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 = strdup(data->conn->host.name);
++ digest->origin_port = data->conn->remote_port;
++ Curl_safefree(digest->user);
++ digest->user = strdup(data->state.aptr.user ?
++ data->state.aptr.user : "");
++ Curl_safefree(digest->passwd);
++ digest->passwd = 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 e54721dd98..1873e2dc5d 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -317,14 +317,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;
+ #if defined(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 898629a958..10e3cd6c69 100644
+--- a/lib/vauth/digest.c
++++ b/lib/vauth/digest.c
+@@ -997,6 +997,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 28d0b3599c..dcaaaf2616 100644
+--- a/lib/vauth/digest_sspi.c
++++ b/lib/vauth/digest_sspi.c
+@@ -678,6 +678,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 369f687ecd..49684fb735 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -224,7 +224,7 @@ test1660 test1661 test1662 test1663 test1664 \
+ \
+ test1670 test1671 \
+ \
+-test1680 test1681 test1682 test1683 \
++test1680 test1681 test1682 test1683 test1686 \
+ \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 \
+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 c99af637dd..b5760a69b0 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -79,6 +79,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 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 \
+diff --git a/tests/libtest/lib1686.c b/tests/libtest/lib1686.c
+new file mode 100644
+index 0000000000..33dda0fd87
+--- /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(char *hostip)
++{
++ CURL *curl = NULL;
++ CURLcode res = 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);
++ res = curl_easy_perform(curl);
++
++ easy_setopt(curl, CURLOPT_URL, secondurl);
++ res = curl_easy_perform(curl);
++
++ easy_setopt(curl, CURLOPT_USERPWD, "bob:secret");
++ easy_setopt(curl, CURLOPT_URL, secondurl);
++ res = curl_easy_perform(curl);
++ }
++
++test_cleanup:
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ curl_slist_free_all(host);
++ return res;
++}
diff --git a/0012-curl-8.15.0-CVE-2026-8924.patch b/0012-curl-8.15.0-CVE-2026-8924.patch
deleted file mode 100644
index 8650c00..0000000
--- a/0012-curl-8.15.0-CVE-2026-8924.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-From 89f2e2a79823f41f993911a6129704aa8d59d0b1 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 3 Aug 2026 13:00:16 +0200
-Subject: [PATCH 5/5] 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 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 73 insertions(+), 2 deletions(-)
- create mode 100644 tests/data/test1629
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index 2a1e59d9c6..17a6baba0c 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -907,12 +907,21 @@ 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 49684fb735..b789c9f009 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -215,6 +215,7 @@ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
- test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
- test1614 test1615 test1616 \
- test1620 test1621 \
-+test1629 \
- \
- test1630 test1631 test1632 test1633 test1634 test1635 \
- \
-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,61 @@
-+<?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>
-+
-+<datacheck>
-+HTTP/1.1 200 OK
-+Content-Length: 6
-+Set-Cookie: something=1; Domain=co.uk.; Path=/
-+
-+-foo-
-+</datacheck>
-+</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/0012-netrc-scanner-refactor.patch b/0012-netrc-scanner-refactor.patch
new file mode 100644
index 0000000..e8b42d6
--- /dev/null
+++ b/0012-netrc-scanner-refactor.patch
@@ -0,0 +1,122 @@
+From 31df146d17294f32e2b0087be72d130b719e1785 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 3 Aug 2026 12:56:16 +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)
+---
+ lib/netrc.c | 15 ++++++++++++++-
+ tests/unit/unit1304.c | 23 ++++++++++++++++++++---
+ 2 files changed, 34 insertions(+), 4 deletions(-)
+
+diff --git a/lib/netrc.c b/lib/netrc.c
+index bf53fc01e1..e0f0340d50 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 = strdup("");
+ if(!password)
+diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
+index 0d7f04f9de..e691cadf32 100644
+--- a/tests/unit/unit1304.c
++++ b/tests/unit/unit1304.c
+@@ -61,7 +61,7 @@ static CURLcode test_unit1304(char *arg)
+ 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);
+
+@@ -84,7 +84,7 @@ static CURLcode test_unit1304(char *arg)
+ 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);
+
+@@ -96,7 +96,7 @@ static CURLcode test_unit1304(char *arg)
+ 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);
+
+@@ -173,6 +173,23 @@ static CURLcode test_unit1304(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.
++ */
++ free(password);
++ password = NULL;
++ 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/0013-curl-8.15.0-CVE-2026-12064.patch b/0013-curl-8.15.0-CVE-2026-12064.patch
deleted file mode 100644
index c4af9d5..0000000
--- a/0013-curl-8.15.0-CVE-2026-12064.patch
+++ /dev/null
@@ -1,256 +0,0 @@
-From a9223d620c41600e07ff65c4feaa6885bcdc6bdd 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 | 41 ++++++++++++++++-------
- tests/data/Makefile.am | 4 +--
- tests/data/test1724 | 53 ++++++++++++++++++++++++++++++
- tests/data/test1725 | 29 ++++++++++++++++
- tests/data/test2036 | 26 +++++++++++++++
- 6 files changed, 144 insertions(+), 15 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 8e4af65bae..6b6568b7b3 100644
---- a/src/config2setopts.c
-+++ b/src/config2setopts.c
-@@ -138,15 +138,31 @@ static CURLcode url_proto_and_rewrite(char **url,
- DEBUGASSERT(url && *url);
- if(uh) {
- char *schemep = NULL;
-- if(!curl_url_set(uh, CURLUPART_URL, *url,
-- CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME) &&
-- !curl_url_get(uh, CURLUPART_SCHEME, &schemep,
-- CURLU_DEFAULT_SCHEME)) {
--#ifdef CURL_DISABLE_IPFS
-- (void)config;
--#else
-- if(curl_strequal(schemep, proto_ipfs) ||
-- curl_strequal(schemep, proto_ipns)) {
-+ CURLUcode uc =
-+ curl_url_set(uh, CURLUPART_URL, *url,
-+ CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME);
-+ if(!uc) {
-+ 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 {
-+ 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))
-@@ -156,12 +172,13 @@ static CURLcode url_proto_and_rewrite(char **url,
- if(result)
- config->synthetic_error = TRUE;
- }
-- else
- #endif /* !CURL_DISABLE_IPFS */
-- proto = proto_token(schemep);
--
-+ 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;
- curl_url_cleanup(uh);
- }
- else
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index b789c9f009..c1c25f56cc 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -228,7 +228,7 @@ test1670 test1671 \
- test1680 test1681 test1682 test1683 test1686 \
- \
- test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
--test1708 test1709 test1710 \
-+test1708 test1709 test1710 test1724 test1725 \
- \
- test1800 test1801 test1850 \
- \
-@@ -246,7 +246,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/0013-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch b/0013-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
new file mode 100644
index 0000000..e0d7477
--- /dev/null
+++ b/0013-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
@@ -0,0 +1,29 @@
+From 36312c9d6842ff5fb7ea754371704a4fa711ba27 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 3bae943c7c..11c9c28446 100644
+--- a/lib/vssh/libssh.c
++++ b/lib/vssh/libssh.c
+@@ -423,6 +423,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/0014-cookie-trim-trailing-dots-when-checking-PSL.patch b/0014-cookie-trim-trailing-dots-when-checking-PSL.patch
new file mode 100644
index 0000000..c55b276
--- /dev/null
+++ b/0014-cookie-trim-trailing-dots-when-checking-PSL.patch
@@ -0,0 +1,124 @@
+From 5171cf3847d23ef5dd07f03c96c0a0583727d31c Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 3 Aug 2026 13:00:16 +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 | 61 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 73 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test1629
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index 2a1e59d9c6..17a6baba0c 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -907,12 +907,21 @@ 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 49684fb735..b789c9f009 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -215,6 +215,7 @@ test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
+ test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
+ test1614 test1615 test1616 \
+ test1620 test1621 \
++test1629 \
+ \
+ test1630 test1631 test1632 test1633 test1634 test1635 \
+ \
+diff --git a/tests/data/test1629 b/tests/data/test1629
+new file mode 100644
+index 0000000000..bfbd16aa29
+--- /dev/null
++++ b/tests/data/test1629
+@@ -0,0 +1,61 @@
++<?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>
++
++<datacheck>
++HTTP/1.1 200 OK
++Content-Length: 6
++Set-Cookie: something=1; Domain=co.uk.; Path=/
++
++-foo-
++</datacheck>
++</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/0014-curl-8.15.0-CVE-2026-8286.patch b/0014-curl-8.15.0-CVE-2026-8286.patch
deleted file mode 100644
index ad0910c..0000000
--- a/0014-curl-8.15.0-CVE-2026-8286.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From f44eeb28658b43d61eb81dfaef47eba70770283e Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Thu, 7 May 2026 10:30:07 +0200
-Subject: [PATCH] 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 fd3bb575c7..b04ed7e10c 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -803,7 +803,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 `require_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);
-@@ -954,6 +958,9 @@ static bool url_match_ssl_use(struct connectdata *conn,
- if(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;
- }
-
-@@ -1144,8 +1151,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
-@@ -1416,6 +1423,8 @@ 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/0015-config2setopts-use-default-protocol-properly.patch b/0015-config2setopts-use-default-protocol-properly.patch
new file mode 100644
index 0000000..e48de97
--- /dev/null
+++ b/0015-config2setopts-use-default-protocol-properly.patch
@@ -0,0 +1,253 @@
+From 7ce85e8ae14a22fcbf35b151ed20f26ea39f6455 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 | 41 ++++++++++++++++-------
+ tests/data/Makefile.am | 4 +--
+ tests/data/test1724 | 53 ++++++++++++++++++++++++++++++
+ tests/data/test1725 | 29 ++++++++++++++++
+ tests/data/test2036 | 26 +++++++++++++++
+ 6 files changed, 144 insertions(+), 15 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 8e4af65bae..6b6568b7b3 100644
+--- a/src/config2setopts.c
++++ b/src/config2setopts.c
+@@ -138,15 +138,31 @@ static CURLcode url_proto_and_rewrite(char **url,
+ DEBUGASSERT(url && *url);
+ if(uh) {
+ char *schemep = NULL;
+- if(!curl_url_set(uh, CURLUPART_URL, *url,
+- CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME) &&
+- !curl_url_get(uh, CURLUPART_SCHEME, &schemep,
+- CURLU_DEFAULT_SCHEME)) {
+-#ifdef CURL_DISABLE_IPFS
+- (void)config;
+-#else
+- if(curl_strequal(schemep, proto_ipfs) ||
+- curl_strequal(schemep, proto_ipns)) {
++ CURLUcode uc =
++ curl_url_set(uh, CURLUPART_URL, *url,
++ CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME);
++ if(!uc) {
++ 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 {
++ 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))
+@@ -156,12 +172,13 @@ static CURLcode url_proto_and_rewrite(char **url,
+ if(result)
+ config->synthetic_error = TRUE;
+ }
+- else
+ #endif /* !CURL_DISABLE_IPFS */
+- proto = proto_token(schemep);
+-
++ 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;
+ curl_url_cleanup(uh);
+ }
+ else
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index b789c9f009..c1c25f56cc 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -228,7 +228,7 @@ test1670 test1671 \
+ test1680 test1681 test1682 test1683 test1686 \
+ \
+ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
+-test1708 test1709 test1710 \
++test1708 test1709 test1710 test1724 test1725 \
+ \
+ test1800 test1801 test1850 \
+ \
+@@ -246,7 +246,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/0015-curl-8.15.0-CVE-2026-8925.patch b/0015-curl-8.15.0-CVE-2026-8925.patch
deleted file mode 100644
index e79b4f4..0000000
--- a/0015-curl-8.15.0-CVE-2026-8925.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 56a1fac81fa0d438f04ba114a5beae65a26d66b4 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 a0b1adc9ed..64f04983e1 100644
---- a/docs/INTERNALS.md
-+++ b/docs/INTERNALS.md
-@@ -32,6 +32,7 @@ versions of libs and build tools.
- - c-ares 1.6.0
- - libssh 0.9.0
- - libidn2 2.0.0
-+ - libgsasl 1.6.0
- - wolfSSL 3.4.6
- - OpenLDAP 2.0
- - MIT Kerberos 1.2.4
-diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c
-index 3684c8f4b2..602160141b 100644
---- a/lib/vauth/gsasl.c
-+++ b/lib/vauth/gsasl.c
-@@ -36,6 +36,10 @@
-
- #include <gsasl.h>
-
-+#if GSASL_VERSION_NUMBER < 0x010600
-+#error "requires libgsasl 1.6.0+"
-+#endif
-+
- /* The last 3 #include files should be in this order */
- #include "../curl_printf.h"
- #include "../curl_memory.h"
-@@ -56,6 +60,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/0016-curl-8.15.0-CVE-2026-8927.patch b/0016-curl-8.15.0-CVE-2026-8927.patch
deleted file mode 100644
index 7146063..0000000
--- a/0016-curl-8.15.0-CVE-2026-8927.patch
+++ /dev/null
@@ -1,337 +0,0 @@
-From 379e6dd60d9961d073e09bad5ae2052047545049 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, 238 insertions(+), 1 deletion(-)
- create mode 100644 tests/data/test1647
- create mode 100644 tests/libtest/lib1647.c
-
-diff --git a/lib/url.c b/lib/url.c
-index b04ed7e10c..68a564330f 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -84,6 +84,7 @@
- #include "http_digest.h"
- #include "http_negotiate.h"
- #include "select.h"
-+#include "vauth/vauth.h"
- #include "multiif.h"
- #include "easyif.h"
- #include "speedcheck.h"
-@@ -344,6 +346,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
-+ free(data->state.envproxy);
-+#endif
- free(data);
- return CURLE_OK;
- }
-@@ -2647,6 +2652,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);
-+ free(data->state.envproxy);
-+ data->state.envproxy = 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 1873e2dc5d..d24989f3c9 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -1042,6 +1042,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 c1c25f56cc..f18dba0537 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -217,7 +217,7 @@ test1614 test1615 test1616 \
- test1620 test1621 \
- test1629 \
- \
--test1630 test1631 test1632 test1633 test1634 test1635 \
-+test1630 test1631 test1632 test1633 test1634 test1635 test1647 \
- \
- test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
- test1658 \
-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 b5760a69b0..c73e2c2ebd 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -78,6 +78,7 @@ TESTS_C = \
- lib1576.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 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 res = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 0L);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 0L);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(res)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return res; /* 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(char *URL)
-+{
-+ CURLcode res = CURLE_OK;
-+ CURL *curl = NULL;
-+
-+ res_global_init(CURL_GLOBAL_ALL);
-+ if(res)
-+ return res;
-+
-+ 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);
-+ res = run1647(curl, URL, libtest_arg3);
-+ if(res)
-+ goto test_cleanup;
-+
-+ curl_mprintf("--- Then get '%s'\n", libtest_arg2);
-+ res = run1647(curl, libtest_arg2, libtest_arg4);
-+
-+test_cleanup:
-+
-+ /* proper cleanup sequence - type PB */
-+
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ return res;
-+}
---
-2.55.0
-
diff --git a/0016-url-fix-connection-reuse-for-starttls-protocols.patch b/0016-url-fix-connection-reuse-for-starttls-protocols.patch
new file mode 100644
index 0000000..0871572
--- /dev/null
+++ b/0016-url-fix-connection-reuse-for-starttls-protocols.patch
@@ -0,0 +1,64 @@
+From f7412d734e47aa89092b937f18854d54288946d1 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Thu, 7 May 2026 10:30:07 +0200
+Subject: [PATCH] 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 fd3bb575c7..b04ed7e10c 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -803,7 +803,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 `require_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);
+@@ -954,6 +958,9 @@ static bool url_match_ssl_use(struct connectdata *conn,
+ if(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;
+ }
+
+@@ -1144,8 +1151,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
+@@ -1416,6 +1423,8 @@ 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.15.0-CVE-2026-9545.patch b/0017-curl-8.15.0-CVE-2026-9545.patch
deleted file mode 100644
index 8df629f..0000000
--- a/0017-curl-8.15.0-CVE-2026-9545.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From b8c9fd97c1786c2cd47faa2d3b646c134f41db54 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 | 14 +++++++++++---
- 1 file changed, 11 insertions(+), 3 deletions(-)
-
-diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c
-index 69d54ecce2..24fe7ec0b0 100644
---- a/lib/vquic/curl_ngtcp2.c
-+++ b/lib/vquic/curl_ngtcp2.c
-@@ -463,7 +463,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 = curlx_now();
- ctx->tls_handshake_complete = TRUE;
-@@ -472,6 +472,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;
-+
- CURL_TRC_CF(data, cf, "handshake complete after %dms",
- (int)curlx_timediff(ctx->handshake_at, ctx->started_at));
- /* In case of earlydata, where we simulate being connected, update
-@@ -1329,9 +1332,10 @@ 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;
-
-- CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %dm, %zu",
--
-+ CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %d, %zu",
- stream ? stream->id : -1, blen, result, *pnread);
- CF_DATA_RESTORE(cf, save);
- return result;
-@@ -1657,6 +1661,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;
-
- CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send(len=%zu) -> %d, %zu",
- stream ? stream->id : -1, len, result, *pnwritten);
-@@ -2565,6 +2571,8 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf,
- }
-
- out:
-+ if(ctx->tls_vrfy_result)
-+ result = ctx->tls_vrfy_result;
- if(result == CURLE_RECV_ERROR && ctx->qconn &&
- ngtcp2_conn_in_draining_period(ctx->qconn)) {
- /* When a QUIC server instance is shutting down, it may send us a
---
-2.55.0
-
diff --git a/0017-gsasl-fix-potential-double-free.patch b/0017-gsasl-fix-potential-double-free.patch
new file mode 100644
index 0000000..5192f4f
--- /dev/null
+++ b/0017-gsasl-fix-potential-double-free.patch
@@ -0,0 +1,55 @@
+From 5a2944cb2359ed6cf4f3eb819dfa16f771ed6cd2 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 a0b1adc9ed..64f04983e1 100644
+--- a/docs/INTERNALS.md
++++ b/docs/INTERNALS.md
+@@ -32,6 +32,7 @@ versions of libs and build tools.
+ - c-ares 1.6.0
+ - libssh 0.9.0
+ - libidn2 2.0.0
++ - libgsasl 1.6.0
+ - wolfSSL 3.4.6
+ - OpenLDAP 2.0
+ - MIT Kerberos 1.2.4
+diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c
+index 3684c8f4b2..602160141b 100644
+--- a/lib/vauth/gsasl.c
++++ b/lib/vauth/gsasl.c
+@@ -36,6 +36,10 @@
+
+ #include <gsasl.h>
+
++#if GSASL_VERSION_NUMBER < 0x010600
++#error "requires libgsasl 1.6.0+"
++#endif
++
+ /* The last 3 #include files should be in this order */
+ #include "../curl_printf.h"
+ #include "../curl_memory.h"
+@@ -56,6 +60,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/0018-curl-8.15.0-CVE-2026-9080.patch b/0018-curl-8.15.0-CVE-2026-9080.patch
deleted file mode 100644
index f1cdd96..0000000
--- a/0018-curl-8.15.0-CVE-2026-9080.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From 78559f57f4591e43daefbc8982866699988f9575 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 | 21 +++++++++++++++++++--
- 1 file changed, 19 insertions(+), 2 deletions(-)
-
-diff --git a/lib/multi_ev.c b/lib/multi_ev.c
-index 0b4c472849..6cd3a4ee4a 100644
---- a/lib/multi_ev.c
-+++ b/lib/multi_ev.c
-@@ -53,6 +53,8 @@ static void mev_in_callback(struct Curl_multi *multi, bool value)
-
- #define CURL_MEV_CONN_HASH_SIZE 3
-
-+#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)
- */
-@@ -64,6 +66,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
- };
-
- static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
-@@ -85,6 +90,9 @@ static void mev_sh_entry_dtor(void *freethis)
- {
- struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
- Curl_uint_spbset_destroy(&entry->xfers);
-+#ifdef DEBUGBUILD
-+ entry->magic = 0;
-+#endif
- free(entry);
- }
-
-@@ -123,7 +131,9 @@ mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s)
- 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 */
- }
-
-@@ -233,6 +243,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;
-
-@@ -287,7 +298,13 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
- 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->action = (unsigned int)comboaction;
-+ }
- return CURLM_OK;
- }
-
---
-2.55.0
-
diff --git a/0018-url-detect-proxy-changes-read-from-environment.patch b/0018-url-detect-proxy-changes-read-from-environment.patch
new file mode 100644
index 0000000..f8d2511
--- /dev/null
+++ b/0018-url-detect-proxy-changes-read-from-environment.patch
@@ -0,0 +1,334 @@
+From 59abee3274d1c82a059cfa338bdc963e8c4a219d 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, 238 insertions(+), 1 deletion(-)
+ create mode 100644 tests/data/test1647
+ create mode 100644 tests/libtest/lib1647.c
+
+diff --git a/lib/url.c b/lib/url.c
+index b04ed7e10c..a652b82d36 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -84,6 +84,7 @@
+ #include "http_digest.h"
+ #include "http_negotiate.h"
+ #include "select.h"
++#include "vauth/vauth.h"
+ #include "multiif.h"
+ #include "easyif.h"
+ #include "speedcheck.h"
+@@ -344,6 +345,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
++ free(data->state.envproxy);
++#endif
+ free(data);
+ return CURLE_OK;
+ }
+@@ -2647,6 +2651,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);
++ free(data->state.envproxy);
++ data->state.envproxy = 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 1873e2dc5d..d24989f3c9 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -1042,6 +1042,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 c1c25f56cc..f18dba0537 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -217,7 +217,7 @@ test1614 test1615 test1616 \
+ test1620 test1621 \
+ test1629 \
+ \
+-test1630 test1631 test1632 test1633 test1634 test1635 \
++test1630 test1631 test1632 test1633 test1634 test1635 test1647 \
+ \
+ test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
+ test1658 \
+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 b5760a69b0..c73e2c2ebd 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -78,6 +78,7 @@ TESTS_C = \
+ lib1576.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 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..a37f293a58
+--- /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 res = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYPEER, 0L);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY_SSL_VERIFYHOST, 0L);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(res)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return res; /* 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(char *URL)
++{
++ CURLcode res = CURLE_OK;
++ CURL *curl = NULL;
++
++ res_global_init(CURL_GLOBAL_ALL);
++ if(res)
++ return res;
++
++ 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);
++ res = run1647(curl, URL, libtest_arg3);
++ if(res)
++ goto test_cleanup;
++
++ curl_mprintf("--- Then get '%s'\n", libtest_arg2);
++ res = run1647(curl, libtest_arg2, libtest_arg4);
++
++test_cleanup:
++
++ /* proper cleanup sequence - type PB */
++
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ return res;
++}
diff --git a/0019-curl-8.15.0-CVE-2026-10536.patch b/0019-curl-8.15.0-CVE-2026-10536.patch
deleted file mode 100644
index bac657e..0000000
--- a/0019-curl-8.15.0-CVE-2026-10536.patch
+++ /dev/null
@@ -1,345 +0,0 @@
-From 14d00f9a97f60e34b0ed9d0a21dfab6df96ea468 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/urldata.h | 8 --
- 9 files changed, 34 insertions(+), 130 deletions(-)
-
-diff --git a/docs/libcurl/curl_easy_setopt.md b/docs/libcurl/curl_easy_setopt.md
-index ccca56de6b..4b06a8e0f6 100644
---- a/docs/libcurl/curl_easy_setopt.md
-+++ b/docs/libcurl/curl_easy_setopt.md
-@@ -1158,11 +1158,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 4603dd322c..63e1414cc9 100644
---- a/docs/libcurl/symbols-in-versions
-+++ b/docs/libcurl/symbols-in-versions
-@@ -865,8 +865,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 7ef5b99349..6f74573f41 100644
---- a/include/curl/curl.h
-+++ b/include/curl/curl.h
-@@ -1976,10 +1976,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 36dca426de..cb84d427b5 100644
---- a/lib/http2.c
-+++ b/lib/http2.c
-@@ -1931,16 +1931,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;
- }
-
-@@ -1958,13 +1954,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,
-@@ -2256,7 +2250,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 0ec31908a1..7d3c0a1a7b 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -1647,13 +1647,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 a652b82d36..6a429a1ce9 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -130,12 +130,6 @@
- #include "curl_memory.h"
- #include "memdebug.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.
-@@ -302,8 +296,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
- Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
- Curl_resolv_unlink(data, &data->state.dns[1]);
-
-- 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);
-@@ -4061,96 +4053,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;
-- 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 = 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/urldata.h b/lib/urldata.h
-index d24989f3c9..95f2efc55e 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -945,15 +945,7 @@ struct Curl_data_prio_node {
- * 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/0019-ngtcp2-fail-handshake-directly.patch b/0019-ngtcp2-fail-handshake-directly.patch
new file mode 100644
index 0000000..01a0c86
--- /dev/null
+++ b/0019-ngtcp2-fail-handshake-directly.patch
@@ -0,0 +1,69 @@
+From f8544a2bda63d9d4abc8a332334587ddfff03aff 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 | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c
+index 69d54ecce2..24fe7ec0b0 100644
+--- a/lib/vquic/curl_ngtcp2.c
++++ b/lib/vquic/curl_ngtcp2.c
+@@ -463,7 +463,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 = curlx_now();
+ ctx->tls_handshake_complete = TRUE;
+@@ -472,6 +472,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;
++
+ CURL_TRC_CF(data, cf, "handshake complete after %dms",
+ (int)curlx_timediff(ctx->handshake_at, ctx->started_at));
+ /* In case of earlydata, where we simulate being connected, update
+@@ -1329,9 +1332,10 @@ 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;
+
+- CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %dm, %zu",
+-
++ CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %d, %zu",
+ stream ? stream->id : -1, blen, result, *pnread);
+ CF_DATA_RESTORE(cf, save);
+ return result;
+@@ -1657,6 +1661,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;
+
+ CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send(len=%zu) -> %d, %zu",
+ stream ? stream->id : -1, len, result, *pnwritten);
+@@ -2565,6 +2571,8 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf,
+ }
+
+ out:
++ if(ctx->tls_vrfy_result)
++ result = ctx->tls_vrfy_result;
+ if(result == CURLE_RECV_ERROR && ctx->qconn &&
+ ngtcp2_conn_in_draining_period(ctx->qconn)) {
+ /* When a QUIC server instance is shutting down, it may send us a
diff --git a/0020-curl-8.15.0-CVE-2026-9079.patch b/0020-curl-8.15.0-CVE-2026-9079.patch
deleted file mode 100644
index 8e0a2e6..0000000
--- a/0020-curl-8.15.0-CVE-2026-9079.patch
+++ /dev/null
@@ -1,286 +0,0 @@
-From 8f84686f10a2c82a55d447e2e322944614ab3785 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 7d3c0a1a7b..8be5eef059 100644
---- a/lib/setopt.c
-+++ b/lib/setopt.c
-@@ -2162,16 +2162,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(data->set.str[STRING_PROXYUSERNAME]);
-- result = Curl_urldecode(u, 0, &data->set.str[STRING_PROXYUSERNAME], NULL,
-- REJECT_ZERO);
-- }
-- if(!result && p) {
- Curl_safefree(data->set.str[STRING_PROXYPASSWORD]);
-+ if(u)
-+ result = Curl_urldecode(u, 0, &data->set.str[STRING_PROXYUSERNAME],
-+ NULL, REJECT_ZERO);
-+ }
-+ if(!result && p)
- result = Curl_urldecode(p, 0, &data->set.str[STRING_PROXYPASSWORD], NULL,
- REJECT_ZERO);
-- }
- free(u);
- free(p);
- }
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index f18dba0537..6a60f1ce4f 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -217,7 +217,7 @@ test1614 test1615 test1616 \
- test1620 test1621 \
- test1629 \
- \
--test1630 test1631 test1632 test1633 test1634 test1635 test1647 \
-+test1630 test1631 test1632 test1633 test1634 test1635 test1647 test1648 \
- \
- test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
- test1658 \
-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 c73e2c2ebd..6ae5bb6d04 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -78,7 +78,7 @@ TESTS_C = \
- lib1576.c lib1588.c \
- lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
- lib1598.c lib1599.c \
-- lib1647.c \
-+ lib1647.c lib1648.c \
- lib1662.c \
- lib1686.c \
- lib1900.c lib1901.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 res = CURLE_OK;
-+
-+ res_easy_setopt(curl, CURLOPT_URL, url);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
-+ if(res)
-+ goto init_failed;
-+
-+ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-+ if(res)
-+ goto init_failed;
-+
-+ return CURLE_OK; /* success */
-+
-+init_failed:
-+ return res; /* failure */
-+}
-+
-+static CURLcode run1648(CURL *curl, const char *url, const char *userpwd)
-+{
-+ CURLcode res = CURLE_OK;
-+
-+ res = init1648(curl, url, userpwd);
-+ if(res)
-+ return res;
-+
-+ 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(char *hostip)
-+{
-+ CURLcode res = 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(res)
-+ return res;
-+
-+ 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);
-+ res = run1648(curl, GET_THIS, proxy1_connect);
-+ if(res)
-+ goto test_cleanup;
-+
-+ easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
-+
-+ curl_mprintf("--- Then over '%s'\n", proxy2_connect);
-+ res = 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 res;
-+}
---
-2.55.0
-
diff --git a/0020-multi-handle-pause-in-multi-socket-callback.patch b/0020-multi-handle-pause-in-multi-socket-callback.patch
new file mode 100644
index 0000000..20151b9
--- /dev/null
+++ b/0020-multi-handle-pause-in-multi-socket-callback.patch
@@ -0,0 +1,87 @@
+From a29b135684dbd92b606c3dd8acf112a519000c6e 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 | 21 +++++++++++++++++++--
+ 1 file changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/lib/multi_ev.c b/lib/multi_ev.c
+index 0b4c472849..6cd3a4ee4a 100644
+--- a/lib/multi_ev.c
++++ b/lib/multi_ev.c
+@@ -53,6 +53,8 @@ static void mev_in_callback(struct Curl_multi *multi, bool value)
+
+ #define CURL_MEV_CONN_HASH_SIZE 3
+
++#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)
+ */
+@@ -64,6 +66,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
+ };
+
+ static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
+@@ -85,6 +90,9 @@ static void mev_sh_entry_dtor(void *freethis)
+ {
+ struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
+ Curl_uint_spbset_destroy(&entry->xfers);
++#ifdef DEBUGBUILD
++ entry->magic = 0;
++#endif
+ free(entry);
+ }
+
+@@ -123,7 +131,9 @@ mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s)
+ 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 */
+ }
+
+@@ -233,6 +243,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;
+
+@@ -287,7 +298,13 @@ static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
+ 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->action = (unsigned int)comboaction;
++ }
+ return CURLM_OK;
+ }
+
diff --git a/0021-curl-8.15.0-CVE-2026-8458.patch b/0021-curl-8.15.0-CVE-2026-8458.patch
deleted file mode 100644
index 6d7ac5b..0000000
--- a/0021-curl-8.15.0-CVE-2026-8458.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-From ecc8e735a6ed5602f5de508d6525109da2e2b126 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Thu, 27 Aug 2026 17:10:04 +0200
-Subject: [PATCH] url: add SASL service name to connection reuse matching
-
-Store the SASL service name (set via CURLOPT_SERVICE_NAME and
-CURLOPT_PROXY_SERVICE_NAME) on the connection and compare it during
-connection reuse matching for Negotiate and NTLM authentication.
-
-Without this check, libcurl could wrongfully reuse an existing
-connection authenticated with a different service name, when the
-same server, username and password are used.
-
-This is an adapted backport of upstream commit 5e99b73cf441d9c369768b9cd
-which adds sasl_service to struct Curl_creds. Since curl 8.15.0
-predates the Curl_creds infrastructure, this fix stores the service
-name directly on struct connectdata instead, following the same
-pattern as sasl_authzid and oauth_bearer.
-
-(cherry picked from commit 5e99b73cf441d9c369768b9cd)
-Co-authored-by: Cursor <cursoragent@cursor.com>
----
- lib/url.c | 35 +++++++++++++++++++++++++++++++----
- lib/urldata.h | 2 ++
- 2 files changed, 33 insertions(+), 4 deletions(-)
-
-diff --git a/lib/url.c b/lib/url.c
-index 6a429a1ce9..a233c9831b 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -589,6 +589,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_sasl_service);
- Curl_safefree(conn->host.rawalloc); /* hostname buffer */
- Curl_safefree(conn->conn_to_host.rawalloc); /* hostname buffer */
- Curl_safefree(conn->hostname_resolve);
-@@ -1170,7 +1172,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 */
-@@ -1195,7 +1198,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_sasl_service,
-+ conn->proxy_sasl_service))
- return FALSE;
- }
- else if(conn->proxy_ntlm_state != NTLMSTATE_NONE) {
-@@ -1236,7 +1241,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) {
-@@ -1255,7 +1261,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_sasl_service,
-+ conn->proxy_sasl_service))
- return FALSE;
- }
- else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
-@@ -3596,6 +3604,25 @@ static CURLcode create_conn(struct Curl_easy *data,
- }
- }
-
-+ if(data->set.str[STRING_SERVICE_NAME]) {
-+ conn->sasl_service = strdup(data->set.str[STRING_SERVICE_NAME]);
-+ if(!conn->sasl_service) {
-+ result = CURLE_OUT_OF_MEMORY;
-+ goto out;
-+ }
-+ }
-+
-+#ifndef CURL_DISABLE_PROXY
-+ if(data->set.str[STRING_PROXY_SERVICE_NAME]) {
-+ conn->proxy_sasl_service =
-+ strdup(data->set.str[STRING_PROXY_SERVICE_NAME]);
-+ if(!conn->proxy_sasl_service) {
-+ result = CURLE_OUT_OF_MEMORY;
-+ goto out;
-+ }
-+ }
-+#endif
-+
- #ifdef USE_UNIX_SOCKETS
- if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
- conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
-diff --git a/lib/urldata.h b/lib/urldata.h
-index 95f2efc55e..12883b86c0 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -687,6 +687,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 for auth, allocated */
-+ char *proxy_sasl_service; /* SASL service name for proxy auth, allocated */
- struct curltime created; /* creation time */
- struct curltime lastused; /* when returned to the connection poolas idle */
- curl_socket_t sock[2]; /* two sockets, the second is used for the data
---
-2.55.0
-
diff --git a/0021-http2-remove-stream-dependency-tracking.patch b/0021-http2-remove-stream-dependency-tracking.patch
new file mode 100644
index 0000000..69f1c6a
--- /dev/null
+++ b/0021-http2-remove-stream-dependency-tracking.patch
@@ -0,0 +1,342 @@
+From 8eb3ea12d2c437df87450f0cf3ed8c1965ec58f3 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/urldata.h | 8 --
+ 9 files changed, 34 insertions(+), 130 deletions(-)
+
+diff --git a/docs/libcurl/curl_easy_setopt.md b/docs/libcurl/curl_easy_setopt.md
+index ccca56de6b..4b06a8e0f6 100644
+--- a/docs/libcurl/curl_easy_setopt.md
++++ b/docs/libcurl/curl_easy_setopt.md
+@@ -1158,11 +1158,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 4603dd322c..63e1414cc9 100644
+--- a/docs/libcurl/symbols-in-versions
++++ b/docs/libcurl/symbols-in-versions
+@@ -865,8 +865,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 7ef5b99349..6f74573f41 100644
+--- a/include/curl/curl.h
++++ b/include/curl/curl.h
+@@ -1976,10 +1976,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 36dca426de..cb84d427b5 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -1931,16 +1931,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;
+ }
+
+@@ -1958,13 +1954,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,
+@@ -2256,7 +2250,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 0ec31908a1..7d3c0a1a7b 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -1647,13 +1647,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 a652b82d36..6a429a1ce9 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -130,12 +130,6 @@
+ #include "curl_memory.h"
+ #include "memdebug.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.
+@@ -302,8 +296,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
+ Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
+ Curl_resolv_unlink(data, &data->state.dns[1]);
+
+- 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);
+@@ -4061,96 +4053,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;
+- 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 = 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/urldata.h b/lib/urldata.h
+index d24989f3c9..95f2efc55e 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -945,15 +945,7 @@ struct Curl_data_prio_node {
+ * 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/0022-curl-8.15.0-CVE-2026-80255.patch b/0022-curl-8.15.0-CVE-2026-80255.patch
deleted file mode 100644
index f7765af..0000000
--- a/0022-curl-8.15.0-CVE-2026-80255.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-From 9f56553df92b6825e4aabf9ea9d21b6529764bff Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 27 Aug 2026 08:33:30 +0200
-Subject: [PATCH 1/2] cookie: improve TAB handling
-
-For entries with a leading tab. Verified in test 2885.
-
-Reported-by: Stanislav Fort
-Closes #22699
-
-(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
----
- lib/cookie.c | 6 ++---
- tests/data/Makefile.am | 2 +-
- tests/data/test2885 | 52 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 56 insertions(+), 4 deletions(-)
- create mode 100644 tests/data/test2885
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index 17a6baba0c..7faa109947 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -437,9 +437,9 @@ static bool bad_domain(const char *domain, size_t len)
- static bool invalid_octets(const char *ptr)
- {
- const unsigned char *p = (const unsigned char *)ptr;
-- /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */
-+ /* Reject all bytes \x01 - \x1f + \x7f */
- while(*p) {
-- if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f))
-+ if((*p < 0x20) || (*p == 0x7f))
- return TRUE;
- p++;
- }
-@@ -497,7 +497,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 done = FALSE;
- bool sep = FALSE;
- curlx_str_trimblanks(&name);
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 6a60f1ce4f..4888dec3ea 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -270,7 +270,7 @@ test2600 test2601 test2602 test2603 test2604 \
- 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="yes">
-+HTTP/1.1 200 OK
-+Content-Length: 0
-+Set-Cookie: thisis=SECRET; Secure
-+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="yes">
-+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 FALSE / TRUE 0 also notab
-+cookie.example FALSE / TRUE 0 thisis SECRET
-+</file>
-+</verify>
-+</testcase>
---
-2.55.0
-
diff --git a/0022-setopt-clear-proxy-auth-properly-on-NULL.patch b/0022-setopt-clear-proxy-auth-properly-on-NULL.patch
new file mode 100644
index 0000000..764d7a0
--- /dev/null
+++ b/0022-setopt-clear-proxy-auth-properly-on-NULL.patch
@@ -0,0 +1,283 @@
+From 2648283012b0709af713f12b7d858a89e5dc7ce3 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 7d3c0a1a7b..8be5eef059 100644
+--- a/lib/setopt.c
++++ b/lib/setopt.c
+@@ -2162,16 +2162,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(data->set.str[STRING_PROXYUSERNAME]);
+- result = Curl_urldecode(u, 0, &data->set.str[STRING_PROXYUSERNAME], NULL,
+- REJECT_ZERO);
+- }
+- if(!result && p) {
+ Curl_safefree(data->set.str[STRING_PROXYPASSWORD]);
++ if(u)
++ result = Curl_urldecode(u, 0, &data->set.str[STRING_PROXYUSERNAME],
++ NULL, REJECT_ZERO);
++ }
++ if(!result && p)
+ result = Curl_urldecode(p, 0, &data->set.str[STRING_PROXYPASSWORD], NULL,
+ REJECT_ZERO);
+- }
+ free(u);
+ free(p);
+ }
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index f18dba0537..6a60f1ce4f 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -217,7 +217,7 @@ test1614 test1615 test1616 \
+ test1620 test1621 \
+ test1629 \
+ \
+-test1630 test1631 test1632 test1633 test1634 test1635 test1647 \
++test1630 test1631 test1632 test1633 test1634 test1635 test1647 test1648 \
+ \
+ test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
+ test1658 \
+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 c73e2c2ebd..6ae5bb6d04 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -78,7 +78,7 @@ TESTS_C = \
+ lib1576.c lib1588.c \
+ lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c \
+ lib1598.c lib1599.c \
+- lib1647.c \
++ lib1647.c lib1648.c \
+ lib1662.c \
+ lib1686.c \
+ lib1900.c lib1901.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..25317c3138
+--- /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 res = CURLE_OK;
++
++ res_easy_setopt(curl, CURLOPT_URL, url);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_PROXY, proxy);
++ if(res)
++ goto init_failed;
++
++ res_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
++ if(res)
++ goto init_failed;
++
++ return CURLE_OK; /* success */
++
++init_failed:
++ return res; /* failure */
++}
++
++static CURLcode run1648(CURL *curl, const char *url, const char *userpwd)
++{
++ CURLcode res = CURLE_OK;
++
++ res = init1648(curl, url, userpwd);
++ if(res)
++ return res;
++
++ 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(char *hostip)
++{
++ CURLcode res = 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(res)
++ return res;
++
++ 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);
++ res = run1648(curl, GET_THIS, proxy1_connect);
++ if(res)
++ goto test_cleanup;
++
++ easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
++
++ curl_mprintf("--- Then over '%s'\n", proxy2_connect);
++ res = 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 res;
++}
diff --git a/0023-curl-8.15.0-CVE-2026-80229.patch b/0023-curl-8.15.0-CVE-2026-80229.patch
deleted file mode 100644
index c5690ba..0000000
--- a/0023-curl-8.15.0-CVE-2026-80229.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 67b6f41077b7681c5315e338a29899fcac59a912 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 b0f91cf400..05210c8316 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4030,6 +4030,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/0023-url-add-SASL-service-name-to-connection-reuse-matchi.patch b/0023-url-add-SASL-service-name-to-connection-reuse-matchi.patch
new file mode 100644
index 0000000..0fc4610
--- /dev/null
+++ b/0023-url-add-SASL-service-name-to-connection-reuse-matchi.patch
@@ -0,0 +1,120 @@
+From 2723bc33cd43cfd40ea880cdad979a93d060c923 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Thu, 27 Aug 2026 17:10:04 +0200
+Subject: [PATCH] url: add SASL service name to connection reuse matching
+
+Store the SASL service name (set via CURLOPT_SERVICE_NAME and
+CURLOPT_PROXY_SERVICE_NAME) on the connection and compare it during
+connection reuse matching for Negotiate and NTLM authentication.
+
+Without this check, libcurl could wrongfully reuse an existing
+connection authenticated with a different service name, when the
+same server, username and password are used.
+
+This is an adapted backport of upstream commit 5e99b73cf441d9c369768b9cd
+which adds sasl_service to struct Curl_creds. Since curl 8.15.0
+predates the Curl_creds infrastructure, this fix stores the service
+name directly on struct connectdata instead, following the same
+pattern as sasl_authzid and oauth_bearer.
+
+(cherry picked from commit 5e99b73cf441d9c369768b9cd)
+Co-authored-by: Cursor <cursoragent@cursor.com>
+---
+ lib/url.c | 35 +++++++++++++++++++++++++++++++----
+ lib/urldata.h | 2 ++
+ 2 files changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/lib/url.c b/lib/url.c
+index 6a429a1ce9..a233c9831b 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -589,6 +589,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_sasl_service);
+ Curl_safefree(conn->host.rawalloc); /* hostname buffer */
+ Curl_safefree(conn->conn_to_host.rawalloc); /* hostname buffer */
+ Curl_safefree(conn->hostname_resolve);
+@@ -1170,7 +1172,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 */
+@@ -1195,7 +1198,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_sasl_service,
++ conn->proxy_sasl_service))
+ return FALSE;
+ }
+ else if(conn->proxy_ntlm_state != NTLMSTATE_NONE) {
+@@ -1236,7 +1241,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) {
+@@ -1255,7 +1261,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_sasl_service,
++ conn->proxy_sasl_service))
+ return FALSE;
+ }
+ else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
+@@ -3596,6 +3604,25 @@ static CURLcode create_conn(struct Curl_easy *data,
+ }
+ }
+
++ if(data->set.str[STRING_SERVICE_NAME]) {
++ conn->sasl_service = strdup(data->set.str[STRING_SERVICE_NAME]);
++ if(!conn->sasl_service) {
++ result = CURLE_OUT_OF_MEMORY;
++ goto out;
++ }
++ }
++
++#ifndef CURL_DISABLE_PROXY
++ if(data->set.str[STRING_PROXY_SERVICE_NAME]) {
++ conn->proxy_sasl_service =
++ strdup(data->set.str[STRING_PROXY_SERVICE_NAME]);
++ if(!conn->proxy_sasl_service) {
++ result = CURLE_OUT_OF_MEMORY;
++ goto out;
++ }
++ }
++#endif
++
+ #ifdef USE_UNIX_SOCKETS
+ if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
+ conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
+diff --git a/lib/urldata.h b/lib/urldata.h
+index 95f2efc55e..12883b86c0 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -687,6 +687,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 for auth, allocated */
++ char *proxy_sasl_service; /* SASL service name for proxy auth, allocated */
+ struct curltime created; /* creation time */
+ struct curltime lastused; /* when returned to the connection poolas idle */
+ curl_socket_t sock[2]; /* two sockets, the second is used for the data
diff --git a/0024-cookie-improve-TAB-handling.patch b/0024-cookie-improve-TAB-handling.patch
new file mode 100644
index 0000000..f4dfcd4
--- /dev/null
+++ b/0024-cookie-improve-TAB-handling.patch
@@ -0,0 +1,114 @@
+From c1aa85dfd492da5b9f5bde8de064a63b43d0c9f5 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.
+
+Reported-by: Stanislav Fort
+Closes #22699
+
+(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
+---
+ lib/cookie.c | 6 ++---
+ tests/data/Makefile.am | 2 +-
+ tests/data/test2885 | 52 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 56 insertions(+), 4 deletions(-)
+ create mode 100644 tests/data/test2885
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index 17a6baba0c..7faa109947 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -437,9 +437,9 @@ static bool bad_domain(const char *domain, size_t len)
+ static bool invalid_octets(const char *ptr)
+ {
+ const unsigned char *p = (const unsigned char *)ptr;
+- /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */
++ /* Reject all bytes \x01 - \x1f + \x7f */
+ while(*p) {
+- if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f))
++ if((*p < 0x20) || (*p == 0x7f))
+ return TRUE;
+ p++;
+ }
+@@ -497,7 +497,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 done = FALSE;
+ bool sep = FALSE;
+ curlx_str_trimblanks(&name);
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 6a60f1ce4f..4888dec3ea 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -270,7 +270,7 @@ test2600 test2601 test2602 test2603 test2604 \
+ 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..f5fbfccc61
+--- /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="yes">
++HTTP/1.1 200 OK
++Content-Length: 0
++Set-Cookie: thisis=SECRET; Secure
++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="yes">
++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 FALSE / TRUE 0 also notab
++cookie.example FALSE / TRUE 0 thisis SECRET
++</file>
++</verify>
++</testcase>
diff --git a/0024-curl-8.15.0-CVE-2026-8932.patch b/0024-curl-8.15.0-CVE-2026-8932.patch
deleted file mode 100644
index cbf6a3e..0000000
--- a/0024-curl-8.15.0-CVE-2026-8932.patch
+++ /dev/null
@@ -1,835 +0,0 @@
-From ee6702aece7d4c7cf915706379642a4b472eaca7 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 | 22 +++----
- lib/vtls/openssl.c | 7 ++-
- lib/vtls/rustls.c | 13 ++--
- lib/vtls/schannel.c | 10 ++--
- lib/vtls/vtls.c | 40 +++++++++----
- lib/vtls/vtls_scache.c | 72 +++++++++++++++++++----
- lib/vtls/wolfssl.c | 14 ++---
- tests/data/Makefile.am | 2 +
- tests/data/test3303 | 20 +++++++
- tests/unit/Makefile.inc | 3 +-
- tests/unit/unit3303.c | 127 ++++++++++++++++++++++++++++++++++++++++
- 16 files changed, 293 insertions(+), 73 deletions(-)
- create mode 100644 tests/data/test3303
- create mode 100644 tests/unit/unit3303.c
-
-diff --git a/lib/ldap.c b/lib/ldap.c
-index f6da886242..d23263592e 100644
---- a/lib/ldap.c
-+++ b/lib/ldap.c
-@@ -404,8 +404,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 12883b86c0..857f06b696 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -267,9 +267,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) */
-@@ -289,11 +294,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 tls1.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 11c9c28446..25ef8cd3a8 100644
---- a/lib/vssh/libssh.c
-+++ b/lib/vssh/libssh.c
-@@ -972,7 +972,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)
-@@ -986,7 +986,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",
-@@ -999,7 +999,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 d599d3cc50..0daf8d1d1a 100644
---- a/lib/vssh/libssh2.c
-+++ b/lib/vssh/libssh2.c
-@@ -1295,7 +1295,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 f5e02975a0..8cb77c67e9 100644
---- a/lib/vtls/gtls.c
-+++ b/lib/vtls/gtls.c
-@@ -981,10 +981,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 "
-@@ -1002,14 +1003,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 75190d30f3..0438bc253e 100644
---- a/lib/vtls/mbedtls.c
-+++ b/lib/vtls/mbedtls.c
-@@ -717,7 +717,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
- if(ret) {
- mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
- failf(data, "Error reading client cert data %s - mbedTLS: (-0x%04X) %s",
-- ssl_config->key, -ret, errorbuf);
-+ ssl_config->primary.key, -ret, errorbuf);
- return CURLE_SSL_CERTPROBLEM;
- }
- }
-@@ -725,17 +725,17 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
- /* 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 >= 0x03000000
-- 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,
- &backend->ctr_drbg);
- #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);
- #endif
- if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
- mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_ECKEY)))
-@@ -744,7 +744,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
- if(ret) {
- mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
- failf(data, "Error reading private key %s - mbedTLS: (-0x%04X) %s",
-- ssl_config->key, -ret, errorbuf);
-+ ssl_config->primary.key, -ret, errorbuf);
- return CURLE_SSL_CERTPROBLEM;
- }
- #else
-@@ -753,10 +753,10 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
- #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 >= 0x03000000
- ret = mbedtls_pk_parse_key(&backend->pk, key_data, ssl_key_blob->len,
- (const unsigned char *)passwd,
-@@ -927,7 +927,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
- 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 05210c8316..63b2a05133 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4000,7 +4000,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;
- const bool verifypeer = conn_config->verifypeer;
- unsigned int ssl_version_min;
- char error_buffer[256];
-@@ -4191,8 +4191,9 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
- if(!result &&
- !cert_stuff(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))
- result = CURLE_SSL_CERTPROBLEM;
- if(result)
- /* failf() is already done in cert_stuff() */
-diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
-index 4e1b78a759..86e53b5443 100644
---- a/lib/vtls/rustls.c
-+++ b/lib/vtls/rustls.c
-@@ -852,14 +852,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;
- }
-
-@@ -873,8 +873,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;
- }
-@@ -1066,7 +1067,7 @@ cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data,
- }
- }
-
-- 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 2ac61ba794..0ba35f0ef9 100644
---- a/lib/vtls/schannel.c
-+++ b/lib/vtls/schannel.c
-@@ -597,8 +597,8 @@ 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);
-@@ -648,14 +648,14 @@ 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*)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 db4e57342e..f05b5d67c2 100644
---- a/lib/vtls/vtls.c
-+++ b/lib/vtls/vtls.c
-@@ -199,6 +199,7 @@ 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) &&
-@@ -211,8 +212,12 @@ match_ssl_primary_config(struct Curl_easy *data,
- curl_strequal(c1->cipher_list13, c2->cipher_list13) &&
- 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_safecmp(c1->CRLfile, c2->CRLfile) &&
-+ Curl_safecmp(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);
-@@ -308,12 +323,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- data->set.ssl.primary.username = data->set.str[STRING_TLSAUTH_USERNAME];
- data->set.ssl.primary.password = data->set.str[STRING_TLSAUTH_PASSWORD];
- #endif
-- data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE];
-- data->set.ssl.key = data->set.str[STRING_KEY];
-- data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE];
-- data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD];
-+ data->set.ssl.primary.cert_type = data->set.str[STRING_CERT_TYPE];
-+ data->set.ssl.primary.key = data->set.str[STRING_KEY];
-+ data->set.ssl.primary.key_type = data->set.str[STRING_KEY_TYPE];
-+ data->set.ssl.primary.key_passwd = data->set.str[STRING_KEY_PASSWD];
- data->set.ssl.primary.clientcert = data->set.str[STRING_CERT];
-- data->set.ssl.key_blob = data->set.blobs[BLOB_KEY];
-+ data->set.ssl.primary.key_blob = data->set.blobs[BLOB_KEY];
-
- #ifndef CURL_DISABLE_PROXY
- data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
-@@ -333,12 +348,13 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
- data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY];
- data->set.proxy_ssl.primary.CRLfile =
- data->set.str[STRING_SSL_CRLFILE_PROXY];
-- data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
-- data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
-- data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
-- data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
-+ data->set.proxy_ssl.primary.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
-+ data->set.proxy_ssl.primary.key = data->set.str[STRING_KEY_PROXY];
-+ data->set.proxy_ssl.primary.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
-+ data->set.proxy_ssl.primary.key_passwd =
-+ data->set.str[STRING_KEY_PASSWD_PROXY];
- data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
-- data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY];
-+ data->set.proxy_ssl.primary.key_blob = data->set.blobs[BLOB_KEY_PROXY];
- #ifdef USE_TLS_SRP
- data->set.proxy_ssl.primary.username =
- data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
-diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c
-index 662539cd89..6adab68e5d 100644
---- a/lib/vtls/vtls_scache.c
-+++ b/lib/vtls/vtls_scache.c
-@@ -63,6 +63,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;
-@@ -189,8 +190,8 @@ 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);
- #endif
- Curl_safefree(peer->ssl_peer_key);
-@@ -217,8 +218,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)));
- }
-@@ -227,6 +228,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,
-@@ -255,6 +257,11 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
- if(!peer->clientcert)
- goto out;
- }
-+ if(key_passwd) {
-+ peer->key_passwd = strdup(key_passwd);
-+ if(!peer->key_passwd)
-+ goto out;
-+ }
- if(srp_username) {
- peer->srp_username = strdup(srp_username);
- if(!peer->srp_username)
-@@ -431,6 +438,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"
-
-@@ -568,11 +617,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");
-@@ -607,7 +654,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)
-@@ -617,6 +664,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))
-@@ -746,12 +795,13 @@ 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;
-@@ -1126,7 +1176,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/wolfssl.c b/lib/vtls/wolfssl.c
-index c3560e8b8d..d164fd431a 100644
---- a/lib/vtls/wolfssl.c
-+++ b/lib/vtls/wolfssl.c
-@@ -1133,10 +1133,10 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
- #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) {
-@@ -1169,7 +1169,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
- 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,
-@@ -1184,8 +1184,8 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
- #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) {
-@@ -1212,7 +1212,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
- 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 4888dec3ea..b8fd17306c 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -282,6 +282,8 @@ test3100 test3101 test3102 test3103 test3104 test3105 \
- test3200 test3201 test3202 test3203 test3204 test3205 test3207 test3208 \
- test3209 test3210 test3211 test3212 test3213 test3214 \
- \
-+test3303 \
-+\
- test4000 test4001
-
- EXTRA_DIST = $(TESTCASES) DISABLED
-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/unit/Makefile.inc b/tests/unit/Makefile.inc
-index f64a1630c8..552e2940c4 100644
---- a/tests/unit/Makefile.inc
-+++ b/tests/unit/Makefile.inc
-@@ -42,4 +42,5 @@ TESTS_C = \
- unit1979.c unit1980.c \
- unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c \
- unit3200.c unit3205.c \
-- unit3211.c unit3212.c unit3213.c unit3214.c
-+ unit3211.c unit3212.c unit3213.c unit3214.c \
-+ unit3303.c
-diff --git a/tests/unit/unit3303.c b/tests/unit/unit3303.c
-new file mode 100644
-index 0000000000..090ab7adbc
---- /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(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 = calloc(1, sizeof(*conn));
-+ if(!conn || Curl_ssl_conn_config_init((struct Curl_easy *)curl, conn)) {
-+ if(conn)
-+ Curl_ssl_conn_config_cleanup(conn);
-+ 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);
-+ free(conn);
-+ curl_easy_cleanup(curl);
-+ curl_global_cleanup();
-+ }
-+#endif /* USE_SSL */
-+
-+ UNITTEST_END_SIMPLE
-+}
---
-2.56.0
-
diff --git a/0025-curl-8.15.0-CVE-2026-13608.patch b/0025-curl-8.15.0-CVE-2026-13608.patch
deleted file mode 100644
index 9ff5ecf..0000000
--- a/0025-curl-8.15.0-CVE-2026-13608.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 75de5728d2003609bc75894c4ce70993ee3d2933 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 e4714b5580..fb341045c0 100644
---- a/lib/openldap.c
-+++ b/lib/openldap.c
-@@ -751,8 +751,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/0025-openssl-avoid-conn-reuse-if-provider-is-used.patch b/0025-openssl-avoid-conn-reuse-if-provider-is-used.patch
new file mode 100644
index 0000000..f450c13
--- /dev/null
+++ b/0025-openssl-avoid-conn-reuse-if-provider-is-used.patch
@@ -0,0 +1,30 @@
+From c155fdbb7ac4c89b818184bfe9b91efc92d3a0b7 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 b0f91cf400..05210c8316 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4030,6 +4030,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/0026-curl-8.15.0-CVE-2026-80230.patch b/0026-curl-8.15.0-CVE-2026-80230.patch
deleted file mode 100644
index f3f30c8..0000000
--- a/0026-curl-8.15.0-CVE-2026-80230.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 3160728bd26fc2ee98136557fdf865867976719b 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 | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 63b2a05133..83a45ca6d6 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4847,6 +4847,18 @@ static void infof_certstack(struct Curl_easy *data, const SSL *ssl)
- #define infof_certstack(data, ssl)
- #endif
-
-+static const char *pinned(struct Curl_cfilter *cf,
-+ struct Curl_easy *data)
-+{
-+ (void)cf;
-+ return
-+#ifndef CURL_DISABLE_PROXY
-+ Curl_ssl_cf_is_proxy(cf) ?
-+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
-+#endif
-+ data->set.str[STRING_SSL_PINNEDPUBLICKEY];
-+}
-+
- #define MAX_CERT_NAME_LENGTH 2048
-
- CURLcode Curl_oss_check_peer_cert(struct Curl_cfilter *cf,
-@@ -4887,7 +4899,7 @@ CURLcode Curl_oss_check_peer_cert(struct Curl_cfilter *cf,
- octx->server_cert = SSL_get1_peer_certificate(octx->ssl);
- if(!octx->server_cert) {
- BIO_free(mem);
-- if(!strict)
-+ if(!strict && !pinned(cf, data))
- return CURLE_OK;
-
- failf(data, "SSL: could not get peer certificate");
---
-2.56.0
-
diff --git a/0026-tests-mark-test-1501-as-flaky.patch b/0026-tests-mark-test-1501-as-flaky.patch
new file mode 100644
index 0000000..620aee8
--- /dev/null
+++ b/0026-tests-mark-test-1501-as-flaky.patch
@@ -0,0 +1,26 @@
+From de7cc3cf9faad6a69027dd252bd3050c31aee571 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Wed, 7 Oct 2026 08:00:00 +0200
+Subject: [PATCH] tests: mark test 1501 as flaky
+
+Test 1501 checks that curl_multi_perform() never blocks for more than
+500ms. Under valgrind on i686, this threshold is regularly exceeded due
+to instrumentation overhead, causing spurious failures.
+
+Mark the test as flaky so it is skipped when running with '!flaky'.
+---
+ tests/data/test1501 | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tests/data/test1501 b/tests/data/test1501
+index 070ff7d97a..a3c1fc86fd 100644
+--- a/tests/data/test1501
++++ b/tests/data/test1501
+@@ -3,6 +3,7 @@
+ <keywords>
+ FTP
+ RETR
++flaky
+ multi
+ LIST
+ DELAY
diff --git a/0027-curl-8.15.0-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch b/0027-curl-8.15.0-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
deleted file mode 100644
index acc2e4e..0000000
--- a/0027-curl-8.15.0-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 268679ddd77cd25f8f1868804a89191ff115ba17 Mon Sep 17 00:00:00 2001
-From: Collin Funk <collin.funk1@gmail.com>
-Date: Sat, 11 Jul 2026 00:47:16 -0700
-Subject: [PATCH] unit3214: fix to pass on systems with >=128-bit pointers
- and bump MAX_CONNECTDATA
-
-E.g. on CHERI pointers are 128 bits [1]. This causes the unit3214 test
-to fail, which was written with more traditional platforms in mind.
-
-Multiply the allowed size on systems with larger than 64-bit pointers.
-
-[1] https://www.cl.cam.ac.uk/research/security/ctsrd/pdfs/20171017a-cheri-poster.pdf
-
-Closes #22299
-
-(cherry picked from commit dfa444f1e59c52b56fb0d16152e610e4c29c7115)
-
-Additionally, bump MAX_CONNECTDATA from 1300 to 1400.
-
-The CVE-2026-8932 fix (incomplete mTLS config matching in conn reuse)
-promoted cert_type, key, key_type, key_passwd and key_blob from
-ssl_config_data into ssl_primary_config, which is embedded inside
-struct connectdata. This grew the struct by 28 bytes to 1328 on
-64-bit systems, exceeding the previous limit of 1300.
----
- tests/unit/unit3214.c | 10 +++++++---
- 1 file changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/tests/unit/unit3214.c b/tests/unit/unit3214.c
-index fa65b06c58..130e585193 100644
---- a/tests/unit/unit3214.c
-+++ b/tests/unit/unit3214.c
-@@ -27,6 +27,11 @@
-
- static void checksize(const char *name, size_t size, size_t allowed)
- {
-+ /* Some platforms, e.g., CHERI, have 128-bit pointers. Allow structs to be
-+ double the size of what we would typically expect. */
-+ if(sizeof(void *) > 8)
-+ allowed *= sizeof(void *) / 8;
-+
- if(size > allowed) {
- fprintf(stderr, "BAD: struct %s is %d bytes, allowed to be %d",
- name, (int)size, (int)allowed);
-@@ -39,9 +44,10 @@ static void checksize(const char *name, size_t size, size_t allowed)
- }
- }
-
--/* the maximum sizes we allow specific structs to grow to */
-+/* The maximum sizes we allow specific structs to grow to.
-+ These sizes were chosen with platforms with 64-bit pointers in mind. */
- #define MAX_CURL_EASY 5800
--#define MAX_CONNECTDATA 1300
-+#define MAX_CONNECTDATA 1400
- #define MAX_CURL_MULTI 750
- #define MAX_CURL_HTTPPOST 112
- #define MAX_CURL_SLIST 16
---
-2.56.0
diff --git a/0027-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch b/0027-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
new file mode 100644
index 0000000..d9c66ad
--- /dev/null
+++ b/0027-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
@@ -0,0 +1,832 @@
+From c3e082caafff0b9302074e86ddf661f360d8e954 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 | 22 +++----
+ lib/vtls/openssl.c | 7 ++-
+ lib/vtls/rustls.c | 13 ++--
+ lib/vtls/schannel.c | 10 ++--
+ lib/vtls/vtls.c | 40 +++++++++----
+ lib/vtls/vtls_scache.c | 72 +++++++++++++++++++----
+ lib/vtls/wolfssl.c | 14 ++---
+ tests/data/Makefile.am | 2 +
+ tests/data/test3303 | 20 +++++++
+ tests/unit/Makefile.inc | 3 +-
+ tests/unit/unit3303.c | 127 ++++++++++++++++++++++++++++++++++++++++
+ 16 files changed, 293 insertions(+), 73 deletions(-)
+ create mode 100644 tests/data/test3303
+ create mode 100644 tests/unit/unit3303.c
+
+diff --git a/lib/ldap.c b/lib/ldap.c
+index f6da886242..d23263592e 100644
+--- a/lib/ldap.c
++++ b/lib/ldap.c
+@@ -404,8 +404,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 12883b86c0..857f06b696 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -267,9 +267,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) */
+@@ -289,11 +294,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 tls1.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 11c9c28446..21f4e289e7 100644
+--- a/lib/vssh/libssh.c
++++ b/lib/vssh/libssh.c
+@@ -972,7 +972,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)
+@@ -986,7 +986,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",
+@@ -999,7 +999,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 d599d3cc50..0daf8d1d1a 100644
+--- a/lib/vssh/libssh2.c
++++ b/lib/vssh/libssh2.c
+@@ -1295,7 +1295,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 f5e02975a0..8cb77c67e9 100644
+--- a/lib/vtls/gtls.c
++++ b/lib/vtls/gtls.c
+@@ -981,10 +981,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 "
+@@ -1002,14 +1003,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 75190d30f3..0438bc253e 100644
+--- a/lib/vtls/mbedtls.c
++++ b/lib/vtls/mbedtls.c
+@@ -717,7 +717,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
+ if(ret) {
+ mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
+ failf(data, "Error reading client cert data %s - mbedTLS: (-0x%04X) %s",
+- ssl_config->key, -ret, errorbuf);
++ ssl_config->primary.key, -ret, errorbuf);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ }
+@@ -725,17 +725,17 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
+ /* 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 >= 0x03000000
+- 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,
+ &backend->ctr_drbg);
+ #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);
+ #endif
+ if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
+ mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_ECKEY)))
+@@ -744,7 +744,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
+ if(ret) {
+ mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
+ failf(data, "Error reading private key %s - mbedTLS: (-0x%04X) %s",
+- ssl_config->key, -ret, errorbuf);
++ ssl_config->primary.key, -ret, errorbuf);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ #else
+@@ -753,10 +753,10 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
+ #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 >= 0x03000000
+ ret = mbedtls_pk_parse_key(&backend->pk, key_data, ssl_key_blob->len,
+ (const unsigned char *)passwd,
+@@ -927,7 +927,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data)
+ 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 05210c8316..63b2a05133 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4000,7 +4000,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;
+ const bool verifypeer = conn_config->verifypeer;
+ unsigned int ssl_version_min;
+ char error_buffer[256];
+@@ -4191,8 +4191,9 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+ if(!result &&
+ !cert_stuff(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))
+ result = CURLE_SSL_CERTPROBLEM;
+ if(result)
+ /* failf() is already done in cert_stuff() */
+diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c
+index 4e1b78a759..86e53b5443 100644
+--- a/lib/vtls/rustls.c
++++ b/lib/vtls/rustls.c
+@@ -852,14 +852,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;
+ }
+
+@@ -873,8 +873,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;
+ }
+@@ -1066,7 +1067,7 @@ cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data,
+ }
+ }
+
+- 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 2ac61ba794..0ba35f0ef9 100644
+--- a/lib/vtls/schannel.c
++++ b/lib/vtls/schannel.c
+@@ -597,8 +597,8 @@ 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);
+@@ -648,14 +648,14 @@ 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*)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 db4e57342e..f05b5d67c2 100644
+--- a/lib/vtls/vtls.c
++++ b/lib/vtls/vtls.c
+@@ -199,6 +199,7 @@ 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) &&
+@@ -211,8 +212,12 @@ match_ssl_primary_config(struct Curl_easy *data,
+ curl_strequal(c1->cipher_list13, c2->cipher_list13) &&
+ 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_safecmp(c1->CRLfile, c2->CRLfile) &&
++ Curl_safecmp(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);
+@@ -308,12 +323,12 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ data->set.ssl.primary.username = data->set.str[STRING_TLSAUTH_USERNAME];
+ data->set.ssl.primary.password = data->set.str[STRING_TLSAUTH_PASSWORD];
+ #endif
+- data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE];
+- data->set.ssl.key = data->set.str[STRING_KEY];
+- data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE];
+- data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD];
++ data->set.ssl.primary.cert_type = data->set.str[STRING_CERT_TYPE];
++ data->set.ssl.primary.key = data->set.str[STRING_KEY];
++ data->set.ssl.primary.key_type = data->set.str[STRING_KEY_TYPE];
++ data->set.ssl.primary.key_passwd = data->set.str[STRING_KEY_PASSWD];
+ data->set.ssl.primary.clientcert = data->set.str[STRING_CERT];
+- data->set.ssl.key_blob = data->set.blobs[BLOB_KEY];
++ data->set.ssl.primary.key_blob = data->set.blobs[BLOB_KEY];
+
+ #ifndef CURL_DISABLE_PROXY
+ data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
+@@ -333,12 +348,13 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data)
+ data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY];
+ data->set.proxy_ssl.primary.CRLfile =
+ data->set.str[STRING_SSL_CRLFILE_PROXY];
+- data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
+- data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
+- data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
+- data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
++ data->set.proxy_ssl.primary.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
++ data->set.proxy_ssl.primary.key = data->set.str[STRING_KEY_PROXY];
++ data->set.proxy_ssl.primary.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
++ data->set.proxy_ssl.primary.key_passwd =
++ data->set.str[STRING_KEY_PASSWD_PROXY];
+ data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
+- data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY];
++ data->set.proxy_ssl.primary.key_blob = data->set.blobs[BLOB_KEY_PROXY];
+ #ifdef USE_TLS_SRP
+ data->set.proxy_ssl.primary.username =
+ data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
+diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c
+index 662539cd89..6adab68e5d 100644
+--- a/lib/vtls/vtls_scache.c
++++ b/lib/vtls/vtls_scache.c
+@@ -63,6 +63,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;
+@@ -189,8 +190,8 @@ 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);
+ #endif
+ Curl_safefree(peer->ssl_peer_key);
+@@ -217,8 +218,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)));
+ }
+@@ -227,6 +228,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,
+@@ -255,6 +257,11 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer,
+ if(!peer->clientcert)
+ goto out;
+ }
++ if(key_passwd) {
++ peer->key_passwd = strdup(key_passwd);
++ if(!peer->key_passwd)
++ goto out;
++ }
+ if(srp_username) {
+ peer->srp_username = strdup(srp_username);
+ if(!peer->srp_username)
+@@ -431,6 +438,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"
+
+@@ -568,11 +617,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");
+@@ -607,7 +654,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)
+@@ -617,6 +664,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))
+@@ -746,12 +795,13 @@ 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;
+@@ -1126,7 +1176,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/wolfssl.c b/lib/vtls/wolfssl.c
+index c3560e8b8d..d164fd431a 100644
+--- a/lib/vtls/wolfssl.c
++++ b/lib/vtls/wolfssl.c
+@@ -1133,10 +1133,10 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
+ #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) {
+@@ -1169,7 +1169,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
+ 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,
+@@ -1184,8 +1184,8 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
+ #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) {
+@@ -1212,7 +1212,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
+ 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 4888dec3ea..b8fd17306c 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -282,6 +282,8 @@ test3100 test3101 test3102 test3103 test3104 test3105 \
+ test3200 test3201 test3202 test3203 test3204 test3205 test3207 test3208 \
+ test3209 test3210 test3211 test3212 test3213 test3214 \
+ \
++test3303 \
++\
+ test4000 test4001
+
+ EXTRA_DIST = $(TESTCASES) DISABLED
+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/unit/Makefile.inc b/tests/unit/Makefile.inc
+index f64a1630c8..552e2940c4 100644
+--- a/tests/unit/Makefile.inc
++++ b/tests/unit/Makefile.inc
+@@ -42,4 +42,5 @@ TESTS_C = \
+ unit1979.c unit1980.c \
+ unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c \
+ unit3200.c unit3205.c \
+- unit3211.c unit3212.c unit3213.c unit3214.c
++ unit3211.c unit3212.c unit3213.c unit3214.c \
++ unit3303.c
+diff --git a/tests/unit/unit3303.c b/tests/unit/unit3303.c
+new file mode 100644
+index 0000000000..ec7ee3794b
+--- /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(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 = calloc(1, sizeof(*conn));
++ if(!conn || Curl_ssl_conn_config_init((struct Curl_easy *)curl, conn)) {
++ if(conn)
++ Curl_ssl_conn_config_cleanup(conn);
++ 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);
++ free(conn);
++ curl_easy_cleanup(curl);
++ curl_global_cleanup();
++ }
++#endif /* USE_SSL */
++
++ UNITTEST_END_SIMPLE
++}
diff --git a/0028-openldap-handle-Curl_sasl_continue-returns-better.patch b/0028-openldap-handle-Curl_sasl_continue-returns-better.patch
new file mode 100644
index 0000000..9453532
--- /dev/null
+++ b/0028-openldap-handle-Curl_sasl_continue-returns-better.patch
@@ -0,0 +1,43 @@
+From 63bec8d8801c5203db278f5f1ac6bc9c9423c5df 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 e4714b5580..fb341045c0 100644
+--- a/lib/openldap.c
++++ b/lib/openldap.c
+@@ -751,8 +751,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/0029-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch b/0029-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
new file mode 100644
index 0000000..e984d60
--- /dev/null
+++ b/0029-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
@@ -0,0 +1,45 @@
+From 519eca6456c831bd58125b50b46146dedc63fd73 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 | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 63b2a05133..83a45ca6d6 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4847,6 +4847,18 @@ static void infof_certstack(struct Curl_easy *data, const SSL *ssl)
+ #define infof_certstack(data, ssl)
+ #endif
+
++static const char *pinned(struct Curl_cfilter *cf,
++ struct Curl_easy *data)
++{
++ (void)cf;
++ return
++#ifndef CURL_DISABLE_PROXY
++ Curl_ssl_cf_is_proxy(cf) ?
++ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
++#endif
++ data->set.str[STRING_SSL_PINNEDPUBLICKEY];
++}
++
+ #define MAX_CERT_NAME_LENGTH 2048
+
+ CURLcode Curl_oss_check_peer_cert(struct Curl_cfilter *cf,
+@@ -4887,7 +4899,7 @@ CURLcode Curl_oss_check_peer_cert(struct Curl_cfilter *cf,
+ octx->server_cert = SSL_get1_peer_certificate(octx->ssl);
+ if(!octx->server_cert) {
+ BIO_free(mem);
+- if(!strict)
++ if(!strict && !pinned(cf, data))
+ return CURLE_OK;
+
+ failf(data, "SSL: could not get peer certificate");
diff --git a/0030-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch b/0030-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
new file mode 100644
index 0000000..7d8d575
--- /dev/null
+++ b/0030-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
@@ -0,0 +1,57 @@
+From 5833a8214bfc758dffb23e885e187189dec06370 Mon Sep 17 00:00:00 2001
+From: Collin Funk <collin.funk1@gmail.com>
+Date: Sat, 11 Jul 2026 00:47:16 -0700
+Subject: [PATCH] unit3214: fix to pass on systems with >=128-bit pointers and
+ bump MAX_CONNECTDATA
+
+E.g. on CHERI pointers are 128 bits [1]. This causes the unit3214 test
+to fail, which was written with more traditional platforms in mind.
+
+Multiply the allowed size on systems with larger than 64-bit pointers.
+
+[1] https://www.cl.cam.ac.uk/research/security/ctsrd/pdfs/20171017a-cheri-poster.pdf
+
+Closes #22299
+
+(cherry picked from commit dfa444f1e59c52b56fb0d16152e610e4c29c7115)
+
+Additionally, bump MAX_CONNECTDATA from 1300 to 1400.
+
+The CVE-2026-8932 fix (incomplete mTLS config matching in conn reuse)
+promoted cert_type, key, key_type, key_passwd and key_blob from
+ssl_config_data into ssl_primary_config, which is embedded inside
+struct connectdata. This grew the struct by 28 bytes to 1328 on
+64-bit systems, exceeding the previous limit of 1300.
+---
+ tests/unit/unit3214.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/tests/unit/unit3214.c b/tests/unit/unit3214.c
+index fa65b06c58..e550ea95cc 100644
+--- a/tests/unit/unit3214.c
++++ b/tests/unit/unit3214.c
+@@ -27,6 +27,11 @@
+
+ static void checksize(const char *name, size_t size, size_t allowed)
+ {
++ /* Some platforms, e.g., CHERI, have 128-bit pointers. Allow structs to be
++ double the size of what we would typically expect. */
++ if(sizeof(void *) > 8)
++ allowed *= sizeof(void *) / 8;
++
+ if(size > allowed) {
+ fprintf(stderr, "BAD: struct %s is %d bytes, allowed to be %d",
+ name, (int)size, (int)allowed);
+@@ -39,9 +44,10 @@ static void checksize(const char *name, size_t size, size_t allowed)
+ }
+ }
+
+-/* the maximum sizes we allow specific structs to grow to */
++/* The maximum sizes we allow specific structs to grow to.
++ These sizes were chosen with platforms with 64-bit pointers in mind. */
+ #define MAX_CURL_EASY 5800
+-#define MAX_CONNECTDATA 1300
++#define MAX_CONNECTDATA 1400
+ #define MAX_CURL_MULTI 750
+ #define MAX_CURL_HTTPPOST 112
+ #define MAX_CURL_SLIST 16
diff --git a/0031-ci-setup-packit.patch b/0031-ci-setup-packit.patch
new file mode 100644
index 0000000..8006a88
--- /dev/null
+++ b/0031-ci-setup-packit.patch
@@ -0,0 +1,64 @@
+From 4187579b30f6cb7d71a33b10f1bb156ffa344eba 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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 45 insertions(+)
+ create mode 100644 .packit.yml
+
+diff --git a/.packit.yml b/.packit.yml
+new file mode 100644
+index 0000000000..9d37bd6c9e
+--- /dev/null
++++ b/.packit.yml
+@@ -0,0 +1,45 @@
++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.
++ # Upstream tags look like curl-8_15_0, so strip the prefix and turn
++ # underscores into dots (8.15.0). Only match upstream tags.
++ - "bash -ec 'git describe --tags --abbrev=0 --match \"curl-*\" | sed -e \"s/^curl-//\" -e \"s/_/./g\"'"
++
++ post-upstream-clone:
++ # Use the Fedora specfile
++ - "git clone -b f43 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"
++ # Drop the detached signature source too, otherwise packit tries to
++ # download it and it isn't needed without gpgverify
++ - "sed -ri '/^Source1:/d' .packit_rpm/curl.spec"
++
++# Available targets can be listed via `copr-cli list-chroots`
++jobs:
++- job: copr_build
++ trigger: pull_request
++ targets:
++ - fedora-43-aarch64
++ - fedora-43-ppc64le
++ - fedora-43-s390x
++ - fedora-43-x86_64
diff --git a/0032-multi-adjust-the-cleanup-order-in-multi_done.patch b/0032-multi-adjust-the-cleanup-order-in-multi_done.patch
new file mode 100644
index 0000000..fa868f9
--- /dev/null
+++ b/0032-multi-adjust-the-cleanup-order-in-multi_done.patch
@@ -0,0 +1,47 @@
+From b1877881bf2f741b02ca5253e810d921f125b103 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
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+---
+ lib/multi.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/lib/multi.c b/lib/multi.c
+index b3a7938e33..250d8d64a2 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -672,19 +672,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 e7b2a32..0000000
--- a/0101-curl-7.32.0-multilib.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 495c771a6f9be008b783c5f59285d30fdc15fd63 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Mon, 10 Mar 2025 14:23:59 +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 5518416..324e0b7 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 "X@libdir@" != 'X/usr/lib' -a "X@libdir@" != 'X/usr/lib64'; then
-- curllibdir="-L@libdir@ "
-- else
-- curllibdir=''
-- fi
-- if test 'X@ENABLE_SHARED@' = 'Xno'; 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 'X@ENABLE_STATIC@' != 'Xno'; 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 12ad245..fa0e03d 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 c0ba524..f3645e1 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.48.1
-
diff --git a/0105-curl-8.11.1-test616.patch b/0105-curl-8.11.1-test616.patch
deleted file mode 100644
index 91bde80..0000000
--- a/0105-curl-8.11.1-test616.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 82baec8c7cd40361585d8793dfe4531f7aad30e3 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Wed, 11 Dec 2024 13:16:12 +0100
-Subject: [PATCH] test616: disable valgrind
-
-Valgrind disable was removed in upstream in https://github.com/curl/curl/commit/c91c37b6e87ceee760b7bb334c8e97e03ee93e93#diff-e01fd8774cf5b26329c7dc7dc03ec49745469205f3d501ced72c9d133455d5e7L35
-But test 616 is still failing under valgrind, so disable valgrind for this test.
-
-```
- valgrind ERROR ==188588== 144 bytes in 1 blocks are definitely lost in loss record 1 of 1
-==188588== at 0x484B133: calloc (vg_replace_malloc.c:1675)
-==188588== by 0x4BB7575: ??? (in /usr/lib64/libssh.so.4.10.1)
-==188588== by 0x4BB8CC6: sftp_fstat (in /usr/lib64/libssh.so.4.10.1)
-==188588== by 0x48EEAFB: myssh_statemach_act (libssh.c:1610)
-==188588== by 0x48F1B9D: myssh_multi_statemach.lto_priv.0 (libssh.c:2095)
-==188588== by 0x48BA971: UnknownInlinedFun (multi.c:1643)
-==188588== by 0x48BA971: UnknownInlinedFun (multi.c:2314)
-==188588== by 0x48BA971: multi_runsingle (multi.c:2768)
-==188588== by 0x48BCCA4: curl_multi_perform (multi.c:3016)
-==188588== by 0x4884E4A: UnknownInlinedFun (easy.c:701)
-==188588== by 0x4884E4A: UnknownInlinedFun (easy.c:796)
-==188588== by 0x4884E4A: curl_easy_perform (easy.c:815)
-==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:2902)
-==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:3127)
-==188588== by 0x10C12B: UnknownInlinedFun (tool_operate.c:3249)
-==188588== by 0x10C12B: main (tool_main.c:271)
-==188588==
-```
----
- tests/data/test616 | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/tests/data/test616 b/tests/data/test616
-index f76c68a..0ebc734 100644
---- a/tests/data/test616
-+++ b/tests/data/test616
-@@ -32,5 +32,8 @@ SFTP retrieval of empty file
- #
- # Verify data after the test has been "shot"
- <verify>
-+<valgrind>
-+disable
-+</valgrind>
- </verify>
- </testcase>
---
-2.47.1
-
diff --git a/0106-curl-8.15.0-test1501-flaky.patch b/0106-curl-8.15.0-test1501-flaky.patch
deleted file mode 100644
index 695d514..0000000
--- a/0106-curl-8.15.0-test1501-flaky.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From: Jan Macku <jamacku@redhat.com>
-Date: Tue, 7 Oct 2026 08:00:00 +0200
-Subject: [PATCH] tests: mark test 1501 as flaky
-
-Test 1501 checks that curl_multi_perform() never blocks for more than
-500ms. Under valgrind on i686, this threshold is regularly exceeded due
-to instrumentation overhead, causing spurious failures.
-
-Mark the test as flaky so it is skipped when running with '!flaky'.
----
- tests/data/test1501 | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/tests/data/test1501 b/tests/data/test1501
---- a/tests/data/test1501
-+++ b/tests/data/test1501
-@@ -3,6 +3,7 @@
- <keywords>
- FTP
- RETR
-+flaky
- multi
- LIST
- DELAY
diff --git a/curl.spec b/curl.spec
index 6fb1e68..dd3d7bc 100644
--- a/curl.spec
+++ b/curl.spec
@@ -7,7 +7,7 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 8.15.0
-Release: 12%{?dist}
+Release: 13%{?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
@@ -17,95 +17,38 @@ Source1: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz.asc
Source2: mykey.asc
# Fedora-specific
-# fix curl: tool_read_cb(): curl killed by SIGSEGV
-Patch001: 0001-curl-8.15.0-curl-tool_read_cb-fix-of-segfault.patch
-
-# fix broken TLS options for threaded LDAPS (CVE-2025-14017)
-Patch002: 0002-curl-8.15.0-CVE-2025-14017.patch
-
-# fix bad reuse of HTTP Negotiate connection (CVE-2026-1965)
-Patch003: 0003-curl-8.15.0-CVE-2026-1965.patch
-
-# fix token leak with redirect and netrc (CVE-2026-3783)
-Patch004: 0004-curl-8.15.0-CVE-2026-3783.patch
-
-# fix wrong proxy connection reuse with credentials (CVE-2026-3784)
-Patch005: 0005-curl-8.15.0-CVE-2026-3784.patch
-
-# fix use after free in SMB connection reuse (CVE-2026-3805)
-Patch006: 0006-curl-8.15.0-CVE-2026-3805.patch
-
-# fix Out of bounds read for cookie path (CVE-2025-9086)
-Patch007: 0007-curl-8.15.0-CVE-2025-9086.patch
-
-# fix cross-proxy Digest auth state leak (CVE-2026-7168)
-Patch008: 0008-curl-8.15.0-CVE-2026-7168.patch
-
-# fix cross-origin Digest auth state leak (CVE-2026-11856)
-Patch009: 0009-curl-8.15.0-CVE-2026-11856.patch
-
-# fix password leak with netrc and user in URL (CVE-2026-8926)
-Patch010: 0010-curl-8.15.0-CVE-2026-8926.patch
-
-# fix SSH improper host validation (CVE-2026-9547)
-Patch011: 0011-curl-8.15.0-CVE-2026-9547.patch
-
-# fix trailing dot domain super cookie (CVE-2026-8924)
-Patch012: 0012-curl-8.15.0-CVE-2026-8924.patch
-
-# fix proto-default skips SSH verification (CVE-2026-12064)
-Patch013: 0013-curl-8.15.0-CVE-2026-12064.patch
-
-# fix wrong STARTTLS connection reuse (CVE-2026-8286)
-Patch014: 0014-curl-8.15.0-CVE-2026-8286.patch
-
-# fix SASL double-free (CVE-2026-8925)
-Patch015: 0015-curl-8.15.0-CVE-2026-8925.patch
-
-# fix env-set cross-proxy Digest auth state leak (CVE-2026-8927)
-Patch016: 0016-curl-8.15.0-CVE-2026-8927.patch
-
-# fix exposing HTTP/3 early data (CVE-2026-9545)
-Patch017: 0017-curl-8.15.0-CVE-2026-9545.patch
-
-# fix UAF after pause in socket callback (CVE-2026-9080)
-Patch018: 0018-curl-8.15.0-CVE-2026-9080.patch
-
-# fix HTTP/2 stream-dependency tree UAF (CVE-2026-10536)
-Patch019: 0019-curl-8.15.0-CVE-2026-10536.patch
-
-# fix stale proxy password leak (CVE-2026-9079)
-Patch020: 0020-curl-8.15.0-CVE-2026-9079.patch
-
-# fix wrong reuse for different services (CVE-2026-8458)
-Patch021: 0021-curl-8.15.0-CVE-2026-8458.patch
-
-# fix secure cookie attribute bypass with tab (CVE-2026-80255)
-Patch022: 0022-curl-8.15.0-CVE-2026-80255.patch
-
-# fix OpenSSL provider use-after-free (CVE-2026-80229)
-Patch023: 0023-curl-8.15.0-CVE-2026-80229.patch
-
-# fix incomplete mTLS config matching in conn reuse (CVE-2026-8932)
-Patch024: 0024-curl-8.15.0-CVE-2026-8932.patch
-
-# fix OpenLDAP SASL authentication bypass (CVE-2026-13608)
-Patch025: 0025-curl-8.15.0-CVE-2026-13608.patch
-
-# fix OpenSSL pinning bypass (CVE-2026-80230)
-Patch026: 0026-curl-8.15.0-CVE-2026-80230.patch
-
-# fix to pass on systems with >=128-bit pointers
-Patch027: 0027-curl-8.15.0-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
-
-# patch making libcurl multilib ready
-Patch101: 0101-curl-7.32.0-multilib.patch
-
-# test616: disable valgrind
-Patch105: 0105-curl-8.11.1-test616.patch
-
-# test1501: mark as flaky (timing-sensitive, fails under valgrind on i686)
-Patch106: 0106-curl-8.15.0-test1501-flaky.patch
+Patch0001: 0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
+Patch0002: 0002-test616-disable-valgrind.patch
+Patch0003: 0003-curl-tool_read_cb-fix-of-segfault.patch
+Patch0004: 0004-ldap-call-ldap_init-before-setting-the-options.patch
+Patch0005: 0005-CVE-2026-1965.patch
+Patch0006: 0006-CVE-2026-3783.patch
+Patch0007: 0007-CVE-2026-3784.patch
+Patch0008: 0008-CVE-2026-3805.patch
+Patch0009: 0009-cookie-don-t-treat-the-leading-slash-as-trailing.patch
+Patch0010: 0010-setopt-clear-proxy-auth-properties-when-switching.patch
+Patch0011: 0011-digest-flush-state-on-origin-or-credential-change.patch
+Patch0012: 0012-netrc-scanner-refactor.patch
+Patch0013: 0013-libssh-map-SSH_KNOWN_HOSTS_OTHER-to-CURLKHMATCH_MISM.patch
+Patch0014: 0014-cookie-trim-trailing-dots-when-checking-PSL.patch
+Patch0015: 0015-config2setopts-use-default-protocol-properly.patch
+Patch0016: 0016-url-fix-connection-reuse-for-starttls-protocols.patch
+Patch0017: 0017-gsasl-fix-potential-double-free.patch
+Patch0018: 0018-url-detect-proxy-changes-read-from-environment.patch
+Patch0019: 0019-ngtcp2-fail-handshake-directly.patch
+Patch0020: 0020-multi-handle-pause-in-multi-socket-callback.patch
+Patch0021: 0021-http2-remove-stream-dependency-tracking.patch
+Patch0022: 0022-setopt-clear-proxy-auth-properly-on-NULL.patch
+Patch0023: 0023-url-add-SASL-service-name-to-connection-reuse-matchi.patch
+Patch0024: 0024-cookie-improve-TAB-handling.patch
+Patch0025: 0025-openssl-avoid-conn-reuse-if-provider-is-used.patch
+Patch0026: 0026-tests-mark-test-1501-as-flaky.patch
+Patch0027: 0027-tls-fix-incomplete-mTLS-config-in-conn-reuse-and-ses.patch
+Patch0028: 0028-openldap-handle-Curl_sasl_continue-returns-better.patch
+Patch0029: 0029-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
+Patch0030: 0030-unit3214-fix-to-pass-on-systems-with-128-bit-pointer.patch
+Patch0031: 0031-ci-setup-packit.patch
+Patch0032: 0032-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
@@ -503,6 +446,12 @@ rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/wcurl.1*
%{_libdir}/libcurl.so.4.[0-9].[0-9].minimal
%changelog
+* Tue Dec 01 2026 Jan Macku <jamacku@redhat.com> - 8.15.0-13
+- 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)
+
* Tue Oct 13 2026 Jan Macku <jamacku@redhat.com> - 8.15.0-12
- fix incomplete mTLS config matching in conn reuse (CVE-2026-8932)
- fix OpenLDAP SASL authentication bypass (CVE-2026-13608)
reply other threads:[~2026-12-01 14:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179613523051.1.3046621245190851268.rpms-curl-c9f36f91c920@fedoraproject.org \
--to=jamacku@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox