Commit graph

3374 commits

Author SHA1 Message Date
Stefan Eissing
7103a93b05
connections: use admin handles only for maintenance
Maintenance tasks like connection upkeep, liveliness checks and cache
eviction must only run on an admin handle, not the application transfer
from the calling context.

Then application transfers will get only attached to the connections
they actually work on. This makes `data->state.recent_conn_id`
meaningful for checks if a subsequent address is finding the previous
connection again.

One thing led to another:
- add Curl_get_admin(data), to obtain an admin handle for
  an application handle, inheriting some properties for
  connection operation.
- rename `Curl_easy *data` parameter to `Curl_easy *admin`
  where only admin handles should be passed. Add DEBUGASSERTs
  in the called function.
- rename `Curl_conn_terminate()` to `Curl_conn_close()`
  because this makes connections enter the shutdown close
  where possible.
- rename `Curl_cshutdn_terminate()` to `Curl_conn_terminate()`
  since this definitely kills the connection and does not
  involve a `cshutdn` instance.
- add Curl_share_lock_share(), Curl_share_unlock_share()
  so it possible to operate on a share without the passed
  easy handle having the share set.
  This catches a case where a shared needed to be locked
  but was not before. Adjust test1554 results.

Fixes #22567
Reported-by: cybertron10 on github
Closes #22572
2026-08-14 14:01:21 +02:00
hunterinvariants
574749016d
tests: verify AWS SigV4 redirect auth scope
Closes #22538
2026-08-12 16:22:07 +02:00
Alhuda Khan
f5378b88a9
content_encoding: exact-match the identity transfer-coding token
Verified by test 2119

Closes #22541
2026-08-11 17:36:19 +02:00
Stefan Eissing
2d30fd26a0
DoH: improvements
- decode results when individual requests are done
- makes happy eyeballing start asap
- remove doh_resp structures as no longer needed
- remove CURL_DNS_TYPE_NS, CURL_DNS_TYPE_CNAME and
  CURL_DNS_TYPE_DNAME from DoH
- DoH: do not set PIPEWAIT and SSL OPTS when url starts with http:
- mark Doh master handle as dirty after every sub-request, not only the last
- Doh: start probe on AAAA before A (was the other way).

cf-dns: set EXPIRE_HAPPY_EYEBALLS timer when waiting 50ms on AAAA
result or progress will not be triggered in time.

Add debug env var CURL_DBG_HE_AAAA_AWAIT_MS to override the
default 50ms on waiting for the AAAA result to arrive.

test2100: set CURL_DBG_HE_AAAA_AWAIT_MS to 60 seconds to
provide enough time for slow CI runs to sent all DoH requests.

closes #22514
2026-08-10 13:53:31 +02:00
Alhuda Khan
26fdb92c0a
mbedtls: enforce verifyhost when verifypeer is disabled
Verify in test 2118

Closes #22475
2026-08-09 17:45:20 +02:00
Daniel Stenberg
c04189523c
cookie: refuse to load cookies set against a PSL domain
Verified by test 409

Reported-by: 1rhino2 on hackerone

Closes #22500
2026-08-06 17:03:02 +02:00
Daniel Stenberg
b5716286e9
tests: keep test names shorter than 70 columns
- makes test names less complicated

- makes them less likely to wrap lines when using narrow terminals

- runtests now returns error for the test if the name is longer

- replace the "..." with a singe space

Closes #22492
2026-08-06 14:31:15 +02:00
Daniel Stenberg
56457f838c
test557: test curl_mv*printf() functions
These functions were previously untested in the test suite. This is just
a set of basic invokes to make sure they work. The core of these
functions is identical and is tested already.

  - curl_mvfprintf
  - curl_mvprintf
  - curl_mvsnprintf
  - curl_mvsprintf
  - curl_mvaprintf

Closes #22472
2026-08-03 16:24:06 +02:00
Daniel Stenberg
1f860394e6
lib1560: add CURLU_NO_GUESS_SCHEME tests
Closes #22469
2026-08-03 14:00:11 +02:00
Daniel Stenberg
a2b178d378
tests: convert unit test 1396 and 1398 into libtests
They were previously unit tests but used only public library functions.

Closes #22471
2026-08-03 13:55:53 +02:00
Daniel Stenberg
5eb2f0757e
curl: help category cleanups
- add 'mqtt' as a category
- add more protocol categories to several options
- make --data worded better to also cover MQTT

