Commit graph

38672 commits

Author SHA1 Message Date
Viktor Szakats
614b94eecc
tidy-up: miscellaneous
- avoid "will" in builds scripts, scripts folder, curl_easy_ssls_export.md,
  and few other files.
- badwords: add "initialise", "nul terminated", "thread safety" and
  variations.
- prefer "null-terminat", where missing (two places).
- fix "null-terminat*" missing dash.
- hostip: merge two `#if` blocks.
- tool_doswin: fix comment
  Spotted by GitHub Code Quality
  Follow-up to 9a2663322c #17572
- fix stray spaces and newlines.

Closes #21638
2026-05-16 01:56:17 +02:00
Viktor Szakats
47f411c6d8
GHA: enable -Wunused-macros in clang-tidy jobs
Also fix fallouts found.

Windows clang-tidy CI job is a little pickier than I'd prefer due to the
`_CURL_TESTS_CONCAT=ON` option used there, and all macros considered
local, thus checked by the compiler. Upside: it revealed macro usage
dynamics in tests. If too annoying, `first.h` may be opted-out from the
concat logic. Some macros may also be deleted instead of `#if 0`-ing.

Follow-up to e0e56e9ae4 #21550
Follow-up to 5fa5cb3825 #20593

Closes #21554
2026-05-16 01:17:41 +02:00
jeffhuang
a15483c4ca
url: compare full origin when setting credentials
Closes #21575
2026-05-16 01:14:29 +02:00
Stefan Eissing
91dcf4e610
url: url_match_destination fix
Match origin/via_peer also for non-SSL schemes.

Closes #21573
2026-05-16 01:11:06 +02:00
Sergio Correia
61d59c9e39
x509asn1: fix DH public key parameter extraction
The dh(g) parameter was read from param->beg instead of from the
cursor p returned by parsing dh(p). This caused dh(g) to always
report the same value as dh(p) when inspecting DH certificates
via CURLOPT_CERTINFO on non-OpenSSL backends.

The DSA branch correctly advances the cursor; the DH branch lost
this during what appears to be a copy-paste.

Add unit1676 to verify that dh(p) and dh(g) report distinct values
using a hand-crafted minimal DER certificate.

Assisted by: Claude Opus 4.6
Signed-off-by: Sergio Correia <scorreia@redhat.com>
Closes #21595
2026-05-16 01:06:56 +02:00
Daniel Stenberg
d6571f7a70
setopt: more careful cleanup of the HSTS cache
Reported-by: Joshua Rogers
Closes #21615
2026-05-16 01:04:54 +02:00
Emanuel Krollmann
978ea5afec
KNOWN_BUGS.md: remove fixed x509asn.1 bug
KNOWN_BUGS.md contains an entry about a CURLE_OUT_OF_MEMORY
error on a CURLOPT_CERTINFO call when using Schannel.

This bug was fixed by 137a668e8c.

remove the entry from KNOWN_BUGS.md.

Ref: https://github.com/curl/curl/issues/8741#issuecomment-4445486705

Closes #21611
2026-05-16 01:03:16 +02:00
Stefan Eissing
12d6d8e26f
cf-h2-proxy: drop interim responses
Any 1xx response before the CONNECT final one can be dropped as no one
uses those in the HTTP/2 proxy filter. This eliminates a potential
memory exhaustion by the famous malicious server on the internet.

Closes #21626
2026-05-16 01:01:18 +02:00
Daniel Stenberg
60cd4815fd
CURLOPT_SSH_HOSTKEYFUNCTION.md: for new connections only
curl can then reuse the connection for subsequent transfers without
calling this function again.

Fixes #21606
Reported-by: Joshua Rogers
Closes #21628
2026-05-16 00:54:40 +02:00
Viktor Szakats
066478f634
src: add curlx_memzero() to clear buffers securely
To safely zero memory, introduce `curlx_memzero()`, and map it to
`memset_s()` (C11) or `memset_explicit()` (C23) if auto-detected, or
`explicit_bzero()` or `explicit_memset()` for platforms opted-in, or
fall back to a local workaround if all unavailable. On Windows, always
use `SecureZeroMemory()`, or `SecureZeroMemory2()` with Visual Studio
and Windows SDK 10.0.26100.0+.

Details above are experimental and may change if they cause issues.

Also add macros/functions that zero memory before freeing a buffer:
- `curlx_safefreezero()`: for buffers with size.
- `curlx_safefreezeroz()`: for null-terminated buffers.
- `curlx_freezero()`: for buffers with size.
- `curlx_freezeroz()`: for null-terminated buffers.

