]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
2 weeks agognutls: fix clang-tidy warning with !verbose
Viktor Szakats [Sun, 22 Mar 2026 11:40:23 +0000 (12:40 +0100)] 
gnutls: fix clang-tidy warning with !verbose

with
`-DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_USE_GNUTLS=ON -DCURL_CLANG_TIDY=ON`.

```
lib/vtls/gtls.c:268:7: error: Value stored to 'strerr' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
  268 |       strerr = gnutls_strerror(rc);
      |       ^        ~~~~~~~~~~~~~~~~~~~
```

Closes #21060

2 weeks agomulti.h: add CURLMNWC_CLEAR_ALL
Daniel Stenberg [Sat, 21 Mar 2026 22:06:02 +0000 (23:06 +0100)] 
multi.h: add CURLMNWC_CLEAR_ALL

The two bitmask constants for *CLEAR_DNS and *CLEAR_CONNS were
duplicates (both set to 1), so they cannot be distinguished and both
actions fire.

This shipped in public releases since 8.16.0 to and include 8.19.0.

This fix adds CURLMNWC_CLEAR_ALL to be the new 1, and it now implies all
bits. The DNS and CONNS defines get two new bits (2, 4).

Follow-up to 55c045c86338bfcc1de676c496f

Found by Codex Security
Closes #20968

2 weeks agoRevert "md5/md4: enable unaligned access fast path on powerpc64"
Daniel Stenberg [Sun, 22 Mar 2026 10:38:05 +0000 (11:38 +0100)] 
Revert "md5/md4: enable unaligned access fast path on powerpc64"

This reverts commit 21fc17b265ca32c8a5a768dc7cd730754a104740.

That was not properly thought through. PowerPC can run in either endian
and the preprocessor does not know which.

Ref: #20985
Closes #21058

2 weeks agoFAQ.md: point archive.org link to the original, no-JS, revision [ci skip]
Viktor Szakats [Sun, 22 Mar 2026 12:25:34 +0000 (13:25 +0100)] 
FAQ.md: point archive.org link to the original, no-JS, revision [ci skip]

To make it pass mdlinkcheck, open faster, w/o cookie banner, and not
need special URL format to make JS happy.

Ref: 1dc0ce956226186f40fdda072e7bd6c0cc035597

2 weeks agoRELEASE-NOTES: synced
Daniel Stenberg [Sun, 22 Mar 2026 11:02:49 +0000 (12:02 +0100)] 
RELEASE-NOTES: synced

2 weeks agolib: make SMB support opt-in
Daniel Stenberg [Sat, 21 Mar 2026 14:37:58 +0000 (15:37 +0100)] 
lib: make SMB support opt-in

The SMB protocol has weak security and is rarely used these days.

Note that SMB also requires NTLM enabled.

Closes #20846

2 weeks agoGHA/curl-for-win: enable c-ares with HTTPS-RR in an existing job
Viktor Szakats [Fri, 20 Mar 2026 13:08:22 +0000 (14:08 +0100)] 
GHA/curl-for-win: enable c-ares with HTTPS-RR in an existing job

c-ares builds have been sped up within curl-for-win using, pre-fills. It
allows building it with acceptable performance, making it practical to
use it, alongside HTTPS-RR, in curl CI and possibly in curl-for-win. It
has been enabled in its dev branch for a while.

Ref: https://github.com/curl/curl-for-win/commit/61a73541201692136af12548737781f79f1ecd64

Closes #21032

2 weeks agocf-https-connect: silence `-Wimplicit-int-enum-cast` with HTTPS-RR + clang 21
Viktor Szakats [Fri, 20 Mar 2026 12:41:25 +0000 (13:41 +0100)] 
cf-https-connect: silence `-Wimplicit-int-enum-cast` with HTTPS-RR + clang 21

Fixing (seen in curl-for-win dev branch):
```
In file included from _a64-linux-gnu-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:34:
lib/cf-https-connect.c:681:28: error: implicit conversion from 'unsigned char' to enumeration type 'enum alpnid' is invalid in C++ [-Werror,-Wimplicit-int-enum-cast]
  681 |         enum alpnid alpn = rr->alpns[i];
      |                     ~~~~   ^~~~~~~~~~~~e
```

Ref: #21032

Closes #21057

2 weeks agolib: drop support for < c-ares 1.16.0
Daniel Stenberg [Sat, 21 Mar 2026 13:15:53 +0000 (14:15 +0100)] 
lib: drop support for < c-ares 1.16.0

Closes #20911

2 weeks agomd5/md4: enable unaligned access fast path on powerpc64
Scott Boudreaux [Wed, 18 Mar 2026 15:56:09 +0000 (10:56 -0500)] 
md5/md4: enable unaligned access fast path on powerpc64

PowerPC64 (both big-endian and little-endian) supports efficient
unaligned memory access, similar to x86. This extends the existing
fast path that avoids byte-by-byte loads in the MD5 and MD4 SET/GET
macros.

On POWER8 ppc64le, this eliminates 3 shifts + 3 ORs per 32-bit word
load, replacing them with a single lwz (or lwbrx on big-endian).

Co Authored By Claude Opus 4.6 (1M context)

Closes #20985

2 weeks agoprogress: count amount of data "delivered" to application
Daniel Stenberg [Mon, 2 Mar 2026 10:02:03 +0000 (11:02 +0100)] 
progress: count amount of data "delivered" to application

... and apply the CURLOPT_MAXFILESIZE limit (if set) on that as well.
This effectively protects the user against "zip bombs".

Test case 1618 verifies using a 14 byte brotli payload that otherwise
explodes to 102400 zero bytes.

Closes #20787

2 weeks agonetrc: skip malformed macdef lines
Daniel Stenberg [Sat, 21 Mar 2026 14:23:28 +0000 (15:23 +0100)] 
netrc: skip malformed macdef lines

