Commit graph

39503 commits

Author SHA1 Message Date
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
Stefan Eissing
474ebb5247
api-guard: check lock on session cache
Add a property to easy/multi API calls that prohibit calling
the function when the involved SSL session cache is under lock
by the current thread.

Checks are only in effect when pthreads/Windows threads are
available.

Closes #22367
2026-07-24 22:57:58 +02:00
AlanKingPL
20c7877dcb terminal: Enhance terminal size detection for multiple outputs
- Get the terminal size from STDOUT or STDERR when the terminal size of
  STDIN is not available.

Closes https://github.com/curl/curl/pull/22276
2026-07-24 11:46:54 -04:00
Stefan Eissing
a479459ea3
http: fix non-tunneling proxy hostname use
Make sure hostname used in URL to proxy is IDN decoded form, but keep
the original hostname in case it was ipv6.

Fixes #22382
Reported-by: RMMoreton on github
Closes #22385
2026-07-24 16:27:41 +02:00
Graham Campbell
c8860532dd tests: fix the FTP check for unexpected RST
- In vsftpd ignore unrelated RST by matching tcpdump RSTs to the data
  connection port pair.

Prior to this change an unrelated RST on a recycled ephemeral port
could cause test failure.

Closes https://github.com/curl/curl/pull/22305
2026-07-24 04:31:09 -04:00
Stefan Eissing
545cdd4b50
asyn-thrdd: retry link-local ipv6 if missing scope id
When the threaded resolver gets AAAA results that carry a link-local
address without scope-id, it now re-queues a query with AF_UNSPEC and
strips ipv4 addresses from that result. Whatever the resulting addresses
and scope-ids are, this becomes the result of the resolve.

Fixes #22330
Reported-by: Bartel Sielski
Closes #22368
2026-07-23 22:26:43 +02:00
Alhuda Khan
489a4c1b48
ctype: exclude control bytes from ISPRINT and ISGRAPH
Closes #22371
2026-07-23 22:25:06 +02:00
Ross Burton
090056522b
configure: only check in the watt library if WATT_ROOT is set
Only look for gethostbyname in libwatt in $WATT_ROOT/lib if WATT_ROOT
has actually been set. This avoids configure trying to search in /lib,
which won't every succeed and can cause problems in cross builds which
check that host paths are not being searched.

Closes #22380
2026-07-23 22:04:15 +02:00
Viktor Szakats
8734b08883
tidy-up: miscellaneous
- CMake/CurlTests.c: sync indent with rest of file and most of code.
- cmake: sync term in `_CURL_PREFILL` description with rest of code.
- curl_setup.h: document function relying on `_CRT_SECURE_NO_WARNINGS`.
- tests/http/scorecard.py: typo in message.
- 'Quiche' -> 'quiche'.
- fix comment and formatting nits.

Closes #22378
2026-07-23 14:19:23 +02:00
Viktor Szakats
932e63aab9
md5: replace magic numbers with MD5_DIGEST_LEN
Closes #22377
2026-07-23 12:56:18 +02:00
Viktor Szakats
0ada20387c
tidy-up: fix Perl syntax and formatting nits
Closes #22376
2026-07-23 12:56:18 +02:00
Viktor Szakats
4b0cf12ab1
vms: fix symbol typo and missing closing quotes in config_h.com
Closes #22375
2026-07-23 12:42:56 +02:00
Viktor Szakats
3a0c600a1e
tidy-up: fix comment indentation
Closes #22373
2026-07-23 12:01:40 +02:00
Pavel Sobolev
381c3d56e3
ngtcp2: clean up after ngtcp2 in curl_global_cleanup
Frees the memory allocated by `ngtcp2_crypto_ossl_init`, thus making
Valgrind happy. Works for versions of ngtcp2 >= 1.24.0.

Ref: https://github.com/ngtcp2/ngtcp2/issues/2207

Closes #22363
2026-07-22 23:41:35 +02:00
Daniel Stenberg
2c3200f578
dnscache: avoid double unlock
Follow-up to 7ad33fe56f

Pointed out by Zeropath

Closes #22364
2026-07-22 23:17:35 +02:00
Viktor Szakats
41b4a91123
scripts: replace/extend -- with --end-of-options in git commands
It makes these scripts require Git 2.24.0+ (2019-11-04).

Refs:
https://git-scm.com/docs/gitcli
https://nesbitt.io/2026/07/21/end-of-options.html
19e8789b23

Closes #22369
2026-07-22 21:14:52 +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
11soda11
057b251358
tool_doswin: add stdin relay auth
Verify the peer with a random number in the background thread.

Closes #21467
2026-07-22 00:45:12 +02:00
Daniel Stenberg
a53bae7922
RELEASE-NOTES: synced 2026-07-21 23:55:11 +02:00
Stefan Eissing
0c4eebb3fa
test: adjust test_06_13 for 0100::/64 being blackholed
Fixes #22344
Reported-by: Carlos Henrique Lima Melara
Closes #22355
2026-07-21 23:52:35 +02:00
Alb3e3
c221469032
urlapi: preserve empty markers in relative URLs
Verified in test 1560

