Commit graph

16639 commits

Author SHA1 Message Date
Viktor Szakats
c2ca16f3ff
h3: sync printf masks with types, drop two casts
Also fix `nwritten` signedness in `cb_h3_read_req_body()`.

Follow-up to e78b1b3ecc #21153
Ref: #20848

Closes #21799
2026-05-28 16:37:06 +02:00
Stefan Eissing
e4139a73c8
h3-proxy: fixes around H3 proxy
code:
- less exception handling in existing code
- true ip happy eyeballing
- enable certificate verification
- cf-h2-proxy: abort connection when server closed connection

tests:
- remove all --insecure and --proxy-insecure args
- make session reuse test_60_12 a working one
- resolve port conflicts between h2o and nghttpx
- use proxy args better
- make test_60_06 run shorter
- kill h2o at the end of tests, normal stop takes too long

Ref: 59213f8248 #21789
Follow-up to e78b1b3ecc #21153

Closes #21798
2026-05-28 14:41:27 +02:00
Viktor Szakats
cfa735c40a
h3-proxy: rename feature 'Proxy/PROXY-HTTP3' to 'proxy-HTTP3'
For consistency and to follow existing 'HTTPS-proxy' (with lowercase
'proxy') feature tag more closely.

Follow-up to e78b1b3ecc #21153

Closes #21796
2026-05-28 12:52:50 +02:00
tiymat
f1959ae962
urlapi: fix an issue parsing file URLs
Fixes #21743
Closes #21764
2026-05-28 08:49:56 +02:00
ambikeesshh
e2ca8408c4
cf-socket: set scope_id for IPv6 link-local addresses
When connecting to an mDNS hostname that resolves to an IPv6 link-local
address, connect() fails with EINVAL because sin6_scope_id is 0. This is
a regression since 8.20.0 where the threaded resolver started splitting
A and AAAA queries into separate getaddrinfo calls. The AAAA-only call
with PF_INET6 may not set scope_id on systems where the same call with
PF_UNSPEC did.

When the resolver does not provide scope_id for a link-local address,
try to determine it from the system's network interfaces using
getifaddrs(). Also add scope_id to verbose connect output so the value
can be seen in curl -v logs.

Built and tested locally on Linux. checksrc passes.

Fixes #21669
Reported-by: Bartel Sielski
Closes #21728
2026-05-28 08:43:53 +02:00
Daniel Stenberg
6597e6d461
tftp: avoid the timeout calc if the timeout is crazy
Avoids integer overflow when a silly value is set.

Fixes #21782
Reported-by: Mike-menny on github
Closes #21787
2026-05-28 00:14:00 +02:00
Daniel Stenberg
d1b482caec
unit3400: repair after capsule_encap_udp_hdr went static
Access the static function with UNITTEST as designed.

Follow-up to 73c2b4b435

Closes #21788
2026-05-28 00:13:24 +02:00
Viktor Szakats
59320082b0
tidy-up: apply clang-format fixes
To lib, vtls/vauth, vtls/vquic, lib/vtls.

Also:
- unit3400: drop redundant `(void)arg`.
  Follow-up to e78b1b3ecc #21153
- fix comment typos.

Closes #21786
2026-05-28 00:05:47 +02:00
Daniel Stenberg
73c2b4b435
capsule: make capsule_encap_udp_hdr static
And drop the Curl_ prefix.

Closes #21777
2026-05-27 23:17:44 +02:00
Daniel Stenberg
98431e89bb
creds: remove two unused functions
Curl_creds_same_user and Curl_creds_same_password

Closes #21776
2026-05-27 23:16:51 +02:00
Daniel Stenberg
7bc2bf7917
http_proxy: make two proxy_create functions static
And drop their `Curl_` prefixes. They are only used within this file.

Closes #21775
2026-05-27 23:15:29 +02:00
Daniel Stenberg
ead2e13a8e
dnscache: remove Curl_dns_entry_link
Unused function

Closes #21774
2026-05-27 23:13:19 +02:00
Daniel Stenberg
4f8ed62c49
cf-h3-proxy.c: bring back include
Without it, it breaks regular (non-unity) builds.