When skipping macdef lines inside netrc files, ignore it completely and
do not tokenize or bail out on bad quotes.

Verify in test 1672

Follow-up to 3b43a05e000aa8f65bda51

Spotted by Codex Security
Closes #21049

2 weeks agotest1668: unit test the FTP 213 time response parser
Daniel Stenberg [Sat, 21 Mar 2026 17:18:53 +0000 (18:18 +0100)] 
test1668: unit test the FTP 213 time response parser

Should make it harder to introduce regressions.

Closes #21051

2 weeks agobadwords-all: stop checking source code comments
Daniel Stenberg [Sat, 21 Mar 2026 13:43:38 +0000 (14:43 +0100)] 
badwords-all: stop checking source code comments

The code runs under different rules than documentation and these checks
cause too much friction with too little gain.

Leave checking of the public include files since they are almost
documentation.

Closes #21048

2 weeks agohostip: drop guard from `Curl_resolver_error()` definition
Viktor Szakats [Sat, 21 Mar 2026 20:58:36 +0000 (21:58 +0100)] 
hostip: drop guard from `Curl_resolver_error()` definition

To sync with its declaration.

Fixing (seen when building trurl in curl-for-win):
```
ld.lld: error: undefined symbol: Curl_resolver_error
```
Ref: https://github.com/curl/curl-for-win/actions/runs/23388349475/job/68038915761#step:3:7469

Closes #21054

2 weeks agotestcurl.pl: replace shell commands with Perl `rmtree()`
Viktor Szakats [Sat, 21 Mar 2026 18:36:10 +0000 (19:36 +0100)] 
testcurl.pl: replace shell commands with Perl `rmtree()`

Ref: https://perldoc.perl.org/5.8.2/File::Path
Follow-up to e992aa6a54f87f33eafd124cf09f0f70d7d24928

Closes #21053

2 weeks agotool: add check for curlinfo->age when determining if ssh backend is libssh2
Harry Sintonen [Sat, 21 Mar 2026 15:17:57 +0000 (17:17 +0200)] 
tool: add check for curlinfo->age when determining if ssh backend is libssh2

The code failed to check for the version, and could thus read memory
past the existing curl_version_info_data structure. This could lead to a
crash.

Closes #21050

2 weeks agocmake: add CMake Config-based dependency detection
Viktor Szakats [Tue, 3 Mar 2026 13:48:32 +0000 (14:48 +0100)] 
cmake: add CMake Config-based dependency detection

After limiting `find_package()`/`find_dependency()` calls to curl local
Find modules via the `MODULES` keyword, it became possible to detect
dependencies via CMake Configs from within those local Find modules, by
calling `find_package()` again with the `CONFIG` keyword. This patch
implements this. Then maps detection results to the result variables and
curl-specific imported targets the rest of the build expects.

Also honor recently introduced `*_USE_STATIC_LIBS` (experimental) flags
to map to the static target when requested.

This adds CMake Configs as an alternative to the existing `pkg-config`
and `find_path()`/`find_library()` auto-detection methods.

Enabled by default for MSVC, outside vcpkg and when not cross-building.
To enable for other cases, or override the default, you can use
`-DCURL_USE_CMAKECONFIG=ON` or `OFF`.

When enabled, Config detection happens after `pkg-config` and before
`find_path()`/`find_library()`. Using CMake's built-in options, you may
also manually point to the absolute directory holding Config files:

`Libssh2_DIR`, `MbedTLS_DIR`, `NGHTTP2_DIR`, `NGHTTP3_DIR`,
`NGTCP2_DIR` v1.19.0+ (with non-fork OpenSSL only), `Zstd_DIR` v1.4.5+

E.g. `-DMbedTLS_DIR=/path/to/mbedtls/lib/cmake/MbedTLS`

These dependencies typically need to be built with CMake to support
this.

Tagged as experimental.

Refs:
#20013 #19156 #19117
https://github.com/curl/curl/pull/20784#issuecomment-3984318492

Depends-on: fad1ebaecc0c489d38c0a9a155f63fdfd9086907 #20840
Follow-up to 91e06fde1b520bc29c7996749734451e03cd549f #20784
Follow-up to 26c39d8df182a63d28d81ed2b044e6a343519d1a #20015

Closes #20814

2 weeks agoGHA: add NTLM to lots of builds
Daniel Stenberg [Sat, 21 Mar 2026 11:30:31 +0000 (12:30 +0100)] 
GHA: add NTLM to lots of builds

2 weeks agobuild: make NTLM disabled by default
Daniel Stenberg [Sat, 21 Mar 2026 11:30:31 +0000 (12:30 +0100)] 
build: make NTLM disabled by default

NTLM has weak security and does not work over HTTP/2 or HTTP/3.

Enable in cmake or configure to get support for it.

Closes #20698

2 weeks agoDEPRECATE: remove last empty line
Daniel Stenberg [Sat, 21 Mar 2026 14:18:33 +0000 (15:18 +0100)] 
DEPRECATE: remove last empty line

2 weeks agortmp: drop support
Daniel Stenberg [Sat, 21 Mar 2026 11:14:21 +0000 (12:14 +0100)] 
rtmp: drop support

- librtmp has no test cases, makes no proper releases and has not had a
  single commit within the last year

- librtmp parses the URL itself and requires non-compliant URLs for this

- we have no RTMP tests

- RTMP was used by 2.2% of curl users (self-identified in the 2025
  survey)

Closes #20673

2 weeks agoDEPRECATE: fix minor release number typo
Daniel Stenberg [Sat, 21 Mar 2026 13:49:36 +0000 (14:49 +0100)] 
DEPRECATE: fix minor release number typo

2 weeks agocurlx_now(), prevent zero timestamp
Stefan Eissing [Fri, 20 Mar 2026 13:55:53 +0000 (14:55 +0100)] 
curlx_now(), prevent zero timestamp