Closes #22298
2026-07-21 23:38:55 +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
dfc01ea2a3
hardening: add API guards
Add call stacks to easy and multi instances. Record ongoing API calls
and callback invocations there to detect recursion and not allowed
invocations.

Define enums for easy, multi and callbacks in `api.h`. In `api.c` define
properties for these functions:

- can they recurse
- is the easy/multi handle destroyed during the call or should it be
  good afterwards
- is the call allowed when a multi event callback is ongoing
- is the call allowed when a notification callback is ongoing

Entering a guard
- checks that passed CURL*/CURLM* are GOOD on entering
- checks that easy handle's `mid` is correct and it is known
  for it in the multi.
- checks that call properties are obeyed (recursion, callback checks)
- checks that passed CURL*/CURLM* are GOOD on leaving, unless call is
  known to kill it

Checks for ongoing callbacks inspect the whole call stack and catches
nested invocations (which our current flags can not).

Call stacks in easy/multi handle are fixed size and will deny recursion
when the limit is reached. The current limits are 7 for easy and 15 for
multi now.

Removes:
- multi->in_callback, check is done via call stack
- multi->in_ntfy_cb, check is done via call stack

The overhead in my tests seems minimal, if noticeable at all.

Closes #22237
2026-07-21 23:22:24 +02:00
Stefan Eissing
ab8d771d31
lib: reader/writer fixes
- clear writer paused bit when destroying writer stack
- remove the reader paused bit that turned out not to be a good idea

follow-up to b41c28e70a

Closes #22361
2026-07-21 23:20:35 +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
Stefan Eissing
c5fd5eb55a
uint-spbset: reused empty chunks
Fix chunk allocations by reusing existing empty chunks when a new offset
is needed. Before this fix, spbsets would only ever grow with added
numbers outside the range of existing chunks.

Closes #22340
2026-07-21 00:38:26 +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
b41c28e70a
lib: client writer tweaks
- keep pause state at request
- keep presense of content decoding writers at request
- only add cw-pause writer when content decoding happens
- define macro for passing data down the writer chain

scorecard: add option to test with h2o server

Closes #22335
2026-07-21 00:07:03 +02:00
Daniel Stenberg
f65253056a
cf-quiche.c: minor tidy-ups
Pointed out by the GitHub AI thing

Closes #22360
2026-07-21 00:03:59 +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
Viktor Szakats
bd58857201
vtls_scache: allocate absolute filename on heap (Windows)
To allow any full path lengths, beyond the 260 characters allowed by
`_MAX_PATH`.

Follow-up to fa0ccd9f1f #15774

Closes #22357
2026-07-20 19:16:08 +02:00
Keng-Yu Lin
703a999602
tests: fix type promotion on 32-bit arches in http test code
As reported in the bug:

> On a 32-bit architecture (i386):
> 1. `chunks * chunk_size` evaluates to `unsigned int` (32-bit
>    unsigned).
> 2. Due to Usual Arithmetic Conversions in C, the signed `-1` (int)
>    operand of the ternary operator is promoted to `unsigned int`,
>    yielding `4294967295` (0xFFFFFFFF).
> 3. The ternary operator returns `4294967295` as an `unsigned int`.
> 4. This unsigned value is then assigned to `r->clength` (apr_off_t,
>    64-bit signed). Since the source is unsigned, it is zero-extended,
>    resulting in `r->clength` becoming `+4294967295`.
> 5. The subsequently executed check `if(r->clength >= 0)` evaluates to
>    true.
> 6. Inside the block, `apr_ltoa(r->pool, (long)r->clength)` casts it to
>    a 32-bit signed `long` (on 32-bit platforms), which truncates it
>    back to `-1`, formatting it as "-1" and sending the
>    "Content-Length: -1" header.
>
> On a 64-bit architecture (amd64), `size_t` is 64-bit, and `-1` (32-bit
> int) is promoted to `unsigned long` (64-bit), yielding
> `18446744073709551615`. When assigned to `r->clength` (64-bit signed),
> it wraps back to `-1`, which correctly skips the Content-Length
> generation.
>
> This type promotion mismatch can be safely fixed by avoiding the
> signed/unsigned mixture in the ternary operator.

Origin: debian, https://bugs.debian.org/1140793
Bug-Debian: https://bugs.debian.org/1140793

These are standard Debian patches' trailers, I can get rid of then if you prefer.

I've tested the fix using [debusine on i386 runner](https://debusine.debian.net/debian/developers/artifact/4083252/raw/log):

> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.0] PASSED [ 17%]
> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.1] PASSED [ 18%]
> 782s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[h2] PASSED [ 18%]

