Commit graph

16956 commits

Author SHA1 Message Date
hunterinvariants
419f6404d4 schannel: reuse the send buffer
- Reuse a buffer for schannel_send instead of allocating and freeing a
  buffer for every send.

Closes https://github.com/curl/curl/pull/22540
2026-08-11 03:14:04 -04:00
anupamme
a61f2f9219
ldap: reject control characters in URL-decoded filter values
Closes #22524
2026-08-10 23:11:07 +02:00
Stefan Eissing
874a54de5d
multi: use index list for expire timeouts
Replace the `timeoutlist` and time nodes for expire timers with `struct
expire_timers` that keeps a time and next array.

There is only ever one timeout per timer id and a fully dynamic list is
not needed. Do the sorting by keeping an array of 'next' indiced and a
'first' starting point.

Added tracking of splay tree status.

Fixed missing splay removal when last timeout was removed via
Curl_expire_done().

Closes #22473
2026-08-10 23:07:13 +02:00
Viktor Szakats
5050196dcc
build: require !NDEBUG for debug-enabled (aka development) builds
To prevent creating a curl-development (aka debug-enabled, aka
`-DENABLE_DEBUG=ON`, `--enable-debug` or `DEBUGBUILD`) build without
`assert()`s. Since it may break expectations by missing to catch error
cases. Also to make it less likely to build an inherently insecure
development build by accident.

- in CMake, for non-Multi-Config builds, show this error unless Debug
  configuration is set at configure-time:
  ```
  CMake Error at CMakeLists.txt:263 (message):
    Debug-enabled (aka development mode) curl requires the Debug configuration
  ```
  Ref: https://github.com/curl/curl/actions/runs/31159065911/job/92805128331?pr=22513#step:6:56
  The other 3 predefined configs (`Release`, `RelWithDebInfo`,
  `MinSizeRel`) set `NDEBUG` automatically.

- or this message in other cases, e.g. when using CMake Multi-Config
  with non-Debug, e.g. `--config Release`, or passed `NDEBUG` manually
  with either build tools:
  ```
  curl_setup.h(1062): fatal error C1189: #error:
    "Debug-enabled builds cannot be combined with NDEBUG"
  ```
  Ref: https://github.com/curl/curl/actions/runs/31159628749/job/92807878479#step:9:28

Also:
- INSTALL-CMAKE.md: document.
- GHA/windows: adjust CI jobs to meet the above requirement, where
  missing.

Reported-by Stefan Eissing
Bug: https://github.com/curl/curl/pull/22484#discussion_r3730045572
Ref: ea98445680 #13592
Fixes #22481
Fixes #22484

Closes #22513
2026-08-10 18:14:09 +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
Viktor Szakats
791b6883ed
build: replace assert() with DEBUGASSERT(), where missing
Follow-up to 9a2663322c #17572
Follow-up to c96f982166 #10451

Closes #22521
2026-08-10 08:55:08 +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
Jay Satiro
b24346fe31 api: fix printf format specifier
- Use %hu for unsigned short instead of %u.

Prior to this change some compilers could warn of an argument type
mismatch. C argument promotion rules promote the unsigned short argument
to an int, which does not match %u (unsigned int) but does match %hu
(unsigned short).

Assisted-by: Viktor Szakats

Closes https://github.com/curl/curl/pull/22511
2026-08-08 11:32:18 -04:00
Daniel Stenberg
ff4bab0a68
ldap_do: refactor error handling and simplify show_vals function
- (much) less code repetition

- simplifies ldap_do somewhat

Closes #22510
2026-08-07 11:45:19 +02:00
Stefan Eissing
7f6a75664f
dnsd: add support for DoH
dnsd now opens UDP+TCP sockets and accepts http: DoH requests to obtain
the same, configured answers (records, delays, error codes) as over UDP.

DoH: use `async->queries_ongoing` like all other resolvers instead of
the internal `pending` counter. Fixes waiting for results.

Tests: in pytest, parameterize dnsd tests to use both DNS and DoH.

Closes #22506
2026-08-07 09:20:12 +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
26b9f3aa9b
rtsp: refactor method handling and improve error checks
- convert the method switch() to a simple table

- avoid converting the methods from external to internal numbers, they were
  the same anyway so keep the external ones, just use the old defines.