As code checks `curltime` values for zero and interprets this
as not-initialized or "forever" in several places, make sure
`curlx_now()` never returns a zero timestamp.

Closes #21034

2 weeks agoCURLOPT_HAPROXY_CLIENT_IP.md: mention assuption on data format
Daniel Stenberg [Fri, 20 Mar 2026 22:41:11 +0000 (23:41 +0100)] 
CURLOPT_HAPROXY_CLIENT_IP.md: mention assuption on data format

The user is assumed to pass in correct data. I think we should start
clarifying this in more places.

Closes #21042

2 weeks agoshare: concurrency handling, easy updates
Stefan Eissing [Mon, 9 Mar 2026 14:40:34 +0000 (15:40 +0100)] 
share: concurrency handling, easy updates

Replace the `volatile int dirty` with a reference counter
protected by a mutex when available.

Solve the problem of when to call application's lock function
by adding a volatile flag that indicates a share has been added
to easy handles in its lifetime. That flag ever goes from
FALSE to TRUE, so volatile might work (in the absence of a mutex).

(The problem is that the lock/unlock functions need 2-3
`curl_share_setopt()` invocations to become usable and there
is no way of telling if the third will ever happen. Calling
the lock function before the 3rd setopt may crash the
application.)

When removing a share from an easy handle (or replacing it with
another share), detach the easy connection on a share with a
connection pool.

When cleaning up a share, allow this even if it is still used in
easy handles. It will be destroyed when the reference count
drops to 0.

Closes #20870

2 weeks agohostip: fix !no_signal mixup in resolve refaactor
Stefan Eissing [Sat, 21 Mar 2026 12:49:12 +0000 (13:49 +0100)] 
hostip: fix !no_signal mixup in resolve refaactor

When extracting the resolve case using alarm timers, the check for "we
are not allowed to use signals" was refactored wrong.

Follow-up to 96d5b5c688c48a8f58ded1563ed0c

Closes #21047

2 weeks agoGHA: update dependency rustls/rustls-ffi to v0.15.1
renovate[bot] [Sat, 21 Mar 2026 10:59:13 +0000 (10:59 +0000)] 
GHA: update dependency rustls/rustls-ffi to v0.15.1

Closes #21044

2 weeks agobuild: assume `snprintf()` in `mprintf`, drop feature check
Viktor Szakats [Fri, 27 Feb 2026 15:10:59 +0000 (16:10 +0100)] 
build: assume `snprintf()` in `mprintf`, drop feature check

- it was already required for `curl_*printf()` float/double support.
- some curl tests always fail without it.
- it was already assumed to be present to build test servers.
  Source code did not check for `HAVE_SNPRINTF` detection variable.
- it was already required to build examples.

Windows builds stopped using this detection and the function via earlier
commits.

Follow-up to 64f28b8f8859fc80816f7db3b5c4b6f2fd84bd27 #20765
Follow-up to 935b1bd4544a23a91d68ffb9f86983e92747e9a5 #9570 #9569

Closes #20763

2 weeks agocmake: drop support for CMake 3.17 and older
Viktor Szakats [Wed, 26 Nov 2025 18:07:19 +0000 (19:07 +0100)] 
cmake: drop support for CMake 3.17 and older

Require CMake 3.18 (2020-07-15) or newer, up from 3.7 (2016-11-11)
prior to this patch.

This requirement also applies to the distributed `curl-config.cmake`.

To allow dropping compatibility code maintained for old versions, and to
use features which were unpractical in separate code paths. Also to make
testing, documentation and development easier, CI builds faster due to
CMake performance improvements over time. (e.g. integration tests on
macOS run 8x faster (10 minutes is now under 1.5m) in CI, 2.5x faster on
Windows.)

CMake offers pre-built binaries for major platforms. They work without
an install step, just by unpacking and pointing the cmake command to
them. Making upgrades easy in many cases:
https://cmake.org/download/
https://cmake.org/files/
https://github.com/Kitware/CMake/releases

CMake 3.18 brings these feature as generally available when building or
consuming curl/libcurl:

LTO support, improved performance, `pkg-config` and interface target
support, `OBJECT` target (for faster libcurl builds), modern invocation
with `-S`/`-B` options, better support for custom linker options,
FetchContent, `GnuTLS::GnuTLS` target, `--verbose` and `--install`
options, `CMAKE_GENERATOR` env, last but not least unity mode and Ninja
generator.

For maximum build speed, use:
`-DCMAKE_UNITY_BUILD=ON -DCURL_DROP_UNUSED=ON`

As for deprecations, C++11 is required to build CMake itself, which may
be a limit on some platforms. autotools continues to cover them.

Follow-up to 9bcdfb3809a41327054421368bdea77ea17e6f90 #20408
Follow-up to a7c974e038572bd1d4a653afbd6de5fad5a10215 #19902
Follow-up to dfbe035c8b39b056a234bc76df3f384f7a7a24af #10161
Discussion: https://github.com/curl/curl/discussions/18704

Closes #20407

2 weeks agoscripts: drop redundant double-quotes: `"$var"` -> `$var` (Perl)
Viktor Szakats [Thu, 19 Mar 2026 00:15:43 +0000 (01:15 +0100)] 
scripts: drop redundant double-quotes: `"$var"` -> `$var` (Perl)

Closes #21009

2 weeks agocurl/curl.h: replace recursive macros with C++-friendly method to enforce 3 args
Viktor Szakats [Tue, 24 Feb 2026 11:45:59 +0000 (12:45 +0100)] 
curl/curl.h: replace recursive macros with C++-friendly method to enforce 3 args

Certain uses may still trigger a C compiler warning
`-Wdisabled-macro-expansion` after this, e.g. when the call is wrapped
in the `CURL_IGNORE_DEPRECATION()` macro as seen in docs/examples.

Suggested-by: Kai Pastor
Ref: https://github.com/curl/curl/issues/20682#issuecomment-3949788664