Fix regression from 7e1001bcd6

Closes #21785
2026-05-27 23:12:27 +02:00
Viktor Szakats
40f2da6ec3
vtls: more large buffer support and error checks for SHA-256
- gnutls: support 4GiB+ SHA-256 digest inputs.
- openssl: check success of low-level update/finish digest calls.
- openssl: pass NULL to `EVP_DigestFinal_ex()` instead of discarding
  returned value.
- wolfssl: support 4GiB+ SHA-256 digest inputs.
- wolfssl: check success of low-level update/finish digest calls.
- sync and tidy up argument names in low-level sha256_sum functions.

Closes #21771
2026-05-27 16:57:39 +02:00
Viktor Szakats
a1baacc670
schannel: check schannel_sha256sum() success, and more
Also:
- support 4GiB+ SHA-256 digest inputs.
- check `CryptGetHashParam()` output size.
- avoid overwriting existing digest when new digest calculation fails.
- avoid adding digest hash element on failure.

Closes #21739
2026-05-27 16:57:38 +02:00
Viktor Szakats
c7f0267eb7
curl_sha512_256: fix result code on error
Replace result code `CURLE_SSL_CIPHER` with
`CURLE_BAD_FUNCTION_ARGUMENT` in case of a low-level digest function
fails. Functionality is related to vauth, not SSL, and the operation is
a digest, not a cipher.

Also fix a indentation.

Follow-up to 05268cf801 #13070

Closes #21767
2026-05-27 16:57:38 +02:00
Viktor Szakats
7bcf34672d
vtls_spack: drop redundant macro fallbacks
For `UINT16_MAX` and `UINT32_MAX`. They are used in other sources
without this fallback.

Closes #21768
2026-05-27 16:53:57 +02:00
Viktor Szakats
7e1001bcd6
tidy-up: miscellaneous
- H3 proxy: re-sync code with original source `curl_ngtcp2.c` to reduce
  differences, and to apply missed minor fixes. Also apply clang-format.
  Drop redundant `#undef`s, casts, `#endif` comments, includes, drop
  intermediate variables, sync include and macro order.
  Follow-up to e78b1b3ecc #21153