- fix range check. It wrongly used the method numbers as bitmask, which made
  the check not work previously. Also error on OOM.

- Dropped the session-id check. It too wrongly did a bitmask check which was
  wrong and never worked. When fixed, it broke test cases so I dropped the
  entire check.

- split out rtsp_setup_request() from rtsp_do()

- replace the httpversion variable with a define

Closes #22505
2026-08-06 14:51:32 +02:00
Daniel Stenberg
a478393759
psl: update a comment to understandable English
Closes #22502
2026-08-06 14:48:27 +02:00
Daniel Stenberg
abcb5349e3
cf-socket: disable TCP SYN retransmissions for localhost on Windows
Suggested-by: Marcel Jamin
URL: https://curl.se/mail/lib-2026-08/0002.html
URL: https://daniel.haxx.se/blog/2024/08/14/slow-tcp-connect-on-windows/

Closes #22494
2026-08-06 14:22:59 +02:00
Daniel Stenberg
90325ff044
http2: make server push transfers inherit share from parent
Reported-by: Stephan Zeisberg
Closes #22488
2026-08-05 11:52:08 +02:00
Stefan Eissing
69a224d6b4
vdns: directory for all DNS related sources
Move all DNS related source files from lib to lib/vdns. Fix
include paths, no furher changes.

Closes #22482
2026-08-05 08:09:07 +02:00
Stefan Eissing
73a05428d4
dnscache: use Curl_peer in resolve and dnscache operations
Removes unused/duplicate members in async/ares/doh structs.

Closes #22446
2026-08-04 10:49:11 +02:00
Daniel Stenberg
7acf124614
url: rename Curl_init_do => Curl_init_transfer
And correct some comments

Closes #22474
2026-08-04 09:08:53 +02:00
Viktor Szakats
a368fbe968
curl_ed25519: add GnuTLS support (via nettle, hogweed)
The necessary cryptography API is provided by nettle 3.1+, via its
'hogweed' library. The minimum GnuTLS version required by curl is 3.6.5,
which requires nettle 3.4.1+, so the API is always available.

Also:
- autotools: detect and use nettle's hogweed library.
- cmake/FindNettle: add support for the hogweed library.
- GHA/http3-linux: enable in the autotools/cmake GnuTLS jobs.

Ref: 4353ea025a

Closes #22456
2026-08-03 16:48:08 +02:00
Stefan Eissing
b3cd319655
curl_trc: remove unused expire timers
The expire timers
-  DNS_PER_NAME
-  DNS_PER_NAME2
-  HAPPY_EYEBALLS_DNS

are unused since we changed our happy eyeballing and handling of partial
resolve results.

Closes #22468
2026-08-03 13:10:16 +02:00
Daniel Stenberg
08679d89f5
multi: remove #if 0'ed code that uses old struct
Closes #22467
2026-08-03 10:55:44 +02:00
Daniel Stenberg
54371bca75
lib: update mentions of the legacy "sessionhandle"
It is now "Curl_easy"

Follow-up to 434f8d0389 (June 2016)

Closes #22463
2026-08-03 08:57:36 +02:00
Viktor Szakats
e9f6619694
curl_ed25519: drop unused wolfSSL random generator
Follow-up to a55731050e #22386 #21239

Closes #22451
2026-07-31 12:38:52 +02:00
Viktor Szakats
ca48bd076d
curl_ed25519: tidy-up backend fallback
Sync fallback logic with other crypto algos to:

- allow falling back to the next backend candidate when wolfSSL does not
  have ed25519 built in.

- de-duplicate fallback code.

Follow-up to a55731050e #22386 #21239

Closes #22450
2026-07-31 12:38:52 +02:00
Viktor Szakats
cb21a37a68
build: assume POSIX select() is available
This change effectively replaces an explicit compile-time #error with
a missing prototype error in environments not offering `select()`, and
saves curl-compatible systems from performing an explicit feature check.

Refs:
https://pubs.opengroup.org/onlinepubs/009695399/functions/pselect.html
https://linux.die.net/man/2/select

Closes #22448
2026-07-31 12:38:52 +02:00
Ramesh Adhikari
decc609085
h3-proxy: fix NULL deref when non-:status header arrives before :status
Closes #22449
2026-07-31 09:30:21 +02:00
Stefan Eissing
6e130eb484
apple-fast-udp: fix sendmsg_x partial results
When sending with sendmsg_x(), fix handling of last gso chunk being
smaller. Handle partial results correctly. Ignore SOCKEMSGSIZE by
reporting success which drops PMTUD probes into the void.