Follow-up to ee9b000438bd6e4cecc8a933804397a55ad0f7b8 #20686
Follow-up to daa6b27b4d998d62c8198b4fe167199cc7bf0064 #20597

Closes #20709

2 weeks agolibtest: drop duplicate include
Viktor Szakats [Sat, 21 Mar 2026 11:52:53 +0000 (12:52 +0100)] 
libtest: drop duplicate include

Include moved to `unitcheck.h` earlier.

Follow-up to 96d5b5c688c48a8f58ded1563ed0c5c47c877e32 #20864
Ref: 8a1f361716ab0bbf1e15f8a9914b9f1f07855bae #21024

Closes #21046

2 weeks agotool_operhlp: propagate low-level OOM in `add_file_name_to_url()`
Viktor Szakats [Sat, 21 Mar 2026 00:31:29 +0000 (01:31 +0100)] 
tool_operhlp: propagate low-level OOM in `add_file_name_to_url()`

Bug: https://github.com/curl/curl/pull/21011#discussion_r2961678069

Closes #21043

2 weeks agolib: move all UNITTEST prototypes to C files (cont.)
Viktor Szakats [Fri, 20 Mar 2026 11:55:46 +0000 (12:55 +0100)] 
lib: move all UNITTEST prototypes to C files (cont.)

Follow-up to 98d8e82c7471232639841eb63e16bb979a30acb4 #21014

Closes #21040

2 weeks agodnscache.h: include curlx/timeval.h for struct curltime
Daniel Stenberg [Sat, 21 Mar 2026 11:20:16 +0000 (12:20 +0100)] 
dnscache.h: include curlx/timeval.h for struct curltime

Follow-up to 96d5b5c688c48a8f5

Closes #21045

2 weeks agoftp: make the MDTM date parser stricter (again)
Daniel Stenberg [Fri, 20 Mar 2026 22:27:55 +0000 (23:27 +0100)] 
ftp: make the MDTM date parser stricter (again)

A previous refactor made the parser more lenient and this takes it back
to making sure only ascii digits are accepted.

Added test 1684 to verify

Follow-up to 304b5183fda43b5c5be

Pointed out by Codex Security

Closes #21041

2 weeks agodnscache: own source file, improvements
Stefan Eissing [Fri, 6 Mar 2026 08:22:26 +0000 (09:22 +0100)] 
dnscache: own source file, improvements

- Rename `Curl_resolv_unlink()` to `Curl_dns_entry_unlink()`.
- Change `Curl_dnscache_get()` to return CURLcode result. Returns
  now `CURLE_COULDNT_RESOLVE_HOST` for "negative" cache entries.
- Add `Curl_dnscache_add_negative()` to put a "negative" entry
  into the cache.

Closes #20864

2 weeks agoopenssl channel_binding: lookup digest algorithm without NID
Stefan Eissing [Thu, 26 Feb 2026 09:21:31 +0000 (10:21 +0100)] 
openssl channel_binding: lookup digest algorithm without NID

Use an alternate OpenSSL API to get the digest algorithm tied
to a certificate signature to compute the channel binding.

Fixes #20590
Reported-by: Rob Crittenden
Closes #20734

2 weeks agomulti: improve wakeup and wait code
Stefan Eissing [Fri, 6 Mar 2026 09:10:55 +0000 (10:10 +0100)] 
multi: improve wakeup and wait code

- Split WINSOCK and POSIX code in `multi_wait()` as the ifdef'ery
  was becoming unreadable
- define `ENABLE_WAKEUP` to mean the wakeup socketpair is enabled,
  no additional USE_WINSOCK check needed. Under WINSOCK
  `ENABLE_WAKEUP` is not defined, so it's availability is as before
  under the double defined() checks
- When the multi handle has "alive" transfers, the admin handle's
  pollset include the wakeup receive socket. This results in the
  admin handle running when someone uses `curl_multi_wakeup()`.
- Without any "alive" transfers, the wakeup socket is removed from
  the pollset. Otherwise, event based processing would never finish,
  eg. leave the event loop.
- The wakeup socket was never registered for event processing before,
  e.g. `curl_multi_wakeup()` never worked in that mode.
- Adjust test exepectations on socket callback invocations and
  number of sockets appearing in waitfds sets.

Closes #20832

2 weeks agoRELEASE-NOTES: synced
Daniel Stenberg [Fri, 20 Mar 2026 21:28:50 +0000 (22:28 +0100)] 
RELEASE-NOTES: synced

Bump curlver to 8.20.0 for pending release

3 weeks agoGHA/windows: disable `taskkill` in torture jobs
Viktor Szakats [Fri, 20 Mar 2026 18:00:44 +0000 (19:00 +0100)] 
GHA/windows: disable `taskkill` in torture jobs

As an experiment.

Also:
- processhelp.pm: log when `taskkill` is force-skipped.

Ref: #21035

Follow-up to f450f3801b6b9dff0ea280f5fb4bf28203f7b313 #19897
Follow-up to 2701ac6a4d16a62130dad05be1c484903b8545c7 #19421

Closes #21039

3 weeks agowolfssl: fix handling of abrupt connection close
Stefan Eissing [Thu, 19 Mar 2026 09:33:08 +0000 (10:33 +0100)] 
wolfssl: fix handling of abrupt connection close

A closed connection without TLS notify shutdowns, has been reported as a
correct EOF instead of an error. Fix the error handling in wolfSSL
backend receive handling.

Spotted by Codex Security

Closes #21002

3 weeks agotransfer: enable custom methods again on next transfer
Daniel Stenberg [Fri, 20 Mar 2026 16:28:03 +0000 (17:28 +0100)] 
transfer: enable custom methods again on next transfer

`http_ignorecustom` is set on redirect handling but was not reset
between transfers, so once a redirect occurs in the new follow modes,
custom request methods were ignored for later transfers on the same
handle.