Closes #22447
2026-07-30 16:17:55 +02:00
Daniel Stenberg
573a6ec16b
urlapi: improved return codes
- add CURLUE_BACKSLASH that can be returned when a backslash was used
  where a forward one probably was intended.

- make CURLUE_NO_HOST higher priority than port number errors for URLs
  without hostname. Like in "http://::1"

- shortened some URL parser error strings

Extend test 1560 to verify.

Reported-by: kit-ty-kate on github
Fixes #22337
Closes #22408
2026-07-28 13:37:28 +02:00
Daniel Stenberg
c7328740ec
lib2405: adjust for non-threaded builds
- Attempt to fix the flakiness set in 9726fc8259
- Reduce macro use

Closes #22414
2026-07-28 13:30:26 +02:00
Matthew John Cheetham
a8881e5e1d spnego: block NTLM fallback in SPNEGO negotiation
- Switch the Windows SSPI identity struct to SEC_WINNT_AUTH_IDENTITY_EX
  to use !ntlm in PackageList to prevent NTLM from being offered.

- For GSS filter out NTLMSSP OID, and restrict via gss_set_neg_mechs()
  to prevent NTLM from being offered.

- Extend the GSS-API debug stub layer to support the NTLM blocking logic
  without a real Kerberos environment.

- Update test 2057 to check that negotiate auth is silently skipped with
  no Authorization header when only NTLM stub credentials are available.

- Add SPNEGO NTLM blocking test 2093 which verifies that Kerberos
  credentials still succeed when NTLM is blocked within SPNEGO.

- Suppress tests valgrind leak for MIT krb5 gss_display_status, since
  the leak is in the library and not in curl.

To suppress the tests valgrind leak, the wildcard '...' bridges over an
anonymous frame inside libgssapi_krb5.so that valgrind reports as '???'.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Aided-by: Johannes Schindelin

Closes https://github.com/curl/curl/pull/21315
Closes https://github.com/curl/curl/pull/22410
2026-07-27 17:28:52 -04:00
Viktor Szakats
6f39c854c8
runtests: fix mode="warn" tests passing unconditionally, fix test 1752
Fix test 1712 to pass curl C by setting `COLUMNS` to the highest
accepted value, and adjust expected results. To avoid envs with varying
lengths of `LOGDIR` affect the outcome.

Apply the same fix to test 459, though it wasn't affected in curl CI.

Also sync up test 433 `COLUMNS` value with these two tests for
consistency.

Ref: #22381
Follow-up to 8e3a2a64d1 #20666

Closes #22388
2026-07-26 22:50:50 +02:00
Daniel Stenberg
acf4498381
http: fix httpsig with auth-redir
Do not let unrelated credentials from a redirected URL bypass the
cross-host auth boundary

Verified by test 5023 to 5025

Follow-up to a55731050e

Closes #22395
2026-07-26 22:45:30 +02:00
Viktor Szakats
b2a5369e70
runtests: allow comments in setenv section, merge sections in test433
Closes #22389
2026-07-26 16:43:18 +02:00
Daniel Stenberg
9bcc64c39b
curl: make --httpsig-key take a key OR a file name for key
Verified by test 5022

Closes #22392
2026-07-25 22:10:30 +02:00
Sameeh Jubran
a55731050e
httpsig: add RFC 9421 HTTP Message Signatures support
Add support for signing outgoing HTTP requests per RFC 9421 using
Ed25519 or HMAC-SHA256 algorithms.

New libcurl options:
 - CURLOPT_HTTPSIG: signing algorithm ("ed25519" or "hmac-sha256")
 - CURLOPT_HTTPSIG_KEY: path to hex-encoded key file
 - CURLOPT_HTTPSIG_KEYID: key identifier for Signature-Input
 - CURLOPT_HTTPSIG_HEADERS: space-separated components to sign

New CLI flags: --httpsig, --httpsig-key, --httpsig-keyid,
--httpsig-headers

The crypto layer follows the sha256.c multi-backend pattern with
implementations for OpenSSL (EVP_DigestSign) and wolfSSL
(wc_ed25519_sign_msg). HMAC-SHA256 uses the existing Curl_hmacit()
infrastructure which works on all backends.

Verified by test 5000 to 5021

Assisted-by: Daniel Stenberg
Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
Closes #22386
Closes #21239
2026-07-25 16:25:37 +02:00
Stefan Eissing
e093c67f1c
connect: connection close tweaks
- connclose/streamclose/connkeep() remove description string that was
  never used anywhere. Add trace statements where reasons for closing
  were not already traced and maybe not obvious.