Closes #22429
2026-07-30 22:55:04 +02:00
Viktor Szakats
b84838073c
tidy-up: minor code fixes and improvements
- schannel: drop redundant parentheses.
- os400sys: drop redundant includes.
  Follow-up to ebc5212dac #22374
- pytest: replace `()` with `[]` to match rest of tests.
- libtests: constify some local pointers.
- libtests: drop redundant `(long)` casts.
- lib650: use `CURL_CSTRLEN()`.
  Follow-up to 59dc2bbe07 #22424

Closes #22444
2026-07-30 12:00:22 +02:00
Viktor Szakats
c4013cdb85
tidy-up: comments, messages, formatting
- 'null-terminate', sync casing.
- add an `#endif` comment.
- avoid a few instances of 'will'.
- configure: 'aws' -> 'aws-sigv4', where missing.
- unfold/fold lines.
- update memzero/strzero comments.
- uppercase 'CRLF'.

Closes #22443
2026-07-30 11:26:22 +02:00
Jay Satiro
c4fe0c7b9f ldap: support empty username and password
Prior to this change an empty username or password was passed to the
LDAP bind function as NULL instead of an empty string.

Regression since 8f71d0fd.

Reported-by: Yoshiro Yoneya

Fixes https://github.com/curl/curl/issues/22162
Closes https://github.com/curl/curl/pull/22196
2026-07-29 13:54:18 -04:00
Viktor Szakats
64f746ee1e
urlapi: clear password buffer on error path
Reported by Copilot
Bug: https://github.com/curl/curl/pull/21637#pullrequestreview-4809702512
Follow-up to 112a8b5adf #21637
Follow-up to 7c34365cce #21879

Closes #22432
2026-07-29 19:12:55 +02:00
Viktor Szakats
112a8b5adf
src: safely clear certain buffers
That may hold credentials or other sensitive data, or where we want to
ensure the zeroing is not optimized out by the compiler.

Credits-to: Daniel Gustafsson
Ref: #13589 (original attempt)
Ref: #21588

Follow-up to #21645
Follow-up to 066478f634 #21598

Closes #21637
2026-07-29 14:38:48 +02:00
Viktor Szakats
2a3804936d
src: improve curlx_memzero() internal APIs
- delete zero-and-free wrapper macros. (not yet used)
  To keep it simple.
- do NULL-check in `curlx_memzero()`.
  To avoid noise at call sites.
- add `curlx_strzero()` for null-terminated strings, also with
  NULL-check.

Ref: #21637
Follow-upt o 066478f634 #21598

Closes #21645
2026-07-29 13:54:07 +02:00
CatboxParadox
c7b1e10dc1
h2: bootstrap max streams from multi handle if in use
Closes #22418
2026-07-29 13:51:55 +02:00
Stefan Eissing
3974491c97
websocket: pause writing and meta data fix
When writing a decoded chunk of websocket data, always flush the writer
chain so that buffered data gets delivered before the ws meta data gets
updated.

Add client writer flags CURL_CW_FLAG_BLOWUP for writer types that may
significantly enlarge write sizes. This flag causes the pause writer to
be added and shrinks the write chunk sizes. We do not want that for
content decoders like WS that do not change the size.

Add test_20_13 to check that large frames are paused/unpaused correctly
with the matching meta data.

Fixes #22413
Reported-by: Hendrik Hübner
Closes #22416
2026-07-29 13:35:50 +02:00
Stefan Eissing
53565fbfd6
conncache: connection healthiness fix
Update the `lastchecked` timestamp on connection health checks when
successful to prevent repeated recalcs for a second.

Rename `seems_dead` to `seems_healthy` because the world is already
depressing enough.

Consider pending input on connection only unhealthy when the connection
has no transfers and is not multiplexed.

Closes #22412
2026-07-29 13:34:19 +02:00
Viktor Szakats
079a11bcba
vquic: add option to use Apple fast UDP
Using Apple's secret `SYS_recvmsg_x` and `SYS_sendmsg_x` syscalls for
receiving/sending batches of UDP packets.

Since it uses undocumented calls, it's experimental and disabled by
default.