Follow-up to fb13923dd67d5196c47e8d

Detected by Codex Security

Closes #21037

3 weeks agoprotcol.h: fix the CURLPROTO_MASK
Daniel Stenberg [Fri, 20 Mar 2026 12:55:47 +0000 (13:55 +0100)] 
protcol.h: fix the CURLPROTO_MASK

It had an 'f' too few. Also provide CURLPROTO_WS* unconditionally
internally, so that code can depend on them in all builds.

Follow-up to cd5ca80f00d2d9f0fe7

Spotted by Codex Security

Test case 3219 added to catch this next time.

Closes #21031

3 weeks agotool_operhlp: fix `add_file_name_to_url()` result on OOM
Viktor Szakats [Thu, 19 Mar 2026 14:47:05 +0000 (15:47 +0100)] 
tool_operhlp: fix `add_file_name_to_url()` result on OOM

Return `CURLE_OUT_OF_MEMORY` instead of `CURLE_URL_MALFORMAT` when
`curl_url()`, `curl_easy_escape()`, or `curl_maprintf()` calls failed.

Found by Codex Security

Also reuse deinit code from a success branch.

Closes #21011

3 weeks agourldata: make speeder_c uint32
Daniel Stenberg [Fri, 20 Mar 2026 14:55:33 +0000 (15:55 +0100)] 
urldata: make speeder_c uint32

This counter is meant to virtually never wrap.

Follow-up to e3691612ea1

Spotted by Codex Security

Closes #21036

3 weeks agounit1627.c: remove a newline
Daniel Stenberg [Fri, 20 Mar 2026 15:55:19 +0000 (16:55 +0100)] 
unit1627.c: remove a newline

3 weeks agoprotocol: use scheme names lowercase
Daniel Stenberg [Fri, 20 Mar 2026 13:28:51 +0000 (14:28 +0100)] 
protocol: use scheme names lowercase

When composing the <scheme>_proxy environment variable, we assume the
handler->scheme name is already lowercase.

This makes unit test 1627 verify that is the case.

Follow-up to c294f9cb564a2d550826cd5

Spotted by Codex Security

Closes #21033

3 weeks agofile: init fd to -1 to prevent close fd 0 on early failure
Daniel Stenberg [Fri, 20 Mar 2026 12:39:02 +0000 (13:39 +0100)] 
file: init fd to -1 to prevent close fd 0 on early failure

Spotted by Codex Security

Closes #21029

3 weeks agogetinfo: initialize `PureInfo` field `used_proxy`
Viktor Szakats [Fri, 20 Mar 2026 00:56:09 +0000 (01:56 +0100)] 
getinfo: initialize `PureInfo` field `used_proxy`

Found by Codex Security

Follow-up to cc04c7367740bb6db0e47368247b8b0c70c376cb #12719

Closes #21020

3 weeks agourl: use the socks type for socks proxy
Daniel Stenberg [Fri, 20 Mar 2026 10:06:47 +0000 (11:06 +0100)] 
url: use the socks type for socks proxy

Reported by Codex Security

Closes #21025

3 weeks agox509asn1: fixed and adapted for ASN1tostr unit testing
Daniel Stenberg [Thu, 19 Mar 2026 15:51:07 +0000 (16:51 +0100)] 
x509asn1: fixed and adapted for ASN1tostr unit testing

- move defines to header file
- make bit2str require < 8 unused bits
- make bool strings stricter
- make UTime2str show + or - for custom time zones
- removed unused 'type' argument to ASN1tostr() function
- fix int2str for negative values. All values below 10000 are now shown
  in decimal properly, also possibly negative values.

Add unit test 1667 to verify ASN1tostr

Closes #21013

3 weeks agotool_operate: drop the scheme-guessing in the -G handling
Daniel Stenberg [Wed, 18 Mar 2026 23:12:33 +0000 (00:12 +0100)] 
tool_operate: drop the scheme-guessing in the -G handling

Prior to this, -G would override the scheme set with --proto-default and
revert back to guessing the scheme based on the hostname.

Add test 2008 to verify the fix

Spotted by Codex Security

Closes #20992

3 weeks agobuild: limit `unitprotos.h` include to `units` target
Viktor Szakats [Fri, 20 Mar 2026 09:58:44 +0000 (10:58 +0100)] 
build: limit `unitprotos.h` include to `units` target

To omit it from `tunits`.

Also: move the include to `unitcheck.h` to save a guard.

Ref: https://github.com/curl/curl/pull/21014#issuecomment-4093742896
Reported-by: Daniel Stenberg
Fixes #21021
Follow-up to 98d8e82c7471232639841eb63e16bb979a30acb4 #21014

Closes #21024

3 weeks agotests/unit/README: describe how to unit test static functions 21018/head
Daniel Stenberg [Thu, 19 Mar 2026 22:05:05 +0000 (23:05 +0100)] 
tests/unit/README: describe how to unit test static functions

UNITTEST explained

Closes #21018

3 weeks agolib: move all UNITTEST prototypes to C files
Daniel Stenberg [Thu, 19 Mar 2026 16:04:00 +0000 (17:04 +0100)] 
lib: move all UNITTEST prototypes to C files

- make extract-unit-protos handle multi-line prototypes - but they need
  to be above the implementation

- Prototypes for static functions we use in unit tests should not be in
  header files. We generate lib/unitprotos.h for this purpose

- Removed some function wrappers written for unit tests and make them
  use UNITTEST function directly.

- Renamed time2str() in the tool to timebuf() since we have the same
  name in lib/ and in unit tests they can both be used non-static in a
  build.

This reverts commit f95fadd116d54f9031e3ba081e09e5a4f3aa7209.

Follow-up to #21010

Closes #21014

3 weeks agoGHA/macos: restore compatibility with Intel runners
Viktor Szakats [Thu, 19 Mar 2026 23:16:37 +0000 (00:16 +0100)] 
GHA/macos: restore compatibility with Intel runners