`curlx_memzero()` must not be passed a NULL pointer because in some
implementations it is undefined behavior.

Also:
- curl_sha512_256: Replace hard-wired `explicit_memset()` call with new
  `curlx_memzero()`.

Refs:
https://en.cppreference.com/c/string/byte/memset
https://man7.org/linux/man-pages/man3/explicit_bzero.3.html
https://man.freebsd.org/cgi/man.cgi?query=explicit_bzero
https://man.netbsd.org/NetBSD-7.2/explicit_memset.3
https://learn.microsoft.com/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
https://learn.microsoft.com/windows/win32/memory/winbase-securezeromemory2
https://learn.microsoft.com/cpp/overview/compiler-versions
https://learn.microsoft.com/windows/apps/windows-sdk/downloads
https://jtsoya539.github.io/windows-sdk-versions/

Credits-to: Daniel Gustafsson
Credits-to: Will Cosgrove and co-authors in libssh2
Ref: #13589 (original attempt)
Ref: #21588

Closes #21598
2026-05-16 00:26:46 +02:00
Daniel Stenberg
831a151484
urlapi: consume trailing dots after IPv4 numerical addresses
If the hostname is specified as an IPv4 numerical address and it is
followed by a single dot, acccept that as a valid IPv4 and remove the
dot when normalizing.

This prevents otherwise legitimate IPv4 hostnames to have trailing dots.
Seems to match what browsers do.

Extended test 1560 to verify.

Closes #21635
2026-05-15 23:38:50 +02:00
Stefan Eissing
aafbe089a8
CURLOPT_SHARE: warn about early remove
Add a warning to removing a SHARE from an EASY handle before it is
finished.

Closes #21633
2026-05-15 16:15:28 +02:00
Daniel Stenberg
a15cfeb100
cookie: compare path case sensitively
Verify with test 1645

Reported-by: Joshua Rogers
Closes #21616
2026-05-15 13:37:52 +02:00
Daniel Stenberg
71430e87fd
strparse: make curlx_str_until() accept zero for 'max'
When asked to parse for a string with max zero bytes, it will always
return error and no longer trigger an assert. This saves the caller from
having to check for this condition.

Closes #21600
2026-05-15 13:28:03 +02:00
Viktor Szakats
de28c9cfad
rustls: drop two wrong leftover casts to ssize_t
While both source and target types are already `size_t`.

Spotted by GitHub Code Quality

Follow-up to b7c676d13f #17593

Closes #21625
2026-05-15 12:16:02 +02:00
Viktor Szakats
4780e509aa
tidy-up: prefer "initialize" with a 'z'
To match the majority of usage in source.

Closes #21618
2026-05-15 11:49:06 +02:00
Viktor Szakats
3da249e1f0
gsasl: fix potential double free
Also:
- require libgsasl 1.6.0+ (2010-12-14) for a `gsasl_finish()` that
  handles a NULL argument.
  Ref: b550032df8

Reported-by: Joshua Rogers (Aisle Research)

Closes #21609
2026-05-15 11:49:06 +02:00
Viktor Szakats
eb9b253d66
libssh: add support for SHA256 host public keys
Reported-by: Joshua Rogers
Fixes #21605

Closes #21607
2026-05-15 11:49:06 +02:00
Daniel Stenberg
9135294115
urlapi: deny hostnames with more than one trailing dot
Or consisting of just a single dot.

Such names cannot be resolved with DNS.

While they *can* still be resolved with /etc/hosts or --resolve tricks,
they easily cause internal problems because their trailing dots.

Let's not allow them anymore.

Closes #21622
2026-05-15 11:44:20 +02:00
Joshua Rogers
88bb7f885f
rustls: error on CURLOPT_CRLFILE with native CA store
Closes #21614
2026-05-15 10:25:55 +02:00
Viktor Szakats
976eb1d50d
windows: update MS SDK versions in comments
To make them more accurate.

Also:
- show Visual Studio version, where missing.
- ease the formatting.
- schannel_int.h: clang-tidy fallback code.

Used: `rg -l --sort=path CERT_FIND_HAS_PRIVATE_KEY`

Closes #21621
2026-05-15 03:41:33 +02:00
Viktor Szakats
ef068fc8b7
GHA: pin containers to hash (where missing)
Fixing this with zizmor v1.25.0:
```
error[unpinned-images]: unpinned image references
  --> .github/workflows/linux-old.yml:59:5
59 |     container: 'debian:stretch'
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ container image is not pinned to a SHA256 hash
   = help: audit documentation -> https://docs.zizmor.sh/audits/#unpinned-images
[...]
```
Ref: https://github.com/curl/curl/actions/runs/25890035949/job/76090925291?pr=21618