To enable:
- autotools: `--enable-apple-fast-udp`
- cmake: `-DCURL_ENABLE_APPLE_FAST_UDP=ON`

Also:
- enable in two H3 CI jobs with both build tools, pytest and clang-tidy.

Refs:
https://max-inden.de/post/fast-udp-io-in-firefox/
https://www.macsyscalls.com/en/syscall/480-recvmsg-x
https://www.macsyscalls.com/en/syscall/481-sendmsg-x

C-code-authored-by: Stefan Eissing
Build-code-authored-by: Viktor Szakats

Closes #22341
Closes #22417
2026-07-29 11:53:19 +02:00
Viktor Szakats
59dc2bbe07
tidy-up: use CURL_CSTRLEN() macro on more static strings
Follow-up to e1450d8fda #22406

Closes #22424
2026-07-29 00:19:37 +02:00
Viktor Szakats
1386135d1c
schannel: fix error check logic in get_client_cert() file reader
Reported by GitHub Code Quality
Follow-up to 0fdf965126 #5193

Closes #22415
2026-07-28 19:29:34 +02:00
Viktor Szakats
75404bda1a
curl_gssapi: document/update feature availability
- update `GSS_C_DELEG_POLICY_FLAG` comment to include Apple GSS, add
  date, and amend MIT Kerberos version to 1.7+ (was: 1.8+)
  Ref: 45875a4d7b
  Ref: 1635de38a8

- document `HAVE_GSS_SET_NEG_MECHS`/`gss_set_neg_mechs()`.
  Ref: 079eed2cf7
  It's also committed to Heimdal, but not present in a release
  as of 7.8.0 (current latest).
  Ref: 735039dbdc

Follow-up to a8881e5e1d #21315 #22410
Follow-up to d169ad68fa #22052

Closes #22419
2026-07-28 19:20:41 +02:00
Viktor Szakats
e1450d8fda
tidy-up: use more static, sizeof(), char[], double-const
- make `const` data `static`, where missing and possible.
- replace `strlen()` on literal or const strings with `sizeof()`.
  While the latter is optimized by popular C compiler, e.g. MSVC only
  does it with `/O2`.
- replace magic numbers with `sizeof()`, where missing.
- introduce `CURL_CSTRLEN()` macro for `sizeof(char[]) - 1`.
- use `CURL_CSTRLEN()` macro.
- move `const` before integer types, where missing.
- replace `char *var` with `var[]`, where missing and possible.
- use double const, where missing.
  `static const char *` -> `static const char * const`.
- lib1514: constify pointers.
- unit3205: drop redundant cast, avoid another one.
- unit1666: map `OID()` macro to identical `STRCONST()`.

Closes #22406
2026-07-28 13:53:11 +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
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
Stefan Eissing
c9ead9bd1c
conncache: conn upkeep/alive: move and enhance
- move `Curl_conn_seems_dead()` into conncache.c
- move `Curl_conn_upkeep()` into conncache.c
- when upkeep gives an error on a connection not in use,
  terminate it

Closes #21806
2026-07-27 23:26:57 +02:00
Stefan Eissing
4eb4b0d080
vquic: use ngtcp2 v1.25.0 new close2 callback
Forward only the app error code from the receiving side to the h3 layer.

This only takes effect when building against ngtcp2 v1.25.0 or higher.

Fixes #22270

Closes #22356
2026-07-27 11:36:56 +02:00
Viktor Szakats
6350eb01ed
cf-ngtcp2-cmn: de-duplicate ngtcp2_conn_client_new() call code
Closes #22401
2026-07-27 10:17:15 +02:00
Viktor Szakats
e90c4397c8
vquic: silence -Wmissing-field-initializers for nghttp3/ngtcp2 callback tables
To avoid a breakage in CI and curl-for-win builds on upstream updates
extending the callback lists. Each such breakage needed patching curl,
rolling these patches into curl-for-win, and doing it in near real-time,
to keep CI and builds working (and still causing some red CI jobs).

Bring calmness here by suppressing the warnings and allowing time to
extend the callback tables as/if needed and at a convenient moment.

Closes #22400
2026-07-27 10:16:43 +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
e416e2948b
vquic: initialize new callback slot for nghttp3 v1.18.0+
Closes #22399
2026-07-26 16:43:18 +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