Commit Graph

35326 Commits

Author SHA1 Message Date
Stefan Eissing
3135ed0d84
tests: make sshserver less verbose
Only display top of key files in verbose mode.

Follow-up to 89f306ae40 #16781

Closes #17647
2025-06-17 12:20:10 +02:00
Stefan Eissing
6270b41f92
multi: do no expire a blocked transfer
When checking to expire a transfer with input data pending, also assess
the blocked status and do not EXPIRE_RUN_NOW a transfer that is blocked
on READ/WRITE.

Follow-up to 62349e45a8 #17636

Closes #17639
2025-06-17 12:07:01 +02:00
Stefan Eissing
1454aa17d6
http2: do not delay RST send on aborted transfer
When a transfer is done prematurely, a RST is generated to the server,
but was not send right away due to send buffering.

Flush the send buffer in a best effort when transfer is done.

Reported-by: Michael Kaufmann
Fixes #17611
Closes #17638
2025-06-17 11:57:56 +02:00
Viktor Szakats
539d11297d
tests/http/clients: drop hack and use curl_setup.h again
Sync build properties with libtests.

This allows accessing macros from `curl_config.h`, for feature flags.
Smoothens out platform bumps, allowing to drop local replicas from
client sources. It enables using Windows wrappers, e.g. for `fopen()`.

Also fix client sources to use `curl_mfprintf()` where curl format
strings are used. (To avoid build failure with older mingw-w64, e.g.
6.4.0 in CI.)

Follow-up to 739c09c8a4 #17627

Closes #17642
2025-06-16 22:25:57 +02:00
Viktor Szakats
6d00b06e16
GHA/windows: avoid libtool wrapper for tunits
To sync it with other test binaries.