Sadly there is no automatic mechanism to bump them..

Also:
- replace `debian-stretch` with its slim variant.
- bump one of the two Alpine jobs from 3.20 to 3.23.4.

Closes #21619
2026-05-15 01:37:39 +02:00
Viktor Szakats
cc5eb4aba9
docs: fix a couple of typos
Spotted by GitHub Code Quality

Closes #21617
2026-05-15 01:37:38 +02:00
Viktor Szakats
5a869edb0f
creds: drop redundant CURL_UNCONST()s
Follow-up to 8f71d0fde5 #21548

Closes #21612
2026-05-15 01:37:38 +02:00
Viktor Szakats
27936d411a
lib: make __STDC_VERSION__ literals L (where missing) 2026-05-14 18:35:49 +02:00
Viktor Szakats
1a69c3a9c0
cmake: unfold a line 2026-05-14 16:33:23 +02:00
Viktor Szakats
db5d888673
GHA: explicitly brew update before brew install with Linuxbrew
Fixing:
```
==> Installing openssl@3 dependency: ca-certificates
==> Pouring ca-certificates--2026-05-14.all.bottle.tar.gz
Error: undefined method '[]' for nil
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/bottles.rb:127:in 'Utils::Bottles.load_tab'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:1507:in 'FormulaInstaller#pour'
[...]
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:114:in '<main>'
You have disabled automatic updates and have not updated today.
Do not report this issue until you've run `brew update` and tried again.
Error: Process completed with exit code 1.
```
Ref: https://github.com/curl/curl/actions/runs/25859030402/job/75984082148?pr=21607

Dropping `HOMEBREW_NO_AUTO_UPDATE=1` was not enough to fix it.

Closes #21608
2026-05-14 14:26:43 +02:00
Daniel Stenberg
81f950dd90
strparse: split a multi-line assert into many separate ones
This way we can better tell exactly which condition that triggers. Like
in fuzzer logs.

Closes #21599
2026-05-13 23:47:39 +02:00
0xN3R3K3
db4a6f286b
docs: fix grammar and wording in FAQ
Closes #21593
2026-05-13 23:19:26 +02:00
Viktor Szakats
a36c571984
pythonlint.sh: make it fail on error, fix ruff warnings in pytest
Follow-up to a5542c23e7 #21289
Follow-up to 17e8200733

Closes #21597
2026-05-13 22:59:36 +02:00
Viktor Szakats
e25e497c5e
cmake: merge if blocks (tidy-up)
Closes #21596
2026-05-13 22:47:56 +02:00
Viktor Szakats
616e8ea6d8
cookie: constify struct pointers
Closes #21589
2026-05-13 17:52:49 +02:00
Viktor Szakats
96dbcf6921
llist: constify struct pointers
Closes #21590
2026-05-13 17:40:42 +02:00
Daniel Stenberg
675a9b0189
urlapi: change more lowercase percent-encoded to uppercase
For consistency with other code, prefer uppercase.

Verified by test 1628
Reported-by: Fabian Keil
URL: https://curl.se/mail/lib-2026-05/0006.html
Closes #21592
2026-05-13 16:47:05 +02:00
Stefan Eissing
7f7e4e3e68
creds: create on service name only
Fix creation of creds object for transfer when only a sasl service
name is configured by the application.

Follow-up to 5e99b73cf4

Closes #21591
2026-05-13 16:37:15 +02:00
Daniel Stenberg
b079595f2e
url: keep the question mark for empty queries
Reported-by: Bill Mill
Fixes #21544

Verified by test 1721

Closes #21584
2026-05-13 14:34:54 +02:00
Daniel Stenberg
11df1251e5
snpego_sspi: preserve distinction btw policy-only and uncond delegation
CURLOPT_GSSAPI_DELEGATION exposes distinct modes:
CURLGSSAPI_DELEGATION_POLICY_FLAG is documented as delegating only when
OK-AS-DELEGATE policy permits it, while CURLGSSAPI_DELEGATION_FLAG is
unconditional. The new SSPI implementation checks for either bit and
sets ISC_REQ_DELEGATE, so a caller requesting policy-limited delegation
is put on the same SSPI path as unconditional delegation.