By generalizing Homebrew prefix in shared code paths, where missing.
No strong reason, sometimes it's useful for tests.

Follow-up to e5316069f13ec9189d9fe0499dc09afaa9fb5cee #18818

Closes #21019

3 weeks agomk-lib1521.pl: fix 4 callback function types passed to setopt
Viktor Szakats [Thu, 19 Mar 2026 21:43:56 +0000 (22:43 +0100)] 
mk-lib1521.pl: fix 4 callback function types passed to setopt

Silencing these warnings (seen on Solaris 11 SPARC GCC 4.9.2 + OpenCSW):
```
lib1521.c: In function 'test_lib1521':
/include/curl/typecheck-gcc.h:93:13: warning: call to 'Wcurl_easy_setopt_err_conv_cb' declared with attribute warning: curl_easy_setopt expects a curl_conv_callback argument
curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION,
curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION,
curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
/include/curl/typecheck-gcc.h:123:13: warning: call to 'Wcurl_easy_setopt_err_interleave_cb' declared with attribute warning: curl_easy_setopt expects a curl_interleave_callback argument
curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION,
```
Ref: https://curl.se/dev/log.cgi?id=20260319160651-1785427#prob2

Follow-up to de0adda78c4c3ce6d221beefdcd4492412dcf287

Closes #21017

3 weeks agoservers.pm: fix to check gopher6 server on its ipv6 port
Viktor Szakats [Thu, 19 Mar 2026 19:54:43 +0000 (20:54 +0100)] 
servers.pm: fix to check gopher6 server on its ipv6 port

Found by Codex Security

Closes #21016

3 weeks agocmake: extend C89-specific warning suppressions to all llvm/clang
Viktor Szakats [Thu, 19 Mar 2026 16:28:12 +0000 (17:28 +0100)] 
cmake: extend C89-specific warning suppressions to all llvm/clang

From Apple clang-only prior to this patch.

Silencing (seen after macos-15 runner accidentally switched to
llvm/clang by default):
```
/Users/runner/work/curl/curl/lib/curlx/warnless.h:64:1: error: '_Bool' is a C99 extension [-Werror,-Wc99-extensions]
   64 | bool curlx_sztouz(ssize_t sznum, size_t *puznum);
      | ^
/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include/stdbool.h:20:14: note: expanded from macro 'bool'
   20 | #define bool _Bool
      |              ^
[...]
```
Ref: https://github.com/curl/curl/actions/runs/23304345180/job/67774031335?pr=21014#step:11:39

Follow-up to 09c9afdd711d0b2ee9f524a235803e755e1074b7 #20363
Ref: https://github.com/actions/runner-images/issues/13827

Closes #21015

3 weeks agooptiontable: replace stdin with filename arg, harden `open()` call
Viktor Szakats [Thu, 19 Mar 2026 13:33:47 +0000 (14:33 +0100)] 
optiontable: replace stdin with filename arg, harden `open()` call

Closes #21008

3 weeks agox509asn1: move declaration to header
Viktor Szakats [Thu, 19 Mar 2026 13:47:12 +0000 (14:47 +0100)] 
x509asn1: move declaration to header

Fixing clang-tidy warning:
```
tests/unit/unit1666.c:50:12: error: call to undeclared function 'encodeOID'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]
   50 |   result = encodeOID(dbuf, oid, oid + spec->size);
      |            ^
```
Ref: https://github.com/curl/curl/actions/runs/23297585235/job/67749144361?pr=21008#step:46:736

Follow-up to 673e14cd33ef720b8c2b7e3485084e6e41a2c9dd #21003

Closes #21010

3 weeks agoscripts: harden / tidy up more Perl `system()` calls
Viktor Szakats [Thu, 19 Mar 2026 11:19:04 +0000 (12:19 +0100)] 
scripts: harden / tidy up more Perl `system()` calls

Closes #21007

3 weeks agodocs: enable more compiler warnings for C snippets, fix 3 finds
Viktor Szakats [Thu, 19 Mar 2026 11:34:32 +0000 (12:34 +0100)] 
docs: enable more compiler warnings for C snippets, fix 3 finds

Also:
- sync gcc option order.
- unfold lines in C snippet.

Closes #21006

3 weeks agox509asn1: improve encodeOID
Daniel Stenberg [Thu, 19 Mar 2026 08:55:46 +0000 (09:55 +0100)] 
x509asn1: improve encodeOID

- return error on zero length input
- return error on OOM or doing too large output
- fix full 32-bit number support
- fix the broken handling of the first and second numbers
- support up to 32-bit minus 80 for the second number
- a field with a leading 0x80 is now considered an error, since it only
  works as padding and is then no longer the shortest possible version

Add unit tests in 1666

Bonus: removed the last argument to OID2str() as it was always set TRUE.

Closes #21003

3 weeks agoinclude: drop 'will' from public headers
Viktor Szakats [Thu, 19 Mar 2026 01:59:42 +0000 (02:59 +0100)] 
include: drop 'will' from public headers

Closes #21005

3 weeks agoextract-unit-protos: retain internal paths for includes
Viktor Szakats [Thu, 19 Mar 2026 10:42:29 +0000 (11:42 +0100)] 
extract-unit-protos: retain internal paths for includes

Follow-up to 3058ed3df873c21ebba2007c3b12ed9f37558bfe #20623

Closes #21004

3 weeks agoexamples: fix typo in comment
Jason Stangroome [Thu, 19 Mar 2026 02:34:02 +0000 (13:34 +1100)] 
examples: fix typo in comment

noticed while reviewing https://github.com/curl/curl/pull/20793

Ref: https://github.com/curl/curl/pull/20793/changes#r2957089487

Closes #21001