Closes #17640
2025-06-16 14:13:40 +02:00
Stefan Eissing
62349e45a8
multi: fix polling with pending input
When multi creates the pollset of a transfer, it checks now if
a connection (FIRST/SECONDARY) socket waits on POLLIN and has input data
pending in filters (relevant to OpenSSL's new read ahead). If so, it
triggers a timeout on the transfer via EXPIRE_RUN_NOW.

This fixes sporadic stalls in test 988 when running event based.

Closes #17636
2025-06-16 13:04:03 +02:00
Viktor Szakats
739c09c8a4
tests: bundle http clients, de-dupe, enable for MSVC
To make building the http client tests faster, with no duplication, by
using the build method that other test binaries already use.

The difference compared to other tests is that these don't use internal
libcurl headers or code. With the exception of `curl_config.h`, for
a feature macro.

Before this patch, these tests were built like examples.

Also:
- de-duplicate code and give unique names to colliding symbols.
- add local getopt implementation and enable all code for MSVC.
  Adapted for curl via Public Domain source:
  4e618ef782/getopt.h
  Credits-to: Christopher Wellons
  Thanks!

Closes #17627
2025-06-16 12:29:05 +02:00
Viktor Szakats
6828009695
windows: fixup fopen() in CURLDEBUG builds
Introduce an immutable `CURL_FOPEN()` macro to store the `fopen()`
mapping on Windows. Then use that instead `(fopen)` from `memdebug.c`.
It makes CURLDEBUG builds use the correct `fopen` wrapper on Windows.
This macro is only defined on Windows, as of this patch.

This is necessary after cde81e4398,
which no longer applies the default `fopen()` override to `memdebug.c`.

Also:
- curl_setup.h: de-dupe, simplify Windows file I/O function overrides.
- curl_memory.h: fix to reset `fopen` to `curlx_win32_fopen()` on
  Windows. Before this patch it reset it to stock `fopen()`.

Follow-up to cde81e4398 #17631

Closes #16747
2025-06-16 12:29:05 +02:00
Viktor Szakats
cde81e4398
memdebug: include in unity batch
Before this patch `memdebug.c` was compiled as a separate source in
unity builds. This was necessary because `memdebug.c` failed to compile
if `memdebug.h` was included before it, in `CURLDEBUG` mode. This patch
fixes this issue and allows to compile `memdebug.c` as part of the unity
source batch. This removes an exception and makes builds perform a notch
better.

- introduce `CURL_SCLOSE()` macro as an immutable synonym of `sclose()`.
- memdebug: replace `sclose()` reference with `CURL_SCLOSE()` to compile
  as expected when `sclose()` is overridden by `memdebug.h`.
- memdebug: make it not break when including `memdebug.h` before it in
  `CURLDEBUG` mode. Do this by calling low-level functions as
  `(function)`.
- autotools, cmake: drop memdebug exception, include it like any other
  source file. This is now possible because `memdebug.c` doesn't break
  if `memdebug.h` was included before it, in `CURLDEBUG` builds.
- mk-unity: drop `--exclude` option. No longer used after this patch.
- drop `MEMDEBUG_NODEFINES` macro hack. No longer necessary.

Ref: #16747
Closes #16746
Closes #16738
Closes #17631
2025-06-16 09:35:01 +02:00
Viktor Szakats
2ac18d7ae4
mk-unity: include the embedded source name in the output
Closes #17634
2025-06-16 09:12:59 +02:00
Viktor Szakats
bb9955c865
tests/libtest: merge MEMPTR into UTILS
Follow-up to ee06673296 #17628

Closes #17633
2025-06-16 09:12:58 +02:00
Viktor Szakats
253e1e94c6
autotools: drop no longer necessary --srcdir unity options
Follow-up to ee06673296 #17628

Closes #17632
2025-06-16 02:48:17 +02:00
Viktor Szakats
34792307ff
build: drop unused variables in tests
Follow-up to fffec3d7e9 #17629
Follow-up to ee06673296 #17628
2025-06-16 01:49:15 +02:00
Viktor Szakats
fffec3d7e9
tests/server: drop memdebug option
I added it just in case when removing enabled-by-default memdebug
from test servers. Apparently it broke after recent changes. It's
probably not a widely used feature and does not seem to be worth fixing.
It creates odd dependencies as the error message indicates:

```
[28/54] Building C object tests/server/CMakeFiles/servers.dir/__/__/lib/memdebug.c.obj
FAILED: tests/server/CMakeFiles/servers.dir/__/__/lib/memdebug.c.obj
[...]
lib/memdebug.c: In function 'curl_dbg_log':
lib/memdebug.c:465:12: error: implicit declaration of function 'mvsnprintf'; did you mean 'vsnprintf'? [-Wimplicit-function-declaration]
  465 |   nchars = mvsnprintf(buf, sizeof(buf), format, ap);
      |            ^~~~~~~~~~
      |            vsnprintf
lib/memdebug.c:465:12: warning: nested extern declaration of 'mvsnprintf' [-Wnested-externs]
```

This patch is dropping these build options:
- cmake: `ENABLE_SERVER_DEBUG`
- autotools: `--enable-server-debug` / `--disable-server-debug`

Follow-up to a16485a42e #16705

Closes #17629
2025-06-16 01:27:46 +02:00
Viktor Szakats
ee06673296
build: sync tests unity builds between cmake and autotools
Instead of relying on CMake's built-in unity feature, use `mk-unity.pl`,
as already done with autotools. It simplified the build, shortens logs
and makes debugging easier because of the fewer build variations.
It also allows testing / fixing with cmake and those automatically apply
to autotools builds too. cmake builds can be much-much faster, esp.
when working the builds themselves.

It also enables "unity" in old cmake versions. Basically every test
target is a single generated .c source.

Also:
- drop a `lib` unity workaround for libtests with autotools after fixing
  the issue in libtests itself. It drops a few exceptions and makes
  libcurl build faster (in autotools unity).
- fix another `lib` autotools unity issue and drop the workaround for it
  from `mk-unity.pl`. `srcdir` was missing from the header path.
- simplify `mk-unity.pl` command-lines, drop exclusions.

Follow-up to 2c27a67daa #17590

Closes #17628
2025-06-16 01:07:41 +02:00
Viktor Szakats
3186a20483
build: drop HAVE_SYS_SOCKET_H and HAVE_SYS_TIME_H macros
Both are available with well-known conditions, under non-Windows, and
`curl/curl.h` already uses them. `sys/time.h` is also necessary for
mingw-w64 for `gettimeofday()`.

Follow-up to 56d5982312 #17522

Closes #17581
2025-06-15 18:44:39 +02:00
Viktor Szakats
639d5e0f5e
tests: tidy up server main function, whitespace and README
Follow-up to 2c27a67daa #17590

Closes #17625
2025-06-15 14:11:21 +02:00
Viktor Szakats
6b016cec55
tidy-up: two comments
Follow-up to 2c27a67daa #17590
Follow-up to df1ff17f88 #17418

Closes #17624
2025-06-15 13:32:24 +02:00
Stefan Eissing
984c96e307
digest: fix build with disabled digest auth
Fix building with `--disable-digest-auth`. Make test cases run in such
a build. Add such a build to our CI jobs.

Reported-by: Tristan Perrault
Fixes #17612
Closes #17614
2025-06-15 12:07:22 +02:00
Stefan Eissing
66d35ee5d4 lib: avoid reusing unclean connection
When `curl_easy_cleanup()` is invoked while still being part
of a multi handle, the code will auto-remove it. But since the
connection was detached first, the code in
`curl_multi_remove_handle()` that invalidates dirty connections
did not bite.

Attach the connection *after* the possible remove from a multi
handle, so that connection reuse can be prevented.

Add test753 to reproduce and verify the fix. This required adding
the new debug env var CURL_FTP_PWD_STOP, to have a transfer return
from multi_perform() early with a connection that does not show
and pending input.

Reported-by: Brian Harris

Fixes https://github.com/curl/curl/issues/17578
Closes https://github.com/curl/curl/pull/17607
2025-06-15 03:22:25 -04:00
Theodore A. Roth
17f2a220a9 openssl: Fix openssl engines
- Return CURLE_OK if the engine successfully loaded.

Prior to this change:

When loading an openssl engine, the result code is initialized to
CURLE_SSL_ENGINE_NOTFOUND, but is never set to CURLE_OK when the engine
was successfully loaded. This causes curl to error out, falsely stating
engine not found when it actually was.

Broken since f2ce6c46 (precedes 8.14.0) which added support for using
engines and providers at the same time.

Fixes https://github.com/curl/curl/issues/17617
Closes https://github.com/curl/curl/pull/17618
2025-06-14 23:15:04 -04:00
Viktor Szakats
2f312a14da
warnless: replace read()/write() wrapper functions with macros (Windows)
Map them to `_read()`/`_write()` (with underscore) to avoid recursive
mapping and to use the non-compatibility naming on Windows.

https://learn.microsoft.com/cpp/c-runtime-library/reference/read
https://learn.microsoft.com/cpp/c-runtime-library/reference/write

Follow-up to 6239146e93

Closes #17619
2025-06-15 02:02:28 +02:00
Viktor Szakats
924c7e15dc
tidy-up: update deprecated status of some symbols/options
`CURLOPT_SSL_FALSESTART` / `--false-start`, Secure Transport, BearSSL,
GSKit, MesaLink, NSS.

Follow-up to 1e2e808def #17595
Follow-up to 08a3e8e19a #16677

Closes #17605
2025-06-15 01:38:26 +02:00
Daniel McCarney
4dabcf4c48
lib: remove superfluous setopt break for CURLOPT_SSL_FALSESTART
Reported-by: 4lan.m
Ref: 1e2e808def (r159957160)
Follow-up to 1e2e808def #17595

Closes #17615
2025-06-15 01:38:25 +02:00
Viktor Szakats
bb7ea30fb6
GHA/windows: enable H3 in the MSVC OpenSSL job
Requires windows-runner 20250602.1 for ngtcp2 1.13.0.

Follow-up to c129d0b1a8 #17561
Ref: https://github.com/curl/curl/pull/17561#issuecomment-2959583138

Closes #17577
2025-06-15 01:31:34 +02:00
Rod Widdowson
df1ff17f88 schannel: allow partial chains for manual peer verification
- Align --cacert behaviour with OpenSSL and LibreSSL.

This changes the default behavior of Schannel manual certificate
verification, which is used when the user provides their own CA
certificates for verification, to accept partial chains. In other words,
the user may provide an intermediate certificate without having to
provide the root CA.

Win8/Server2012 widened the PKIX chain traversal API to allow
certificate traversal to terminate at an intermediate.

This behaviour (terminate at the fist matching intermediate) is the
default for LibreSSL and OpenSSL (with OpenSSL allowing control via
CURLSSLOPT_NO_PARTIALCHAIN).

This change uses the new API if it is available, and also allows the
behaviour to revert legacy if CURLSSLOPT_NO_PARTIALCHAIN is present.

Closes https://github.com/curl/curl/pull/17418
2025-06-14 18:55:08 -04:00
Viktor Szakats
49a0c27bbc
cmake: make docs depend on support files
As in autotools.

Closes #17620
2025-06-14 21:10:59 +02:00
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