In addition, curl's existing protection that avoids reusing a connection
when the GSS delegation setting differs was guarded only by HAVE_GSSAPI;
SSPI-only builds now have an effective delegation option, but the
connection's delegation setting was neither copied nor compared. This
would cause Windows SSPI Negotiate/Kerberos authentication to delegate
credentials contrary to the caller's selected policy or reuse an
already-delegated authenticated connection for a transfer that requested
no delegation.

Follow-up to cc6777d939

Reported by Codex Security
Closes #21583
2026-05-13 14:34:08 +02:00
Stefan Eissing
5e99b73cf4
creds: add sasl service name
The SASL service name, used in authentication, is part of curl's credentials
when authenticating to a server/proxy. Make it part of `struct Curl_creds`.

Change code to use `creds` to obtain a service name. By tying creds used
to the connection, connection reuse is also only allowed when the service
name matches.

Closes #21585
2026-05-13 14:04:17 +02:00
Daniel Stenberg
b2476a0712
tool_urlglob: check glob use before access
As this function can now be invoked with only the second glob "active",
it must avoid accessing the first one if not in use.

Follow-up to 2238f0921c

Spotted by Codex Security

Closes #21586
2026-05-13 13:12:10 +02:00
Daniel Stenberg
2238f0921c
curl: named globs in output file name for upload glob references
Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:

    curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'

Verified by test 2014

Closes #21407
2026-05-13 10:07:50 +02:00
Daniel Stenberg
89f38c168c
CURLOPT_MAXFILESIZE: clarify this also works for on-going transfers
It was not really clear, but it has worked like this since 8.4.0 which
now is a while.

Closes #21582
2026-05-13 09:45:33 +02:00
Viktor Szakats
eca309c2a1
ldap: fix to not leak attribute on OOM (WinLDAP)
Reported-by: Andrew Nesbitt

Closes #21576
2026-05-13 00:43:27 +02:00
Viktor Szakats
54d5de5305
THANKS-filter: update
Source: https://github.com/andrew

Closes #21577
2026-05-13 00:43:27 +02:00
Andrei Rybak
a3618d166d
VULN-DISCLOSURE-POLICY.md: remove mention of bug bounty reward
As a follow-up to commits ca7ef4b817 ("BUG-BOUNTY.md: we stop the
bug-bounty end of Jan 2026", 2026-01-22) and ed7bf43a08 ("BUG-BOUNTY.md:
minor rephrase to say there is no bug bounty", 2026-03-10), remove a
leftover mention of the reward for vulnerability reports, that no longer
exists, in file `VULN-DISCLOSURE-POLICY.md`.

Fixes #21571
Reported-by: Alan De Smet
Closes #21574
2026-05-12 23:47:29 +02:00
Daniel Stenberg
287b082c63
tool_urlglob: better 'Duplicate glob name' position
This now points to where the duplicate name ends, not where it starts.

Also fixes test 2410 to use a fixed hostname so that the error position
remains the same.

Reported-by: Viktor Szakats
Fixes #21567
Closes #21568
2026-05-12 23:46:04 +02:00
Viktor Szakats
02dca1eb86
src: fix comment typos
Found by GitHub Code Quality

Closes #21570
2026-05-12 17:14:38 +02:00
Viktor Szakats
2538dc04e3
curl_ntlm_core: propagate DES CryptEncrypt() error
Spotted by GitHub Code Quality

Closes #21569
2026-05-12 17:14:38 +02:00
Stefan Eissing
8f71d0fde5
creds: hold credentials
Authorizdation credentials are kept in `struct Curl_creds`. This contains:

* `user`: the username, maybe the empty string
* `passwd`: the password, maybe the empty string
* `sasl_authzid`: the SASL authz value, maybe the empty string
* `oauth_bearer`: the OAUTH bearer token, maybe the empty string
* `source`: where the credentials from from
* `refcount`: a reference counter to link/unkink creds

A `creds` with all values empty is equivalent to NULL, e.g. no `creds`
instance. With reference counting, `creds` can be linked/unlinked
in several places.

See docs/internals/CREDENTIALS.md for use.

Closes #21548
2026-05-12 16:05:15 +02:00
Daniel Stenberg
a32a2b0b77
GHA: (re-)enable SMB in a few builds
Closes #21564
2026-05-12 14:53:48 +02:00
Viktor Szakats
82216163b1
curl_ntlm_core: fix nettle 4+ builds in certain MultiSSL combos
Also rename macro to resemble other backends.

Reported by Codex Security

Fixes #21562
Follow-up to 01f08dc4eb #21557

Closes #21566
2026-05-12 14:21:25 +02:00