Versus the [i386 run in Debian's infrastructure](https://debusine.debian.net/debian/developers/artifact/4084220/raw/log):

> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.0] FAILED [ 17%]
> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[http/1.1] PASSED [ 18%]
> 2690s tests/http/test_05_errors.py::TestErrors::test_05_04_unclean_tls_shutdown[h2] PASSED [ 18%]

Closes #22210
2026-07-20 19:13:53 +02:00
Viktor Szakats
1128177a6f
timeval: rename timer frequency variable
It's no longer a global variable.

Follow-up to 1027d07704 #22346

Closes #22347
2026-07-18 14:22:27 +02:00
Viktor Szakats
1027d07704
timeval: make Curl_freq variable static (Windows)
Follow-up to 64d4f5c4b6 #20852

Closes #22346
2026-07-18 03:12:41 +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
33dc64fd0e
urlapi: allow URLs to not have userauth (hostname)
Verified in test 1560

Fixes #22279
Reported-by: Bill Mill
Closes #22313
2026-07-16 10:02:05 +02: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
Graham Campbell
d0545d223a runtests: flush cached test parts when (re)loading a file
Force test file reload on client connect in ftpserver.

Closes #22319
2026-07-15 16:36:36 -07: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
Graham Campbell
b8c061c751
ngtcp2: let verify failures win over expiry processing errors
A flaky CI failure of `test_17_05_bad_ip_addr[h3]` (GnuTLS, event-based)
had curl detect the certificate name mismatch yet exit with
`CURLE_RECV_ERROR` (56) instead of `CURLE_PEER_FAILED_VERIFICATION`
(60). `Curl_cf_ngtcp2_cmn_connect` calls `Curl_cf_ngtcp2_cmn_set_expiry`
after its `ctx->tls_vrfy_result` override and returns the error
unfiltered, so when the server's final handshake flight happens to be
processed by the ingress inside set_expiry, the verify failure surfaces
as a generic receive error.

This PR makes set_expiry prefer `ctx->tls_vrfy_result` over generic
progress errors, as the recv and send paths already do after calling it,
and also covers the `cf-ngtcp2-proxy.c` call sites that lack the
override. Completes #21712. Seen in
https://github.com/curl/curl/actions/runs/29243256619/job/86794119412.

Closes #22317
2026-07-15 22:04:38 +02:00
renovate[bot]
8b5f1809bd
GHA: update dependency cloudflare/quiche to v0.29.3
Follow-up to f369c7ba43 #22331
Follow-up to 899e2edec9 #22333

Closes #22325
2026-07-15 22:00:26 +02:00
Graham Campbell
f369c7ba43
quiche: set the max field section size
quiche 0.29.3 started enforcing a default
`SETTINGS_MAX_FIELD_SECTION_SIZE` of 32 KiB, so larger response headers
now shut down the whole connection with `CURLE_HTTP3`. curl accepts up
to 300 KiB of response headers with every other backend and HTTP
version. Tell quiche to allow what curl itself allows. This keeps
test_01_11 passing with quiche 0.29.3 and it also advertises our real
limit to servers, which the RFC encourages.

Ref: 899e2edec9 #22333
Ref: #22329
Ref: #22325
Ref: 9be0e4fa18
Ref: https://github.com/cloudflare/quiche/releases/tag/0.29.3

Closes #22331
2026-07-15 21:52:07 +02:00
Viktor Szakats
899e2edec9
INTERNALS.md: require quiche 0.20.0+
For function `quiche_h3_config_set_max_field_section_size()`.

Ref: #22331
Ref: https://github.com/curl/curl/pull/22331#issuecomment-4981647189
Ref: https://github.com/cloudflare/quiche/releases/tag/0.20.0

Closes #22333
2026-07-15 21:26:04 +02:00
Viktor Szakats
5f2a70abe3
tidy-up: TEXT() vs _TEXT() vs _T() use (Windows)
Use `_TEXT()` when interacting with CRT functions (also prefer over
synonym `_T()`), `TEXT()` for Win32 functions.

Within curl, they mean the same because CRT/Win32 Unicode mode are
always enabled in sync.

Ref: https://devblogs.microsoft.com/oldnewthing/20040212-00/?p=40643/

Closes #22334
2026-07-15 21:26:04 +02:00
Viktor Szakats
d52c7e78a3
idn: restore MultiByteToWideChar() MB_ERR_INVALID_CHARS flag
Also:
- curlx: pass this flag to the actual conversion calls, for consistency
  and robustness. (It's not stricly necessary because the initial call
  to determine size, with this flag passed, fails already on bad input.)
- schannel: unfold `MultiByteToWideChar()` line (formatting).

Ref: https://learn.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar

Follow-up to 6694a42aa0 #19798

Closes #22326
2026-07-15 17:14:08 +02:00
renovate[bot]
cb81c5f4e2
GHA: update dependency codespell to v2.4.3
Closes #22332
2026-07-15 17:07:22 +02:00