3 weeks agoGHA: update dependency wolfSSL/wolfssl to v5.9.0
renovate[bot] [Thu, 19 Mar 2026 01:06:02 +0000 (01:06 +0000)] 
GHA: update dependency wolfSSL/wolfssl to v5.9.0

Closes #20998

3 weeks agomod_curltest: fix allocation size
Viktor Szakats [Wed, 18 Mar 2026 23:53:00 +0000 (00:53 +0100)] 
mod_curltest: fix allocation size

It wasn't causing an issue with current usage.

Found by Codex Security

Follow-up to 35cfb081d24ae4c1608601f71890e43907643ae5 #16541

Closes #20994

3 weeks agoopenssl: fix memory leaks in ECH code (OpenSSL 3)
Viktor Szakats [Wed, 18 Mar 2026 23:37:14 +0000 (00:37 +0100)] 
openssl: fix memory leaks in ECH code (OpenSSL 3)

Also drop an unnecessary cast.

Found by Codex Security

Follow-up to a362962b7289ec02b412890c9515657cf0ed50ac #11922

Closes #20993

3 weeks agotool_operate: fix condition for loading `curl-ca-bundle.crt` (Windows)
Viktor Szakats [Wed, 18 Mar 2026 19:27:24 +0000 (20:27 +0100)] 
tool_operate: fix condition for loading `curl-ca-bundle.crt` (Windows)

It was incorrecly loaded with env `CURL_CA_BUNDLE` unset +
`SSL_CERT_DIR` set + `SSL_CERT_FILE` unset.

Found by Codex Security

Follow-up to 29bce9857a12b6cfa726a506ab99c4c4c7969364 #11325 #11531

Closes #20989

3 weeks agosws: fix potential OOB write
Viktor Szakats [Wed, 18 Mar 2026 18:28:03 +0000 (19:28 +0100)] 
sws: fix potential OOB write

Found by Codex Security

Follow-up to 0aaebf62ec281286afb9e51f2a8088302463df3f

Closes #20988

3 weeks agosshserver.pl: harden more `system()` calls
Viktor Szakats [Thu, 19 Mar 2026 00:56:46 +0000 (01:56 +0100)] 
sshserver.pl: harden more `system()` calls

Ref: https://perldoc.perl.org/functions/system

Closes #20997

3 weeks agosshserver.pl: pass command-line to `system()` safely
Viktor Szakats [Thu, 19 Mar 2026 00:22:37 +0000 (01:22 +0100)] 
sshserver.pl: pass command-line to `system()` safely

Found by Codex Security

Follow-up to 89f306ae40b678bd91595ba41fe5f9d5ed374897 #16781

Closes #20996

3 weeks agox509asn1: fix to return error in an error case from `encodeOID()`
Viktor Szakats [Wed, 18 Mar 2026 23:11:33 +0000 (00:11 +0100)] 
x509asn1: fix to return error in an error case from `encodeOID()`

Found by Codex Security

Follow-up to d8b0318ad6da7e51f7c94df00a5f165a52580889 #3582

Closes #20991

3 weeks agobuild: enable `-Wimplicit-int-enum-cast` compiler warning, fix issues
Viktor Szakats [Wed, 18 Mar 2026 23:02:02 +0000 (00:02 +0100)] 
build: enable `-Wimplicit-int-enum-cast` compiler warning, fix issues

Offered by clang 21+.

Closes #20990

3 weeks agosynctime: fix off-by-one read and write to a read-only buffer (Windows)
Viktor Szakats [Wed, 18 Mar 2026 18:01:10 +0000 (19:01 +0100)] 
synctime: fix off-by-one read and write to a read-only buffer (Windows)

Also making the `--synctime` option work.

Off-by-one found by Codex Security

Assisted-by: Jay Satiro
Closes #20987

3 weeks agoasyn-ares: drop orphaned variable references
Viktor Szakats [Thu, 19 Mar 2026 01:07:21 +0000 (02:07 +0100)] 
asyn-ares: drop orphaned variable references

In rare, conditional `#if` branches.

Found by Codex Security

Follow-up to ac7e2c3dc693b43c61898aea89f1a80037505c36 #17450
Follow-up to 7bf576064c21fe0bb03a67c382d692ebbb9e3426 #17167

Closes #20999

3 weeks agoGHA: update dependency nghttp2/nghttp2 to v1.68.1
renovate[bot] [Wed, 18 Mar 2026 12:08:00 +0000 (12:08 +0000)] 
GHA: update dependency nghttp2/nghttp2 to v1.68.1

Closes #20982

3 weeks agorand: use `BCryptGenRandom()` in UWP builds
Viktor Szakats [Wed, 18 Mar 2026 13:13:07 +0000 (14:13 +0100)] 
rand: use `BCryptGenRandom()` in UWP builds

Also:
- fix build configuration to correctly set Win10 target in the mingw-w64
  CI build, to enable the `BCryptGenRandom()` prototype in v6+ SDK
  headers.

Ref: https://learn.microsoft.com/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom

Issue raised by Codex Security

Closes #20983

3 weeks agolib: always use Curl_1st_fatal instead of Curl_1st_err
Stefan Eissing [Wed, 18 Mar 2026 10:37:18 +0000 (11:37 +0100)] 
lib: always use Curl_1st_fatal instead of Curl_1st_err

Curl_1st_err() does not return the second error if the first result is
CURLE_AGAIN. This may cause errors to not become noticeable when they
should be.

Replace all use of Curl_1st_err() with Curl_1st_fatal(), which handles
CURLE_AGAIN as a not-a-real-error case.

Closes #20980

3 weeks agoscripts: drop unused CI scripts
Viktor Szakats [Wed, 18 Mar 2026 11:03:04 +0000 (12:03 +0100)] 
scripts: drop unused CI scripts

Replaced by Test Clutch:
https://testclutch.curl.se/static/reports/feature-matrix.html

Closes #20981