- multi_remove_handle: only lookup former connection in pool when
  transfer is set to connect only
- test1554: adapt expectations now that pool is less often locked

Closes #22379
2026-07-24 22:59:46 +02:00
Stefan Eissing
a954d87f0b
httpsrr: DoH with HTTPS, fix response handling
Fix handling of DoH response that only asks for HTTPS records.

Add test 2117 for checking that a HTTPS-RR resolve is processed,
even though the actual answer is invalid.

Closes #22372
2026-07-24 22:58:51 +02:00
Viktor Szakats
6bff85be68
tool_xattr: add support for Windows alternate data stream
Requires a supported filesystem, i.e. NTFS.

Example:
```console
> curl.exe https://curl.se/index.html --output test.txt --xattr --referer https://curl.se/
> cat < test.txt:Zone.Identifier

[ZoneTransfer]
HostUrl=https://curl.se/index.html
ReferrerUrl=https://curl.se/
```

Where newlines are CLRF, `ReferrerUrl` is set when using `--referer`
option.

Also:
- test688: make it test `--referer`.
- document `user.xdg.referrer.url` in `--xattr` man page.

Refs:
https://en.wikipedia.org/wiki/Mark_of_the_Web
https://en.wikipedia.org/wiki/NTFS#Alternate_data_stream_(ADS)
https://learn.microsoft.com/en-us/windows/win32/fileio/file-streams
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c54dec26-1551-4d3a-a0ea-4fa40f848eb3

Ref: #22345

Closes #22354
2026-07-22 12:27:39 +02:00
Graham Campbell
4dc236a109
thrdpool: retry failed thread starts while items wait
Verified in test 3306

Closes #22303
2026-07-21 23:35:18 +02:00
Stefan Eissing
7ad33fe56f
cf-dns: resolve on filter demand
Use separate dns cache entries for addresses (A+AAAA) and HTTPS-RR
results. That makes also "negative" results independent of each other.
Dns cache entries, once in use, can no longer be modified safely, as
concurrent use would require each access then to be done under lock. By
using separate entries, we can update a HTTPS entry without needing to
duplicate an existing address entry for the same host+port.

Connection filters can now ask for DNS resolves. This works at any time
during connection setup and while connect is going on.
`Curl_conn_dns_add_addr_resolve()` and
`Curl_conn_dns_add_https_resolve()` are used for that. They check if the
resolve is already ongoing, can be added to a resolve not started yet
or, as last resort, create a new filter instance and add it to the
connection (it's easier to add more filters than making the same filter
handle multiple resolves. Since DNS filters are removed once the
connection is established, there is no later penalty).

HTTPS-RR queries are added by the `HTTPS-CONNECT`, `SSL` and `QUIC`
filters. The latter will only do that when ECH is configured and
supported. That means we trigger HTTPS-RR queries only when the results
matter.

Add test_22_06 for ALPN influenced via HTTPS-RR when tunneling through a
proxy. This did not work before.

Adjust test2100 to use https: as the previous http: URL no longer
triggers HTTPS-RR resolves.

Closes #22216
2026-07-21 23:18:53 +02:00
Graham Campbell
5bb7d7a4f2
http: stop dropping large custom headers
Closes #22336
2026-07-21 00:37:46 +02:00
Graham Campbell
f0f84d1251
http: avoid length underflow in Curl_compareheader
Closes #22338
2026-07-21 00:14:07 +02:00
Stefan Eissing
009fd378e8
lib: add multi_wakeup_internal
For threaded resolving, added an additional socket/eventfd pair to the
multi handle for notifications from threads. The original "double use"
of the standard wakeup pair did lead to regressions for apps.

The API definition of curl_multi_poll/wait/wakeup is pretty tight
regarding what effects what and adding notifications on top of that
broke what apps perceived to be the contract.

Fixes #22272
Reported-by: Sergei Zimmerman
Closes #22274
2026-07-21 00:01:48 +02:00
Graham Campbell
820c014578 cfilters: fix event-based connection shutdown
- Adjust pollset during connection shutdown.

- Separate the FIRSTSOCKET and SECONDSOCKET check so that one being in
  connect or shutdown no longer adds poll events for the other.

- Fix shutdown state evaluation (as detailed below).

- Add a unit test for Curl_conn_adjust_pollset.

- Add a client for event testing.

