Commit graph

16698 commits

Author SHA1 Message Date
Stefan Eissing
f924489b25
ngtcp2: share common functionality
Share common functions/structs between ngtcp2 HTTP/3 and the proxy
version.

Fix bugs in proxy implementation when it comes to stream and pollset
handling and transfer lifetimes.

Curl_multi_xfer_sockbuf_borrow: work without multi

When a connection gets shutdown by a share, the easy handle used is
share->admin and it does not have a multi handle. In that case let
Curl_multi_xfer_sockbuf_borrow() allocate a buffer to be freed on
release.

This happens when a TLS filter sends its last notify through a HTTP/3
proxy tunnel.

Closes #21871
2026-06-10 13:28:05 +02:00
Daniel Stenberg
5c6b488035
digest: flush state on origin or credential change
Verified by test 1686

Closes #21944
2026-06-10 13:20:03 +02:00
A Johnston
084ceb6601
hsts: duplicate live HSTS data in curl_easy_duphandle
Verified by test 1922

Closes #21809
2026-06-09 16:51:47 +02:00
Viktor Szakats
014be82a66
tidy-up: drop redundant == NULL syntax
Where missed by checksrc.

Closes #21935
2026-06-09 14:37:36 +02:00
Viktor Szakats
59213abfb2
tidy-up: drop redundant != NULL syntax
Where missed by checksrc.

Closes #21932
2026-06-09 14:37:36 +02:00
Viktor Szakats
e37417e021
psl: require libpsl 0.16.0 (2016-12-10) or greater
Debian Stretch offers 0.17.0.

Ref: https://github.com/rockdaboot/libpsl/releases/tag/libpsl-0.16.0
Ref: https://sources.debian.org/src/libpsl/

Closes #21933
2026-06-09 14:34:57 +02:00
alhudz
62b118cf22
http-proxy: verify CONNECT response headers
Verifed by test 2107

Closes #21927
2026-06-09 13:56:28 +02:00
Daniel Stenberg
c7cba2fd2d
sigv4: URL encode the user name in the header
- split into sub functions
- add 'aws-sigv4' as keyword for many tests

Verify with test 3222

Reported-by: Trail of Bits
Closes #21923
2026-06-09 13:34:27 +02:00
Viktor Szakats
847aac066d
tidy-up: use uppercase TRUE/FALSE where missing
Keep it only in external API calls and C++ code.

Also:
- curlx/fopen: replace with `!!`.

Spotted by GitHub Code Quality in cf-socket.c.

Closes #21925
2026-06-09 12:52:08 +02:00
Yedaya Katsman
feb609f28b
cf-socket: store errno from do_connect in ctx->error
This fixes a misleading log in verbose mode when ipv6 connectivity isn't
available, presumably also in other cases:

```
* Immediate connect fail for 2a00:1450:4028:806::200e: Network is unreachable
* connect to 2a00:1450:4028:806::200e port 443 from :: port 0 failed: Success
```

Closes #21914
2026-06-09 11:12:14 +02:00
Daniel Stenberg
e66b81a532
cookie: tailmatch the domains for secure override
If a SECURE cookie is set for a sub-domain (`example.com`) and is then
attempted to get set again for more specific part of that domain
(`www.example.com`) without the SECURE property, the second occurance
should not be allowed.

Reported-by: Trail of Bits

Verified by test 3305
Closes #21910
2026-06-09 11:11:07 +02:00
Viktor Szakats
952b04474c
tidy-up: miscellaneous
- badwords: replace stray synonyms with 'null-terminator'.
- tests/FILEFORMAT.md: tidy up feature descriptions.
- printf: replace stray `%i` masks with `%d` for consistency.
- pytest: add comments for empty excepts to try silencing GitHub CodeQL
  warnings.
- tool1394, unit1675: merge nested `if`s.
- dnscache: fix typo in comment.
- fix whitespace, indent and newlines.

Closes #21921
2026-06-09 11:07:55 +02:00
Stefan Eissing
849317ff5c
ws: make pong sending lazy
Do not send PONG frames unless there is sufficient space left in the
websocket send buffer. A server might be lazy in reading our data and
intermediary PONG frames can be skipped by a client (RFC 6455, ch.
5.5.3).

Add test case measuring no real RSS increase on a server blasting with
PING frames.

