Commit graph

16673 commits

Author SHA1 Message Date
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
Daniel Stenberg
ff300ac4aa
setopt: defref the old referer when setting a new
Closes #21826
2026-06-01 15:23:04 +02:00
Stefan Eissing
d3391229b0
vtls_config: adjust to origin
When a transfer goes against another origin than the initial one, do not
add the following to the ssl configuration: client cert, client key, srp
user/pass, pinned key.

Closes #21695
2026-06-01 09:39:17 +02:00
Daniel Stenberg
1b6724882c
urlapi: accept 0X prefix in IPv4 address as well
Extend test 1560 accordingly

Closes #21820
2026-05-31 23:44:30 +02:00
tiymat
780ccb256e
urlapi: drop base fragment on empty redirect
Extended test 1560 to verify

Fixes #21745
Closes #21763
2026-05-31 23:36:16 +02:00
Stefan Eissing
4ff212f8ed
url: connection reuse fixes for starttls
Add test_31_13 to check connection reuse on mixed --ssl-reqd setting.
For that add debug env var CURL_DBG_NO_USE_SSL_ON_FIRST to disable
--ssl-reqd for the first url. Check that the connection without SSL
from the first url is not reused on the second URL that requires it.

Tweak special ftp: protocol check to fail a DEBUGASSERT on mismatched
`use_ssl` settings as that should have been caught before in the
connection reuse matching (imap/smtp etc. do not have this extra check
and rely on the general part doing its job).

Closes #21665
2026-05-31 23:29:15 +02:00
Viktor Szakats
f1a6f190a6
badwords: prefer 'workaround' (without hyphen)
Closes #21807
2026-05-31 22:05:54 +02:00
Viktor Szakats
c37405cb06
h3-proxy: fix callback return values, and a typo in tests
- replace literal -1 with `NGHTTP3_ERR_CALLBACK_FAILURE` in nghttp3
  callback.
- replace `NGHTTP3_ERR_CALLBACK_FAILURE` with
  `NGTCP2_ERR_CALLBACK_FAILURE` in ngtcp2 callbacks.
- test_60_h3_proxy: fix non-critical typo in symbol.

Spotted by GitHub Code Quality

Follow-up to e78b1b3ecc #21153

Closes #21802
2026-05-28 23:32:33 +02:00
Daniel Stenberg
5e66176733
http: don't pass on set cookies to new origins
Verified by test 2015

Reported-by: azraelxuemo on hackerone

Closes #21794
2026-05-28 17:45:04 +02:00
Viktor Szakats
a0c559ff03
h3: fix signedness of two printf masks
Follow-up to c2ca16f3ff #21799
2026-05-28 17:42:14 +02:00
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