Commit Graph

35949 Commits

Author SHA1 Message Date
Viktor Szakats
2c27a67daa
tests: always make bundles, adapt build and tests
Make test bundles the default. Drop non-bundle build mode.
Also do all the optimizations and tidy-ups this allows, simpler builds,
less bundle exceptions, streamlined build mechanics.

Also rework the init/deinit macro magic for unit tests. The new method
allows using unique init/deinit function names, and calling them with
arguments. This is in turn makes it possible to reduce the use of global
variables.

Note this drop existing build options `-DCURL_TEST_BUNDLES=` from cmake
and `--enable-test-bundles` / `--disable-test-bundles` from autotools.

Also:
- rename test entry functions to have unique names: `test_<testname>`
  This removes the last exception that was handled in the generator.
- fix `make dist` to not miss test sources with test bundles enabled.
- sync and merge `tests/mk-bundle.pl` into `scripts/mk-unity.pl`.
- mk-unity.pl: add `--embed` option and use it when `CURL_CLANG_TIDY=ON`
  to ensure that `clang-tidy` does not miss external test C sources.
  (because `clang-tidy` ignores code that's #included.)
- tests/unit: drop no-op setup/stop functions.
- tests: reduce symbol scopes, global macros, other fixes and tidy-ups.
- tool1621: fix to run, also fix it to pass.
- sockfilt: fix Windows compiler warning in certain unity include order,
  by explicitly including `warnless.h`.

Follow-up to 6897aeb105 #17468

Closes #17590
2025-06-14 21:08:23 +02:00
Stefan Eissing
1cdac95e2e
openssl: fix handling of buffered data
`SSL_pending()` only checks if the *current* TLS packet has more data.
There might be more data in SSL's buffers.

`SSL_has_pending()` only checks if there is data in buffers, but does
*not* check if there is a complete TLS packet that can be decoded.

If we only check the first, we will poll on socket events without having
processed all data and may stall. If we only check the second, we would
busy loop without SSL_read() ever giving something.

Add the flag `connssl->input_pending` that is set on incoming data in
the BIO receive. Clear the flag when encountering a CURLE_AGAIN on
the filters receive (via SSL_read()) or see an EOF.

Ref: #17596
Closes #17601
2025-06-13 00:32:06 +02:00
Daniel Stenberg
cbc062a7b8
http: split http_header into sub functions
Closes #17603
2025-06-12 13:13:46 +02:00
Daniel Stenberg
c257753ee9
asyn-thrdd: free the previous name before strdup'ing the new
Fixes #17602
Reported-by: hiimmat on github
Closes #17604
2025-06-12 12:53:57 +02:00
Viktor Szakats
49a1cfaec2
GHA/non-native: skip test 2707 instead of all WebSocket tests on OpenBSD
Narrowing down the test which may be causing the flaky 6-minute long
delays and CI failures.

Suggested-by: Calvin Ruocco
Ref: https://github.com/curl/curl/pull/17562#issuecomment-2961629713

Follow-up to 05db18e054 #17562
Follow-up to d3594be653 #17136

Closes #17588
2025-06-12 12:01:37 +02:00
Daniel McCarney
1e2e808def
tls: remove Curl_ssl false_start
The secure transport vTLS backend was the only Curl_ssl struct instance
that populated the false_start field. Since its removed, we can now
remove that field entirely. This was a protocol feature specific to TLS
1.2 that has been replaced by the more widely adopted TLS 1.3 early data
mechanisms.

--false-start is now deprecated

Closes #17595
2025-06-12 08:29:15 +02:00
Daniel Stenberg
220c5d8f49
tests/libtest: simplify Makefile.inc
Remove all custom LDADD lines

Plus: a few minor tidy-ups in libtest code.

Closes #17594
2025-06-11 23:26:39 +02:00
Daniel Stenberg
b950c8c03f
http_ntlm: remove unreachable code
Since the code now checks for NULL and returns before this point, 'ntlm'
cannot be NULL at this point in the code. Pointed out by Coverity.

Follow-up to 5586520745

Closes #17587
2025-06-11 23:06:06 +02:00
Viktor Szakats
c9460d6237
libtests: stop building the sames source multiple times
After this patch there is no more double/multiple compile of the same
libtest source under a different libtest ID. Each libtest is compiled
once, and changing behavior at runtime based on test ID.

- drop recently added physical clones for two prevously multi-compiled
  tests:
  - merge lib587 into lib554 again, branch at runtime.
  - merge lib645 into lib643 again, branch at runtime.

- replace existing dynamic branching to use `testnum` instead of
  a manually rolled `testno` based on an extra command-line argument.
  lib1571, lib1576.

- mk-bundle.pl: stop defining `LIB*` macros. No longer used.

- libtests: drop all `LIB*_C` guards.

- Make these tests branch at runtime, stop building copies:
  - lib585, based on lib500
  - lib565, based on lib510
  - lib529, based on lib525
  - lib527, lib532, based on lib526
  - lib545, based on lib544
  - lib548, based on lib547
  - lib696, based on lib556
  - lib584, based on lib589
  - lib1539, based on lib1514
  - lib1543, based on lib1518
  - lib1917, based on lib1916
  - lib1946, based on lib1940
  - lib671, 672, 673, based on lib670

Follow-up to 02dd471bbf #17591
Follow-up to 6897aeb105 #17468

Closes #17598
2025-06-11 19:05:47 +02:00
Daniel Stenberg
02dd471bbf
libtests: make test 1503,1504,1505 use the 1502 binary
Adjust the differences at runtime instead of build-time, to avoid
extra buillds.

Set the `CURL_TESTNUM` env variable to pass test numbers to tests.

Make libtest/first.c use that env variable to set the `testnum` global
variable to allow tests to differ based on which test that runs it.

Closes #17591
2025-06-11 14:25:54 +02:00
Edwin Török
aea336aa23
openssl: enable readahead
Speeds up TLS operations up to ~%13.

Closes #17548

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
2025-06-11 13:26:53 +02:00
Stefan Eissing
20c90ba298
lib: unify recv/send function signatures
cfilter/conn: change send/recv function signatures. Unify the
calling/return conventions in our send/receive handling.

Curl_conn_recv(), adjust pnread type

Parameter `pnread` was a `ssize_t *`, but `size_t *` is better since the
function returns any error in its `CURLcode` return value.

Closes #17546
2025-06-11 11:21:10 +02:00
Viktor Szakats
3934431421
tidy-up: drop BearSSL and Secure Transport reference remains
Follow-up to 08a3e8e19a #16677

Closes #17582
2025-06-11 11:14:29 +02:00
Stefan Eissing
14b42c89db
openssl: error on SSL_ERROR_SYSCALL
Convert the debug-only handling of SSL_ERROR_SYSCALL so that it is
enabled in all builds with openssl. This should not make a difference in
supported OpenSSL versions, but if whatever version or fork we link
against *does* return SSL_ERROR_SYSCALL, handle this as a fatal error.

Fixes #17471
Reported-by: Michael Kaufmann
Closes #17531
2025-06-11 10:44:55 +02:00
Daniel Stenberg
5586520745
http_ntlm: protect against null deref
Closes #17585
2025-06-11 10:15:32 +02:00
Stefan Eissing
950bd72401
pytest test_07_70, weaken early data check
Since the amount of early data sent in the upload test_07_70 varies
much with how fast the server respondes and completes the handshake,
assert that we did sent at least *some* early data instead of relying
on a specific amount.

Closes #17575
2025-06-11 10:15:00 +02:00
Daniel Stenberg
d4db756128
RELEASE-NOTES: synced
Bump to 8.15.0
2025-06-11 09:25:01 +02:00
Daniel Stenberg
599bf4a271
RELEASE-PROCEDURE.md: update docs/VERSIONS
Add it as an item to fix in each release

Closes #17584
2025-06-11 09:21:44 +02:00
Orgad Shaneh
b244371bf4
VERSIONS.md: update
Closes #17583
2025-06-11 08:49:15 +02:00
Stefan Eissing
e39b8c4819
url: fix connection lifetime checks
The checks for a connection being "too long idle" or "too old" where
rounding down the elapsed time to seconds before comparing to the
configured max values. This caused connections to be reused for up to
999ms longer than intended.

Change the compares to scale the configured seconds up to ms, so
connection will properly be "too old" 1 ms after the coonfigured values.

Fixes sporadic failures of test1542 on platforms where "sleep(2)"
returnes before 2 full seconds on the internal clock where passed.

Reported-by: Christian Weisgerber
URL: https://curl.se/mail/lib-2025-06/0004.html
Closes #17571
2025-06-11 08:07:57 +02:00
Daniel Stenberg
f9d8ed63ed
urlapi: simplify and split into sub functions
Closes #17565
2025-06-11 07:58:52 +02:00
Stefan Eissing
3c26e6a896
libssh: de-complex myssh_statemach_act()
Make static functions for the largest state handling code
with a common signature and naming scheme.

Closes #17573
2025-06-11 07:58:09 +02:00
Daniel Stenberg
08a3e8e19a
TLS: remove support for Secure Transport and BearSSL
These libraries do not support TLS 1.3 and have been marked for removal
for over a year. We want to help users select a TLS dependency that is
future-proof and reliable, and not supporting TLS 1.3 in 2025 does not
infer confidence. Users who build libcurl are likely to be served better
and get something more future-proof with a TLS library that supports
1.3.

Closes #16677
2025-06-11 07:54:19 +02:00
Viktor Szakats
b761eb5add
cmake: replace cmakelint with cmake-lint from cmakelang, fix issues
This linter detects formatting and naming issues with minimal amount of
noise. It seems to be an improvement over the existing linter which was
only detecting line width overruns.

Also: fix to exclude `CurlTests.c` from linter.

Ref: https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
Ref: https://github.com/cheshirekow/cmake_format

Closes #17576
2025-06-11 07:07:49 +02:00
Viktor Szakats
56d5982312
build: assume sys/socket.h, sys/time.h on non-Windows (as in curl/curl.h)
Public `curl/curl.h` includes these headers for non-Windows platforms
without further conditions. This makes it safe to assume these headers
do exist, allowing to save two feature checks for non-Windows targets.

`sys/time.h` is also assumed on Windows with mingw-w64, for declaring
`gettimeofday()`.

Closes #17522
2025-06-11 07:07:49 +02:00
Viktor Szakats
3c9d16f4b8
cmake: drop never propagated C macros
Delete macros from `curl_config.h.cmake` that were never set by
the CMake script: `_LARGE_FILES`, `_THREAD_SAFE`, `const`, `size_t`.

Also:
- lib/config-riscos.h: drop `#undef _LARGE_FILES`. This is an
  IBM-specific macro, no need to unset it on other platforms.

Cherry-picked from #17576

Closes #17580
2025-06-11 06:32:22 +02:00
renovate[bot]
0f500e6a9c
Dockerfile: update debian:bookworm-slim Docker digest to e5865e6
Closes #17579
2025-06-11 06:00:17 +02:00
Viktor Szakats
05db18e054
GHA/non-native: skip OpenBSD WebSocket tests to mitigate job timeouts
Trying to avoid the occasional ~6-minute long delays seen in the OpenBSD
since last week. The long delay causes the CI job to timeout and fail:
https://github.com/curl/curl/actions/workflows/non-native.yml?page=2&query=branch%3Amaster

The exact reason is or test number is unknown. I base this attempt on
looking at the first occurrences and possible patches that may be
related.

The issue was first seen in CI within PR #17136:
```
[...]
Wed, 07 May 2025 07:10:30 GMT test 3014...[Check if %{num_headers} returns correct number of headers]
Wed, 07 May 2025 07:10:30 GMT s-p----e--- OK (1743 out of 1778, remaining: 00:02, took 0.195s, duration: 01:43)
Wed, 07 May 2025 07:10:30 GMT test 3016...[GET a directory using file://]
[long delay here]
Wed, 07 May 2025 07:16:17 GMT -------
Wed, 07 May 2025 07:16:17 GMT Error: The operation was canceled.
```
Ref: https://github.com/curl/curl/actions/runs/14877264415/job/41776966626#step:3:5566
Ref: https://github.com/curl/curl/actions/runs/14900320627/job/41850699301#step:3:5561 (next in PR)

Then in master, shortly after merging it via d3594be6531df3d5eafcdd09f84ad9dee1777028:
```
[...]
Mon, 02 Jun 2025 09:23:55 GMT test 3201...[HTTP GET when PROXY Protocol enabled and spoofed client IP]
Mon, 02 Jun 2025 09:23:55 GMT --p----e--- OK (1777 out of 1788, remaining: 00:00, took 0.222s, duration: 01:42)
Mon, 02 Jun 2025 09:23:55 GMT RUN: failed to start the HTTP/2 server
Mon, 02 Jun 2025 09:23:55 GMT test 3202...[HTTP-IPv6 GET with PROXY protocol with spoofed client IP]
[long delay here]
Mon, 02 Jun 2025 09:29:48 GMT --p----e--- OK (1778 out of 1788, remaining: 00:00, took 0.1
Mon, 02 Jun 2025 09:29:48 GMT Error: The operation was canceled.
```
Ref: https://github.com/curl/curl/actions/runs/15388587165/job/43292652793#step:3:5097
Ref: https://github.com/curl/curl/actions/runs/15390589464/job/43298911578#step:3:5097 (next in master)

Closes #17562
2025-06-11 05:39:23 +02:00
Viktor Szakats
6897aeb105
tests: drop mk-bundle exceptions
Using a mixture of techniques to avoid symbols collisions:
- reduce scope.
- add `t*_` / `T*_` prefix.
- move shared functions to `testutil.c`.
  (`suburl()`, `rlim2str()`)
- clone re-used lib*.c sources.
  (lib587, lib645)
- include shared symbols just once in re-used `lib*.c` sources.
  (using `LIB*_C` guards.)
- drop re-used `lib*.c` sources where they were identical or
  unused.
- make macros global.
- #undef macros before use.

What remain is the entry functions `test`, and `unit_setup`,
`unit_stop` in unit tests.

Also:
- fix formatting and other minor things along the way.
- add `const` where possible.
- sync some symbol names between tests.
- drop `mk-bundle-hints.sh` that's no longer necessary.

Closes #17468
2025-06-11 05:39:19 +02:00
Viktor Szakats
9ed34cc45b
schannel: drop Windows 2000 compatibility logic
curl requires Windows XP as a minimum.

Co-authored-by: Jay Satiro

Closes #17447
2025-06-11 05:39:14 +02:00
Viktor Szakats
0d71b18153
windows: reduce/stop loading DLLs at runtime
- replace dynamic `InitSecurityInterface()` call with early binding and
  link `secur32` system DLL.
  The library and function are available in all supported curl Windows
  targets, meaning WinXP or newer.  Add small hack for mingw32ce to
  make it build.

- detect and use `if_nametoindex()` on Windows when available. Link
  `iphlpapi` system DLL. Requires targeting Vista or newer.
  Replacing the dynamic call and the pre-load optimization for lib3026.

Suggested-by: Jay Satiro

Closes #17413
2025-06-11 05:39:09 +02:00
Viktor Szakats
c129d0b1a8
GHA/windows: make MSVC jobs use MSYS2 libraries: psl, OpenSSL, H2, libssh2
Extend MSVC jobs with the option to use MSYS2 binary package as DLL
dependencies. Allow to use them alone (without vcpkg) or combined with
vcpkg packages. This saves the trouble of building these packages from
source and cache them manually.

This solution requires two tricks:
- workaround for zlib which installs a target-specific `zconf.h` that's
  not portable between platforms and C compilers.
- manual dependency configuration in CMake to ensure linking against
  the MSYS2 DLLs (and not it static libs). Static libs aren't portable
  to MSVC due to missing symbols `__chkstk_ms`, `_stack_chk_fail`,
  `_memcpy_chk`, `_stack_chk_guard`, and potentially other issues. CMake
  in MSVC mode, `linker.exe` and `pkg-config` pick the static libs by
  default. To pick `.dll.a` in favour of `.a`, these tools would have
  to be taught about this convention. An alternative is deleting static
  libs and see if `.dll.a` are picked-up automatically.

Using MSYS2 packages adds an install step taking 15-45 seconds per job.

It allowed to:
- re-enable libpsl for all MSVC jobs.
- convert the Intel 64-bit job to use MSYS2 without vcpkg, enabling
  brotli, zstd, OpenSSL 3.5.0, libssh2 (with OpenSSL cryprography) and
  nghttp2.

Using the same technique it's possible to re-enable more features
in MSVC builds, e.g. GnuTLS (also with H3), LibreSSL, mbedTLS, nghttp3,
ngtcp2, libssh, c-ares, gsasl, and replace vcpkg zlib, for faster runs.
What's missing compared to vcpkg is BoringSSL and wolfSSL
(the MSYS2-supplied build doesn't fit curl's requirements IIRC). These
could be built and cached manually.

Also:
- add workaround for zlib (classic) which uses a generated `zconf.h`,
  rendering the MSYS2 zlib header incompatible with MSVC.
- set the correct `msystem` for arm64.
- allow using MSVC without vcpkg.

Follow-up to cd0ec4784c #17089

Closes #17561
2025-06-11 00:51:04 +02:00
Viktor Szakats
a7e364df81
cmake: document OpenSSL and ngtcp2 crypto lib custom variables
Cherry-picked from #17561

Closes #17574
2025-06-10 16:31:07 +02:00
Viktor Szakats
dd4088d916
GHA/checksrc: yq is pre-installed, drop manual install
Follow-up to 17a669426f #17537

Cherry-picked from #17561
2025-06-10 16:23:44 +02:00
Stefan Eissing
ab650379a8
vauth: move auth structs to conn meta data
Remove structs for negotiate, krb5, ntlm and gsasl from connectdata and
store them as connection meta data with auto cleanup.

De-complexify sasl mech selection by moving code into static functions.

Closes #17557
2025-06-10 15:57:44 +02:00
Yedaya Katsman
05ffeeda0c
tests: fail torture if !valgrind&threaded resolver
We don't check the memory debug output with the threaded resolver, so
the only way to do it with with valgrind.

Also move the disabling of memory tracking to where we log that we're
doing it.

Closes #17501
2025-06-10 15:46:47 +02:00
Yedaya Katsman
bc7d88cc8a
tests: torture: don't duplicate valgrind command
When running torture tests with valgrind enabled, the torture function
got a command line that already had the valgrind invocation in it. It
added another, at the end resulting in an empty valgrind log file.

Remove the duplicate logic adding valgrind, which already had a bit of
different logic that wasn't updated when the other one was.

Closes #17501
2025-06-10 15:46:13 +02:00
Daniel Stenberg
1d9c1e4b0f
RELEASE-NOTES: synced 2025-06-10 07:48:17 +02:00
Daniel Stenberg
b530c11bfd
curl.h: remove the "RESERVED" error codes
Return codes for tests should be kept private.

Follow-up to 9465327084

Closes #17563
2025-06-09 23:57:23 +02:00
Daniel Stenberg
1886260a95
lib: make curlx_inet_ntop()
move function to curlx/, change all callers

Closes #17560
2025-06-09 13:16:01 +02:00
Viktor Szakats
c347b43e5c
GHA/hacktoberfest-accepted: prefer GH_TOKEN
For the `gh` tool, over `GITHUB_TOKEN`. It accepts both, of which
the former seems to be preferred according to the source code and
documentation.

GHA/appveyor-status already uses `GH_TOKEN`.

Closes #17556
2025-06-09 12:28:47 +02:00
Carlos Henrique Lima Melara
0ede81dcc6
curl_path: make SFTP handle a path like /~ properly.
... without a trailing slash.

Fixes #17534
Closes #17542
2025-06-09 11:23:16 +02:00
Stefan Eissing
c314759c4c
pingpong: on disconnect, check for unflushed pingpong state
When a pingpong based protocol tries to perform a connection disconnect,
it sends a sort of "logout" command to the server, unless the connection
is deemed dead.

But the disconnect might happen before pingpong data has been completely
sent, in which case sending the "logout" will not work. Check the
pingpong state and do not "logout" when data is pending.

This was detected as a condition in fuzzing that triggered a debug
assert in the pingpong sending.

Closes #17555
2025-06-09 11:22:19 +02:00
Daniel Stenberg
b42776b4f4
tool_operate: fix return code when --retry is used but not triggered
Verify with test 752

Reported-by: fjaell on github
Fixes #17554
Closes #17559
2025-06-09 09:10:06 +02:00
Viktor Szakats
128c5ddc6b
GHA: enclose if expressions in ${{ }} where missing
Enclosing expressions in `${{ }}` is optional, but sometimes required.
It seems more straighforward to use it always rather than decide on
a case-by-case basis. Before this patch 71 `if`s were enclosed and 49
were not. Enclosing these makes it easy to grep and recognize these
whereever used.

https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution

Closes #17550
2025-06-08 13:01:24 +02:00
Dan Fandrich
5f805eec11 tool_getparam: fix --ftp-pasv
This boolean option was moved to the wrong handling function. Make it
an ARG_NONE and move it to the correct handler and add a test to
verify that the option works.

Follow-up to 698491f44

Reported-by: fjaell on github
Fixes #17545
Closes #17547
2025-06-06 14:40:14 -07:00
Viktor Szakats
900612df79
GHA: tidy up single-line run blocks
Also double quote a shell variable.

Closes #17552
2025-06-06 23:24:27 +02:00
Daniel Stenberg
f33ec60fbf
tests/servers.pm: add more ways to figure out current user
Some CI tests fail due to "Can't start ssh server due to lack of USER name" -
add more ways to try to figure it out if no environment variable works: the
whoami and id commands.

Closes #17544
2025-06-06 23:07:29 +02:00
Viktor Szakats
d16a020a87
GHA/hacktoberfest-accepted: tidy up item order
`if`, then `env`, then `run`.

Also tidy up quotes in env entries.

Closes #17551
2025-06-06 23:02:04 +02:00
Viktor Szakats
17a669426f
CI: fix zizmor 1.9.0 warnings, shellcheck verify CI shell code, fix fallouts
zizmor 1.9.0 effectively bans using GHA macros within shell script
snippets. Rework them to pass GHA macro values via envs and use those
envs in shell snippets. `${{ env.* }}` macros could be converted
to native env references after making their names shell-compatible.

Envs and shell commands can no longer be used in GHA macro values. Most
cases could be fixed by using literals. Passing quoted values with
spaces combined with other args also doesn't work anymore. This was
replaced by passing them separately.

Despite the initial complications, avoiding GHA macros in scripts does
seems to make the CI code reasonable cleaner. It also makes it possible
to analyze the scripts with shellcheck, finding subtle issues that went
unnoticed till now.

Also:
- un-ignore and fix three existing zizmor `template-injection` issues.
- add script to extract and shellcheck all shell code stored within GHA
  and Circle CI YAML files.
- add CI job to run this script.
- fix shellcheck issues discovered.
- fix minor differences between cmake and autotools FreeBSD jobs.
- merge cmake/autotools FreeBSD jobs to avoid developing unwanted
  differences again.
- fix/sync quote use across shell code.
- replace `$HOME` with `~` or literal where it made sense.
- replace most `brew --prefix` with literals.
- move all curl install tests to the `curl-install*` prefix.
- add missing curl install tests to cygwin/msys/mingw/*bsd.
- pipe to `tar` instead of storing downloads on disk.
- drop unnecessary `PKG_CONFIG_PATH` when building nghttp3.

Ref: https://github.com/curl/curl/actions/runs/15461461371/job/43523546041
Ref: https://github.com/zizmorcore/zizmor/releases/tag/v1.9.0

Follow-up to e522f47986 #17278

Closes #17537
2025-06-06 21:30:43 +02:00