- Test that shutdown sockets stay with the socket callback until done.

The pollset predicate now reads the connection's own shutdown state
rather than going through data->conn, and the EXPIRE_SHUTDOWN arming in
cshutdn_perform() works again: next_expire_ms started at 0 and could
never be set, so a peer that never sends a close_notify would still park
its connection forever, timeout or not.

Reported-by: pszemus@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/22282
Closes https://github.com/curl/curl/pull/22304
2026-07-17 04:00:56 -04:00
Daniel Stenberg
4176aba5e4
tool_cb_prg: avoid integer overflows
Verify in test 2093

Fixes #22316
Reported-by: xmoezzz on github
Closes #22328
2026-07-16 08:52:16 +02:00
Daniel Stenberg
f2fda908f9
lib1560: test CURLU_DEFAULT_PORT more
Closes #22314
2026-07-16 08:51:16 +02:00
Stefan Eissing
0dc22b690d
ssls: fix potential memory leak on import
Memory can be leaked when importing corrupted SSL session data that
carry the same data fields repeatedly.

Fixes #22323

Closes #22324
2026-07-15 22:18:04 +02:00
Graham Campbell
94fab2d210
test798: force IPv4 to avoid cross-runner port aliasing
`test798` is the only test fetching `http://localhost:%HTTPPORT` without
`-4`, since it needs the hostname for its folded `domain=localhost`
cookie. curl tries `::1` first, but the test HTTP server is IPv4-only.
On the BSDs, IPv4 and IPv6 have separate ephemeral port namespaces, so
with every test server binding port 0, another parallel runner's
IPv6-bound server can hold the same numeric port. curl then connects to
the wrong runner's server, which cannot open its own `log/N/test798` and
closes without a response, giving exit 52 and an empty `server.input`.

This PR fixes this flake by adding `-4` matches what tests 389 and 392
already do. Linux is immune because wildcard IPv6 binds occupy the IPv4
port too. Seen in
https://github.com/curl/curl/actions/runs/29229170329/job/86749470571.

Closes #22318
2026-07-15 22:06:07 +02:00
Daniel Stenberg
eecc273f6d
test1560: allow to build and run without LDAP support
Closes #22312
2026-07-13 22:04:43 +02:00
Alhuda Khan
9494750986
ftp: reject control bytes in ACCT and alternative-to-user
A CR or LF in the CURLOPT_FTP_ACCOUNT or CURLOPT_FTP_ALTERNATIVE_TO_USER
string split the control-channel command line and smuggled a second FTP
command. Reject a byte below 0x20 in both values before the command is
built.

Closes #22301
2026-07-13 08:46:45 +02:00
Alhuda Khan
c3f9ef13f6
mime: reject CR and LF in mail part name and filename
Closes #22247
2026-07-13 08:29:22 +02:00
Stefan Eissing
e89d5a1202
tests: remove test1701
Test 1701 did a HTTP/2 Upgrade in a HTTP/1.1 POST request. This will no
longer be supported in the upcoming nghttp2 release for security reasons
(Upgrade requests with body a re messy, error prone and can easily lead
to connection confusion).

As no other server we have supports this, remove the test.

Reported-by: firexinghe on github
Fixes #22280
Closes #22291
2026-07-12 18:03:48 +02:00
Viktor Szakats
50c244c74d
tests: skip test 311 for wolfSSL 5.9.2
To fix this for everyone running curl tests.

Also: drop workarounds for CI.

Refs:
https://github.com/wolfSSL/wolfssl/pull/10793
7dd269fc52

Ref: https://github.com/curl/curl/pull/22269#issuecomment-4892203666
Follow-up to 7183bec8fe #22269
Follow-up to 03f9751585 #22204

Closes #22286
2026-07-09 21:09:34 +02:00
Stefan Eissing
e0222c0029
test2114: fix reading from stdin
The test provides an invalid username, but no ':' with password, so that
the curl tool tries to read the password from stdin. That makes the test
hang, also in CI.

The check for invalid characters is happening when the CURLOPT_USERPWD
is applied to the URL, so when the transfer is started. Maybe the check
should happen also in setopt already.

The test hangs because tool_paramhlp.c:548 `checkpasswd()` does not see
a ':' and tries to read the password from stdin.

Fix: add a ':' in the tests invalid user setting, so that the read does
not happen.

Follow-up to ecaa344a7a