- INSTALL-CMAKE.md: move `CURL_ENABLE_SMB` to the enable section.
- tests/http/env: rename `tcpdmp` to `tcpdump` to match object variable.
- mbedtls: drop incorrect `mbedTLS 4+` comments.
  (features are also supported by 3+, meaning it's always supported.)
- lib1648: rename a variable to match purpose.
- CIPHERS.md: alpha-sort link list.
- replace rare `X''` hex markup with `0x`.
- `IP v4/6` -> `IPv4/6`.
- 'version X.Y' -> 'vX.Y', where sensible.
- 'VX.Y' -> 'vX.Y', where sensible.
- fix indents, casing, newlines, typos.

Closes #21772
2026-05-27 16:53:57 +02:00
Stefan Eissing
a7d4abb0cf
cf-h3-proxy: add SSL flag
Since the proxy filter does TLS, it needs to set the SSL flag.

Follow-up to e78b1b3ecc
Closes #21770

Spotted by Codex Security
2026-05-27 10:55:59 +02:00
Stefan Eissing
1791a08707
content_encoding: timeout during slow decoding
Check during transfer/content decoding for every MB or so, if the
transfer has reached its overall time limit. Error out if so.

This is mainly a protectin against compression bombs using way more time
than the transfer is allowed to. Normal compression ratios are unlikely
to benefit as they need more upstream data where the timeout handling is
already in place.

Fixes #21603
Reported-by: Joshua Rogers
Closes #21758
2026-05-27 09:52:48 +02:00
Stefan Eissing
049ec8a363
content_encoding: fix limit failure message
The message triggered earlier than intended and did not take the
transfer/content type into account.

Ref #21603
Reported-by: Joshua Rogers
Closes #21756
2026-05-27 09:50:34 +02:00
tiymat
a8e6f90a69
urlapi: forbid '|' in host
Closes #21762
2026-05-27 09:39:37 +02:00
Daniel Stenberg
efdf733bae
gtls: use the correct return code in trace output
Instead of using a hard-coded zero.

Spotted by Copilot

Closes #21766
2026-05-27 09:38:39 +02:00
Joshua Rogers
f21b5d4e66
gtls: fix ignored return and uninitialized status in OCSP check
gnutls_ocsp_resp_get_single() was called with (void) discarding its
return value, so a failure (e.g. an OCSP response with no
SingleResponse entries) went undetected.  The following switch() then
read an uninitialized gnutls_ocsp_cert_status_t, which is undefined
behaviour and could yield GNUTLS_OCSP_CERT_GOOD (0) depending on
stack contents, causing gtls_verify_ocsp_status to return CURLE_OK for
a response that was never successfully parsed.

Fix by initializing status to GNUTLS_OCSP_CERT_UNKNOWN and treating a
negative return from gnutls_ocsp_resp_get_single as an error.

Closes #21679
2026-05-27 09:01:00 +02:00
Aritra Basu
e78b1b3ecc
HTTP/3: add proxy CONNECT and MASQUE CONNECT-UDP support (ngtcp2 QUIC)
This patch adds two major proxy capabilities to curl (ngtcp2 QUIC):
- HTTP/3 Proxy CONNECT: Tunnel HTTP/1.1 or HTTP/2 traffic through an
  HTTPS proxy that speaks HTTP/3 (QUIC) using the standard CONNECT
  method over an HTTP/3 connection.
- MASQUE CONNECT-UDP: Tunnel HTTP/3 (QUIC) traffic through an HTTP
  proxy (speaking HTTP/1.1, HTTP/2, or HTTP/3) using the extended
  CONNECT method with the CONNECT-UDP protocol (RFC9297 & RFC9298).

Public API additions:
- `CURLPROXY_HTTPS3`: new proxy type constant for HTTP/3 proxy
- `--proxy-http3`: new CLI flag to negotiate HTTP/3 with HTTPS proxy

The implementation adds two new filters:
- `H3-PROXY` - enables negotiating HTTP/3 (QUIC) to the proxy and
  running CONNECT/CONNECT-UDP through that proxy transport.
- `CAPSULE` - dedicated filter inserted between QUIC transport and
  HTTP-PROXY to handle datagram capsule encapsulation/decapsulation.

Here is how the curl filter chaining looks in different scenarios:
- HTTP/3 Proxy CONNECT (tunneling TCP protocols over QUIC proxy):
  conn -> HTTP/1.1 or HTTP/2  -> SSL -> HTTP-PROXY ->
                                 H3-PROXY -> HAPPY-EYEBALLS -> UDP
- MASQUE CONNECT-UDP (tunneling QUIC over any proxy):
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H3-PROXY ->
                               HAPPY-EYEBALLS -> UDP
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H1-PROXY or H2-PROXY ->
                               SSL -> HAPPY-EYEBALLS -> TCP

- Both features currently require the ngtcp2 QUIC backend.
- Both features are experimental (disabled by default). Enable with
  `--enable-proxy-http3`(autotools) or `-DUSE_PROXY_HTTP3=ON`(CMake).

Tests:
- tests/unit/unit3400.c: Unit tests for capsule protocol encode/decode
- tests/http/test_60_h3_proxy.py: Comprehensive pytest integration suite
- tests/http/testenv/h2o.py: Managing h2o instances with HTTP/1.1, HTTP/2,
  and HTTP/3 (QUIC) listeners, proxy.connect and proxy.connect-udp enabled.

References:
  RFC 9297 - HTTP Datagrams and the Capsule Protocol
  RFC 9298 - Proxying UDP in HTTP
  RFC 9000 §16 — Variable-Length Integer Encoding

Signed-off-by: Aritra Basu <aritrbas+gh@cisco.com>

Closes #21153
2026-05-27 08:49:53 +02:00
Stefan Eissing
f27233e984
GnuTLS: require 3.7.2 for earlydata
Since all API features we need for TLSv1.3 earlydata support do exist
only from version 3.7.2 onwards, make that the minimal version required.

Fixes #21750
Reported-by: Johannes Schlatow
Closes #21751
2026-05-26 13:41:21 +02:00
Stefan Eissing
eb8f31e18b
multi_ev: silence clang-tidy nonsense
About a "unnecessary define" - my ass.

Closes #21752
2026-05-26 13:01:30 +02:00
Daniel Stenberg
5ab34cba42
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
2026-05-26 10:52:34 +02:00
Daniel Stenberg
862e8a74a8
transfer: clear referer when set to NULL
Verify in test 1649

Closes #21741
2026-05-26 10:04:40 +02:00
Stefan Eissing
230a986636
ldap: switch of chasing referrals
It is switched off in the OpenLDAP backend, so we should do the
same here.

Follow-up to cdc1da9120

Closes #21732
2026-05-25 17:02:43 +02:00
Joshua Rogers
0b8dbbc63c
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
2026-05-25 16:46:22 +02:00
Joshua Rogers
fc90bdbaf9 schannel: error on TLS 1.3-only with cipher list
The legacy SCHANNEL_CRED path cannot negotiate TLS 1.3. When TLS 1.3
is the only enabled protocol and a cipher list is set, fail instead of
silently downgrading to TLS 1.2.

Fixes https://github.com/curl/curl/issues/21702
Closes https://github.com/curl/curl/pull/21725
2026-05-22 11:22:15 -04:00
Stefan Eissing
7b9613fa9b
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
2026-05-22 10:03:05 +02:00
Stefan Eissing
bfbff7852f
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
2026-05-22 09:44:08 +02:00
Daniel Stenberg
7e350dd147
urlapi: fix redirect handling if CURLU_NO_GUESS_SCHEME is set
Verified by test 1967

Reported-by: Joshua Rogers
Closes #21721
2026-05-22 07:48:20 +02:00
Viktor Szakats
a076f821e1
multi: silence gcc 16 -Wnull-dereference, bump CI job to test
- GHA/windows: bump dl-mingw job from gcc 15 to 16.

- multi: silence warning while building libcurlu:
  ```
  In function 'multi_ischanged',
      inlined from 'multi_socket.isra' at D:/a/curl/curl/lib/multi.c:3282:6:
  D:/a/curl/curl/lib/multi.c:1710:17: error: null pointer dereference [-Werror=null-dereference]
   1710 |   bool retval = (bool)multi->recheckstate;
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
  D:/a/curl/curl/lib/multi.c:1712:25: error: null pointer dereference [-Werror=null-dereference]
   1712 |     multi->recheckstate = FALSE;
        |                         ^
  ```
  Ref: https://github.com/curl/curl/actions/runs/26217071531/job/77142119137?pr=21707

- multi: silence another `-Wnull-dereference`, popping up in libcurl
  with gcc 13 after the previous silencing:
  ```
  In function 'Curl_multi_xfers_running',
      inlined from 'multi_socket.isra' at ../../lib/multi.c:3292:28:
  ../../lib/multi.c:4132:15: error: null pointer dereference [-Werror=null-dereference]
   4132 |   return multi->xfers_alive;
        |          ~~~~~^~~~~~~~~~~~~
  ```
  Ref: https://github.com/curl/curl/actions/runs/26218822231/job/77148186045

- multi: also add `DEBUGASSERT(multi)` to the two updated functions.

Closes #21707
2026-05-21 15:16:21 +02:00
Viktor Szakats
bcd0497c81
tidy-up: use curlx_safefree()
Closes #21700
2026-05-21 01:31:03 +02:00
Joshua Rogers
cce4d3b0ed schannel: fix revoke_best_effort setting for proxy
- Fix revoke_best_effort reading wrong ssl config.

Prior to this change the revoke_best_effort setting for the proxy was
wrongly ignored in favor of the same setting for the destination host.

In other words, CURLSSLOPT_REVOKE_BEST_EFFORT set via
CURLOPT_PROXY_SSL_OPTIONS did not apply to the proxy and
CURLSSLOPT_REVOKE_BEST_EFFORT set via CURLOPT_SSL_OPTIONS wrongly
applied to the proxy.

Closes https://github.com/curl/curl/pull/21683
2026-05-20 13:51:35 -04:00
Stefan Eissing
5e4e62962c cfilters: fix busy loop on blocked transfers
When a transfer gets paused after the connection has been established,
any data sitting in the kernel socket buffers will no longer get read.

Prevent the sockets form being added to the pollsets, because they
will trigger POLLIN endlessly and cause a busy poll loop. Same in event
based processing.

Reported-by: Harry Sintonen

Fixes https://github.com/curl/curl/issues/21671
Closes https://github.com/curl/curl/pull/21675
2026-05-20 13:51:34 -04:00
penpal
ba7b65f957 sspi: clear SSPI credentials on AcquireCredentialsHandle failure
- Clear credentials on AcquireCredentialsHandle failure so it is not
  used on a subsequent call.

SSPI initialization may evaluate the credentials pointer to determine
whether or not a prior call to AcquireCredentialsHandle was successful,
therefore we must clear it on a failed call.

Closes https://github.com/curl/curl/pull/21642
2026-05-20 13:51:33 -04:00
Daniel Stenberg
88c7e16cce
setopt: clear proxy auth properly on NULL
Verify NULLed proxy credentials with test1648

Closes #21696
2026-05-20 15:54:41 +02:00
Joshua Rogers
edfc80c7c4
urlapi: compare zone-id in Curl_url_same_origin()
Closes #21686
2026-05-20 11:53:29 +02:00
Stefan Eissing
77e4e5b86d
websockets: auto-tunnel through http proxy
When using a ws: or wss: url with a http proxy, automatically
switch to tunneling operation mode.

Add test_20_10 to check.

Fixes #21663
Closes #21691
2026-05-20 11:50:35 +02:00
Viktor Szakats
b3f76b21c9
tidy-up: miscellaneous
- fix typos and wording in documentation and comments.
- KNOWN_BUGS: merge duplicate H1 section.
- test_10_proxy: delete stray expressions.
- Perl: `while()` -> `while(1)`.
- Perl: fix indent, whitespace, drop redundant quotes and parentheses.
- fix casing: URL, SSL, Windows.
- badwords: readd `threadsafe`, add `well-known` (and fix it).
- replace `WinXP` -> `Windows XP` to match other uses.

Closes #21646
2026-05-20 00:50:43 +02:00
Joshua Rogers
7541ae569d
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
2026-05-20 00:02:33 +02:00
Daniel Stenberg
5c225384b8
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
2026-05-19 17:14:16 +02:00
Viktor Szakats
000de81fb1
tidy-up: rename more CURLcode variables to result
Follow-up to 885b553545 #21348

Closes #21676
2026-05-19 16:55:45 +02:00
Viktor Szakats
1fb734bc2d
docs: tidy-up scheme references
After this patch `://` schemes are lowercase and enclosed in backticks.

Also:
- docs/libcurl/libcurl-multi.md: drop a stray C code fence.
- docs/libcurl/libcurl-tutorial.md: replace single/double quotes with
  Markdown markup where applicable.

Ref: #21646

Closes #21674
2026-05-19 16:55:45 +02:00
Joshua Rogers
81da4ee249
vtls: use Curl_safecmp for CRLfile and pinned_key comparison
Both are filesystem paths (or case-sensitive hash strings for
pinned_key). curl_strequal is case-insensitive and would treat
/etc/ssl/Crl.pem and /etc/ssl/crl.pem as the same file, unlike the other
path fields (CApath, CAfile, issuercert, clientcert) which already use
Curl_safecmp.

Closes #21668
2026-05-19 15:10:47 +02:00
Shintomon Mathew
38cd720f76
creds: mask OAuth bearer token in trace logs
Masked OAuth bearer tokens in credential trace output by emitting ***
when a bearer token is present, matching the existing password redaction
behavior and preventing sensitive token disclosure in verbose/debug
logs.

Closes #21659
2026-05-18 23:53:41 +02:00