Closes #21911
2026-06-09 11:05:34 +02:00
Daniel Stenberg
fb9a520873
peer.h: fix typo in comment
Closes #21920
2026-06-09 11:00:01 +02:00
Yedaya Katsman
7b9d74abf6
resolve: Mention in error that IP address is expected
If you try using a DNS name like connect-to supports it can be confusing that
it is illegal. Also make it a bit more readable

Closes #21913
2026-06-09 09:23:52 +02:00
Daniel Stenberg
a2b943b115
digest: escape control codes too
Since the username is decoded when used and control codes are accepted
in HTTP usernames in general, the username encoding for the Digest auth
needs to percent encode such bytes.

Verified by test 3221

Reported-by: Trail of Bits
Closes #21915
2026-06-09 09:20:47 +02:00
Daniel Stenberg
04afd16076
urlapi: URL decode hostname before IP address normalization
With this, IPv6 addresses that end with '%25' with no following zone id are
considered invalid.

Extend test 1560 to verify

Reported-by: Hem Parekh
Closes #21918
2026-06-09 08:42:19 +02:00
alhudz
7de0a7e71a
chunked: reject invalid bytes in trailer
Trailers are delivered to the application as headers via
CLIENTWRITE_TRAILER, but unlike regular response headers they skipped
the verify_header() checks, so a server could smuggle a nul byte (or
stray CR) into a header reaching CURLOPT_HEADERFUNCTION and
curl_easy_header().

Run each assembled trailer line through Curl_verify_header(), the same
validation used for normal headers.

Covered by the new test 2106.

Closes #21896
2026-06-08 13:56:10 +02:00
Stefan Eissing
d69bfad3fa
ssl native_ca_store: always reinit
Add bit `native_ca_store_opt` to keep the setting of
CURLOPT_(PROXY_)SSL_OPTIONS and use that to calculate every easy
transfer if a native CA store shall be used or not.

This avoids `native_ca_store` getting stuck on TRUE after being set
once.

Closes #21902
2026-06-08 13:53:54 +02:00
Stefan Eissing
435fb96dcf
netrc: remember and check filename loaded
Remember the filename of a loaded netrc file to detect changed
configurations in a reused easy handle.

Closes #21903
2026-06-08 13:53:02 +02:00
Viktor Szakats
39d5cead0d
libssh2: save non-standard port to known_hosts
Reported-by: dyingc on github
Fixes #21863

Closes #21874
2026-06-08 13:26:31 +02:00
Daniel Stenberg
5df33efab4
setopt: claer the "custom" CA booleans when set to NULL
Mark them as custom choices only when pointer is passed, and clear them
again when set to NULL.

Closes #21901
2026-06-08 12:37:35 +02:00
Daniel Stenberg
0618ffe50d
Revert "url: remove ssh_config_matches"
This reverts commit 3e9817cd1b.

The change was incorrect as the check was not for the options the commit
message mentions.

Reported-by: ByteRay on hackerone
Closes #21899
2026-06-08 09:09:58 +02:00
Viktor Szakats
7c34365cce
urlapi: fix memleaks on error in parse_hostname_login()
Detected by GitHub Code Quality

Follow-up to acd82c8bfd #11006
Follow-up to 4183b8fe9a #8049