Closes #22264
2026-07-04 22:53:01 +02:00
Alhuda Khan
ecaa344a7a
url: reject control codes in credentials set via CURLOPT
Closes #22236
2026-07-04 12:28:29 +02:00
Daniel Stenberg
69ac867f98
TLS: drop support for TLS-SRP
The options will simply do nothing.

Closes #21965
2026-07-04 12:20:20 +02:00
Memduh Çelik
ddc76c24c5
tests: pin connection reuse rules for partial, host, and credentials
Add classic tests 3223-3226 and extend tests/http/test_12_reuse.py so that
connection reuse decisions are explicit:

- partial/aborted HTTP/1.1 responses must not reuse the connection
  (premature multi_done closes non-multiplexed conns)
- different target hostnames must not share a connection even when they
  resolve to the same address (url_match_destination)
- HTTP Basic credentials are per-request (PROTOPT_CREDSPERREQUEST), so
  different -u values still reuse; assert that with num_connects
- same host positive control reuses (num_connects 1 then 0)

Closes #22224
2026-06-30 09:57:00 +02:00
Patrick Monnerat
f02c53361e
sasl: fix zero-length response encoding
A sasl zero-length normal response is an empty string, unlike an initial
response. Since the encoding of a zero-length initial response is
protocol dependent, move its handling to the protocol-specific sendauth
procedure. Similarly, do not check for an '=' server message, as this
should normally never occur.

Update the erroneous tests accordingly.

Closes #22218
2026-06-30 08:58:33 +02:00
alhudz
bedeeaa4a7
smtp: reject CR and LF in the envelope address
Verified in test 2110

Closes #22119
2026-06-29 22:28:46 +02:00
Daniel Stenberg
8aeef462e3
config2setopt.c: refactor config2setopts
Introduce sub functions

Closes #22215
2026-06-29 22:24:57 +02:00
HwangRock
df350dd0d8
content_encoding: give a clear error on multi-member gzip
A gzip Content-Encoding response holding more than one gzip member made
curl decode the first member and then fail the transfer with a bare
CURLE_WRITE_ERROR and no hint about the cause. Detect the trailing
member and fail with a message that explains what happened.

Fixes #22156
Closes #22172
2026-06-29 22:21:34 +02:00
Viktor Szakats
39dec13ec0
build: always use local inet_pton()/inet_ntop() implementations
Also repurpose existing build-time feature checks into unit test 1961,
to verify.

Prior to this patch these functions were auto-detected with both
autotools and cmake. In case of autotools there was an extra
verification phase ensuring the functions work as expected. This step
required running the function, thus was limited to non-cross-builds. For
cross-builds and CMake it always used the system implementation if
present. On Windows it always used the local implementation, because
availability/use is complicated there.

After this patch all platforms, always use the local implementation,
which is known to be accurate. This makes curl behave more consistently,
and simplifies the build process, a fixes cross-builds and CMake
auto-detection differences.

Also:
- test1960: enable unconditionally.
- checksrc: disallow globally, allowlist in `block_ip.c` example.
- dnsd: verify ntop result for NULL before passing to printf.

Ref: https://github.com/curl/curl/pull/22137#issuecomment-4797440983
Ref: #22137
Ref: 8537a5b0bc #16577

Closes #22170
2026-06-27 01:24:39 +02:00
alhudz
65d8eaeaa2
gopher: reject CR and LF in the selector
Verifed in test 1609

Closes #22116
2026-06-26 23:09:43 +02:00
Alhuda Khan
a36384ab94
http: trim custom header name before the Authorization drop
A custom header name padded with blanks (`Authorization :`) missed the
exact-length compare and slipped past the cross-host Authorization and
Cookie drop, forwarding the header to the redirect target. Trim the
parsed name in both the request and proxy CONNECT header builders.

Closes #22178
2026-06-26 14:50:04 +02:00
Viktor Szakats
397b8f0ec6
tidy-up: docs, comments, typos, whitespace
- GHA/windows: mention `IgnoreStandardErrorWarningFormat=true`
  in comment.
- cmake: fix MIT/GNU GSS order in messages.
- drop some exclamation marks from messages.
- drop redundant ending newlines from messages.
- fold/unfold where possible.
- fix indent, whitespace, typos and other nits.

Closes #22185
2026-06-26 11:36:09 +02:00
Daniel Stenberg
c6c4c6a16d
test 1560: test RFC4291 style IPv6 IPv4-mapped addresses
Closes #22136
2026-06-25 11:03:18 +02:00