3 weeks agobadwords: prefer 'null-terminated'
Viktor Szakats [Wed, 18 Mar 2026 10:29:53 +0000 (11:29 +0100)] 
badwords: prefer 'null-terminated'

Aligning with existing text.

Closes #20979

3 weeks agoexamples/websocket: fix to sleep more on Windows
Viktor Szakats [Wed, 18 Mar 2026 10:12:04 +0000 (11:12 +0100)] 
examples/websocket: fix to sleep more on Windows

Found by Codex Security

Follow-up to d4b85890555388bec212b75f47a5c1a48705b156 #13771

Closes #20978

3 weeks agodelta: avoid potential zero division
Viktor Szakats [Wed, 18 Mar 2026 09:54:27 +0000 (10:54 +0100)] 
delta: avoid potential zero division

Found by Codex Security

Closes #20977

3 weeks agogcc: guard `#pragma diagnostic` in core code for <4.6, disable picky warnings
Viktor Szakats [Thu, 12 Mar 2026 09:58:35 +0000 (10:58 +0100)] 
gcc: guard `#pragma diagnostic` in core code for <4.6, disable picky warnings

Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98ae113b832a8748ba66e1554a7f14c6897e #20366
Fixes #20892
Fixes #20924
Closes #20902
Closes #20907

3 weeks agoftp: reject PWD responses containing control characters
Ercan Ermis [Tue, 17 Mar 2026 08:47:24 +0000 (09:47 +0100)] 
ftp: reject PWD responses containing control characters

A malicious or compromised FTP server could include control characters
(e.g. bare \r, or bytes 0x01-0x1f/0x7f) inside the quoted directory path
of its 257 PWD response. That string is stored verbatim as
ftpc->entrypath and later sent unescaped in a CWD command on connection
reuse via Curl_pp_sendf(), which performs no sanitization before
appending \r\n.

Reject the entire path if any control character is encountered during
extraction so that tainted data never reaches a subsequent FTP command.

Add test case 3217 and 3218 to verify. Adjusted test 1152 accordingly.

Closes #20949

3 weeks agobadwords: pass config as filename arg
Viktor Szakats [Tue, 17 Mar 2026 23:51:08 +0000 (00:51 +0100)] 
badwords: pass config as filename arg

Instead of stdin.

To simplify the command-line, and allow using a safe and portable
`system()` call from `badwords-all`.

Ref: https://perldoc.perl.org/functions/system

Closes #20970

3 weeks agourlapi: make dedotdotify handle leading dots correctly
Daniel Stenberg [Wed, 18 Mar 2026 08:14:59 +0000 (09:14 +0100)] 
urlapi: make dedotdotify handle leading dots correctly

Paths starting with one or two leading dots but without a following
slash were not handled correctly.

Follow-up to c31dd6631f9a0177aa9045cdbb

Extended test 1395 accordingly with a set of new test string.

Reported by Codex Security

Closes #20974

3 weeks agotool_msgs: avoid null pointer deref for early errors
Daniel Stenberg [Tue, 17 Mar 2026 23:00:52 +0000 (00:00 +0100)] 
tool_msgs: avoid null pointer deref for early errors

When errorf()/warnf() is used early on, before the global pointer is
setup, curl would previosly deref the null pointer.

Follow-up to 3b40128b0f11a3

Found by Codex Security

Closes #20967

3 weeks agohttp2: clear the h2 session at delete
Daniel Stenberg [Wed, 18 Mar 2026 09:12:46 +0000 (10:12 +0100)] 
http2: clear the h2 session at delete

When calling nghttp2 to delete session, clear the pointer to avoid risk
of UAF.

Pointed out by Codex Security

Closes #20975

3 weeks agoasyn-ares: fix HTTPS-lookup when not on port 443
Daniel Stenberg [Tue, 17 Mar 2026 22:53:33 +0000 (23:53 +0100)] 
asyn-ares: fix HTTPS-lookup when not on port 443

Follow-up to 8d0bfe74fba1e8394e73d

Spotted by Codex Security

Closes #20966

3 weeks agotop-complexity: prevent filename-based shell injection risk
Daniel Stenberg [Tue, 17 Mar 2026 23:14:35 +0000 (00:14 +0100)] 
top-complexity: prevent filename-based shell injection risk

As we run this script in CI, this should reduce the risk of mischief

Found by Codex Security

Closes #20969

3 weeks agotool_formparse: propagate my_get_line errors when reading headers
Daniel Stenberg [Tue, 17 Mar 2026 15:22:54 +0000 (16:22 +0100)] 
tool_formparse: propagate my_get_line errors when reading headers

The read_field_headers() function would return "ok" even if the
underlying file read returned error, thus would the parent not become
aware of the problem.

Follow-up to f847d2ed0244319ee6b5e9b054c

Found by Codex Security

Closes #20963

3 weeks agogenerate.bat: remove extra % from VC11 and VC12 runs
Daniel Stenberg [Tue, 17 Mar 2026 15:46:02 +0000 (16:46 +0100)] 
generate.bat: remove extra % from VC11 and VC12 runs

The extra % translates to nothing, so this did not break anything they
are just superfluous.

Follow-up to 57d349fe0eee7e1f3eb68dc

Assisted-by: Viktor Szakats
Found by Codex Security

3 weeks agocmake: document functions used from Windows system DLLs
Viktor Szakats [Tue, 17 Mar 2026 19:20:13 +0000 (20:20 +0100)] 
cmake: document functions used from Windows system DLLs

Closes #20965

3 weeks agoRELEASE-NOTES: synced
Daniel Stenberg [Tue, 17 Mar 2026 16:05:15 +0000 (17:05 +0100)] 
RELEASE-NOTES: synced

3 weeks agonetrc: refactor into smaller sub functions
Daniel Stenberg [Mon, 9 Mar 2026 07:38:14 +0000 (08:38 +0100)] 
netrc: refactor into smaller sub functions

Fixes #20950 - test 685 is extended for this
Closes #20932