Closes #21879
2026-06-08 00:42:51 +02:00
Stefan Eissing
fbcf10ab84
progress: fx CURLINFO time reporting
Whack the times reported for a transfer (see
https://curl.se/libcurl/c/curl_easy_getinfo.html#TIMES) into order for
all variations of up-/download, http/ftp etc. Make sure they are
reported in the documented order.

There is still the *possibility* of PRETRANSFER being longer then
POSTTRANSFER, if a server sends a response before an upload is done.
POST is the time the first response byte is received, and PRE is the
time the last byte was sent by curl.

This may happen with more likelihood on HTTP/2 and 3 for a server
rejected upload. But for successful uploads, the answer will almost over
come afterwards.

Undo the previous twists in lib500.c tests, adjust pytest timeline
checks.

Fixes #21828
Reported-by: BazaarAcc32 on github
Closes #21843
2026-06-07 14:39:10 +02:00
Daniel Stenberg
317bf7e8a8
ftplistparser: clear strings.target if not symlink
When the struct is passed to the CURLOPT_CHUNK_BGN_FUNCTION callback,
clear the pointer if the provided data is not a symlink.

Closes #21884
2026-06-07 00:26:51 +02:00
Daniel Stenberg
c3c2cfb65d
http: reject spurious CR bytes in headers
Verified by test 2105

Closes #21882
2026-06-06 22:54:25 +02:00
Vasiliy-Kkk
3b9f0972e2 schannel_verify: simplify CryptQueryObject use
- Specify that the content is base64 encoded, rather than rely on
  auto-detect.

- Remove unnecessary sanity check of the returned content type.

Closes https://github.com/curl/curl/pull/21760
2026-06-06 11:27:34 -04:00
Viktor Szakats
d3e9a815c4
tidy-up: miscellaneous
- fix typos.
- badword: add two new words.
- cpp: drop parentheses from standalone `#if` expressions.
- libssh: vertical-align comment block with others.
- clang-format.

Closes #21880
2026-06-05 16:57:38 +02:00
Viktor Szakats
982e19f231
vquic: drop stray casts for iovec.iov_len
Spotted by GitHub Code Quality

Closes #21877
2026-06-05 16:57:38 +02:00
Viktor Szakats
0c8c6f4fc0
libssh2: replace macro names with non-misspelled alternatives
They are available in libssh2 0.15+.

Closes #21876
2026-06-05 16:57:38 +02:00
Viktor Szakats
1b8f4dba28
tidy-up: drop stray casts for allocated pointers
Closes #21865
2026-06-05 12:24:01 +02:00
Viktor Szakats
cb307544ad
libssh2: sync version check with INTERNALS.md
Follow-up to cf3b9657bc

Closes #21868
2026-06-05 12:06:22 +02:00
Viktor Szakats
5c9ac36e58
libssh2: do not use deprecated macros when unavailable
To support building with `LIBSSH2_NO_DEPRECATED` macro defined, a future
libssh2 that may have dropped these macros.

Ref: https://github.com/libssh2/libssh2/pull/1977

Closes #21867
2026-06-05 12:06:22 +02:00
Viktor Szakats
3c7d136225
libssh2: use non-deprecated libssh2_knownhost_addc()
Supported since libssh2 v1.2.5. Replacing `libssh2_knownhost_add()`,
which was deprecated in that same version.

The new API supports a comment field.

Ref: https://github.com/libssh2/libssh2/pull/1977

Closes #21866
2026-06-05 12:06:22 +02:00
Stefan Eissing
56eca2afb4
quic: count zero length packets against max
With a flood of zero lenght UDP packets to curl, the receive loop might
run longer than intended to. Count such packets against the max to
terminate the loop as intended.

URL: https://hackerone.com/reports/3783438
Reported-by: vectorqueue on hackerone
Closes #21869
2026-06-05 09:14:21 +02:00
Daniel Stenberg
ef8f68568f
urlapi: simplify urlget_url somewhat
- make file_url() a separate function that returns a file:// URL
- group the checks that need scheme info

Closes #21856
2026-06-03 10:41:15 +02:00
Daniel Stenberg
6730081429
cookie: refactor parse_cookie_header
- introduce a few static helper functions
- simplify the bad octet checks
- simplify the too long cookie/value check

Closes #21854
2026-06-03 09:42:52 +02:00
Stefan Eissing
22d979400a
vquic: moving related things into subdir
Move QUIC related implementations into the vquic directory. Rename
files that implement a connection filter accordingly.

Closes #21848
2026-06-02 22:48:21 +02:00
Viktor Szakats
2932b7f56f
gtls: minor fixes and improvements
- fix GnuTLS function name reference in `Curl_gtls_shared_creds_create()`
  error message.
  Spotted by GitHub Code Quality.
- unfold a line.
- in `Curl_gtls_verifyserver()`:
  - report the failure of `gnutls_x509_crt_import()`.
    Spotted by GitHub Code Quality.
  - fix a minor inconsistency in error strings.
  - drop redundant NULL checks for `config->issuercert`.

Closes #21850
2026-06-02 21:59:41 +02:00
Vasiliy-Kkk
a79467343f schannel: use fopen instead CreateFile
- Refactor CA file reading to use the typical fopen/fread instead of
  CreateFile/ReadFile.

Closes https://github.com/curl/curl/pull/21773
2026-06-02 13:58:21 -04:00
Joshua Rogers
be6c4ee7fa
gtls: verify OCSP response signature in gtls_verify_ocsp_status
Since aeb1a281ca ("gtls: fix OCSP stapling management"), the function
parses the stapled OCSP response and reads the certificate status via
gnutls_ocsp_resp_get_single(), but never calls gnutls_ocsp_resp_verify()
or gnutls_ocsp_resp_verify_direct(). A response with a forged or
corrupted signature is accepted without question.

Fix by calling gnutls_ocsp_resp_verify() against the trust list obtained
from the session credentials immediately after gnutls_ocsp_resp_import().
This handles both directly-signed responses and delegated OCSP responders
without requiring the issuer certificate to be present in the peer chain.

The missing check only affects the CURLOPT_SSL_VERIFYSTATUS code path
when CURLOPT_SSL_VERIFYPEER is disabled. With peer verification enabled,
gnutls_certificate_verify_peers2() independently catches the invalid
response via GNUTLS_CERT_INVALID_OCSP_STATUS before
gtls_verify_ocsp_status() is reached. As a result, no attack is possible
that is not already trivially achievable without OCSP stapling when peer
verification is off. This is a correctness and consistency fix, not a
security vulnerability.

Reported-by: Joshua Rogers

Closes #21677
2026-06-02 13:30:35 +02:00
Joshua Rogers
d191de891a
telnet: honor CURLOPT_TIMEOUT in send_telnet_data()
The poll-before-write loop used -1 (infinite) as the Curl_poll timeout,
so a peer that stops reading could stall the transfer indefinitely,
bypassing CURLOPT_TIMEOUT. Use Curl_timeleft_ms() instead and return
CURLE_OPERATION_TIMEDOUT when the deadline is reached or exceeded.

Closes #21685
2026-06-02 11:43:00 +02:00
Stefan Eissing
31cb54e1fa
cfilters: remove close method
closing a filter chain and reconnecting it again is a complication
that only the HTTP/1.x proxy filter used. Remove it from all filters.

Instead, a filter can return CURLE_AGAIN during the connect phase
and the cf-setup filter will tear down all "sub filters" and restart
over.

With this, a filter never resets to the initial phase but progresses
through connect -> connected -> shutdown -> destroy once.

Closes #21831
2026-06-02 08:27:00 +02:00
Josef Cejka
ba600296d2
http: prefer chunked encoding over Content-Length: 0
Call http_size() before checking the request for empty body to prefer
Transfer-Encoding: chunked even if Content-Length is 0.

Closes #21706
2026-06-01 23:40:28 +02:00
Randall S. Becker
2a63957204
capsule: include arpa/inet.h for ntohs() declaration
Some platforms require inclusion of arpa/inet.h in order to use ntohs().

Follow-up to e78b1b3ecc #21153

Closes #21834
2026-06-01 23:36:04 +02:00
Viktor Szakats
d229055549
tidy-up: miscellaneous
- drop more uses of the word "just". (not enforced here)
- drop some uses of the "will" word.
- "then" -> "than".
- tests/http/testenv/curl.py: fix copy-paste typo in error message.
- pytest: replace `shutdownh` with `shutdown` in test names.
  Spotted by GitHub Code Quality.
- comment typos.
- whitespace and newlines fixes.

Closes #21830
2026-06-01 22:33:57 +02:00
Stefan Eissing
032b15c434
cf-setup: improve readability
Restructure the code in cf-setup connect to make it better readable what
is happening for establishing the connection's filter chain.

Closes #21827
2026-06-01 16:47:24 +02:00
Daniel Stenberg
c53426231d
setopt: CURLOPT_MAXCONNECTS set to 0 restores default value
Closes #21829
2026-06-01 16:46:10 +02:00
Stefan Eissing
12869080a1
data creds: detect change
Reshuffle code a little to detect when the transfer's credentials
actually change. Otherwise, leave the existing creds in place.

This gives the precise location where we may want to reset other
states that become invalid with change credentials. Also, by
keeping a creds instance as long as it is valid, we can associate
meta data with it.

Closes #21755
2026-06-01 16:42:10 +02:00