6768 Commits

Author SHA1 Message Date
Stefan Eissing
909af1a43b
multi: do transfer book keeping using mid
Change multi's book keeping of transfers to no longer use lists, but a
special table and bitsets for unsigned int values.

`multi-xfers` is the `uint_tbl` where `multi_add_handle()` inserts a new
transfer which assigns it a unique identifier `mid`. Use bitsets to keep
track of transfers that are in state "process" or "pending" or
"msgsent".

Use sparse bitsets to replace `conn->easyq` and event handlings tracking
of transfers per socket. Instead of pointers, keep the mids involved.

Provide base data structures and document them in docs/internal:
* `uint_tbl`: a table of transfers with `mid` as lookup key,
   handing out a mid for adds between 0 - capacity.
* `uint_bset`: a bitset keeping unsigned ints from 0 - capacity.
* `uint_spbset`: a sparse bitset for keeping a small number of
  unsigned int values
* `uint_hash`: for associating `mid`s with a pointer.

This makes the `mid` the recommended way to refer to transfers inside
the same multi without risk of running into a UAF.

Modifying table and bitsets is safe while iterating over them. Overall
memory requirements are lower as with the double linked list apprach.

Closes #16761
2025-04-17 17:28:38 +02:00
Daniel Stenberg
02e9690c3e
tests/server/dnsd: basic DNS server for test suite
Currently the DNS server only responds to A and AAAA queries. It always
responds with a fixed response: the localhost address. Three times.

It should work fine over either IPv4 or IPv6, but I don't think it
matters much for curl testing.

The idea is to allow curl tests to use "normal" DNS hostnames (using the
normal name resolving code paths) and still use the local test servers.

This setup currently only works if curl is built with c-ares because
redirecting DNS requests to our test server when using getaddrinfo() is
not easy.

This should be extended to respond to HTTPS queries as well to allow
more testing there, as c-ares is always used for that.

Test 2102 is the first test using this.

Closes #17015
2025-04-17 09:13:24 +02:00
Stefan Eissing
5eefdd71a3
vquic: ngtcp2 + openssl support
With the new addition of OpenSSL QUIC API support and the support in
ngtcp2 main branch, make the necessary adjustments in curl to support
this combination.

- add support in configure.ac to detect the feature OPENSSL_QUIC_API2 in
  openssl
- initialise ngtcp2 properly in this combination
- add a Curl_vquic_init() for global initialisation that ngtcp2 likes
  for performance reasons
- add documentation on how to build in docs/HTTP3.md
- add CI testing in http3-linux.yml

Assisted-by: Viktor Szakats
Closes #17027
2025-04-16 22:32:07 +02:00
Viktor Szakats
fbe408ccd7
cmake: do not install mk-ca-bundle script and manpage
To sync with autotools builds.

Reported-by: Daniel Stenberg
Bug: https://github.com/curl/curl/pull/17035#pullrequestreview-2769964979
Follow-up to 5023ffad2c27d4b916ddb91800f99ecc5d3aad07 #13197

Closes #17068
2025-04-16 13:37:54 +02:00
Daniel Stenberg
0a0aec01b5
VERSIONS: 8.14.0 is pending 2025-04-16 09:39:06 +02:00
Christian Schmitz
8ad0243e1f
mqtt: send ping at upkeep interval
Closes #16975
2025-04-16 09:36:19 +02:00
Daniel Stenberg
a1413b4a27
docs/INSTALL.md: drop reference to removed configure option
--disable-pthreads has been removed

Fixes #17023
Reported-by: mschroeder-fzj on github
Closes #17026
2025-04-11 15:25:44 +02:00
Daniel Stenberg
960984263f
docs/libcurl: make examples build with picky compiler options
Found by improving verify-examples.pl:

- Operate directly on markdown files to remove the need to render nroff files
  first.

- Add -Wall as a compiler option to find more issues

Closes #17028
2025-04-11 15:23:51 +02:00
Pavel Kropachev
d9a86b6729
docs: add missing return statement in examples
Closes #17024
2025-04-11 14:41:28 +02:00
Daniel Stenberg
4a9657a890
KNOWN_BUGS: fix link in sivg4 issue 16.3
Fixes #17007
Reported-by: Demi Marie Obenour
Closes #17009
2025-04-10 08:29:53 +02:00
Jake Yuesong Li
320eed00a4
HTTP3.md: fix incorrect variable placeholders
Closes #17008
2025-04-10 08:18:56 +02:00
Daniel Stenberg
fd39579241
KNOWN_BUGS: wolfssh: all tests fail
Closes #16794
2025-04-06 13:19:30 +02:00
Jay Satiro
023cc8d595 winbuild: add the deprecation warning to the README
- Mention in README.md and INSTALL-CMAKE.md that the winbuild build
  system is going to be removed in September 2025.

Closes https://github.com/curl/curl/pull/16957
2025-04-05 14:51:00 -04:00
Stefan Eissing
5fbd78eb2d
http2: fix stream window size after unpausing
When pausing a HTTP/2 transfer, the stream's local window size
is reduced to 0 to prevent the server from sending further data
which curl cannot write out to the application.

When unpausing again, the stream's window size was not correctly
increased again. The attempt to trigger a window update was
ignored by nghttp2, the server never received it and the transfer
stalled.

Add a debug feature to allow use of small window sizes which
reproduces this bug in test_02_21.

Fixes #16955
Closes #16960
2025-04-05 14:54:40 +02:00
Dan Fandrich
34cdd4e118 INSTALL.md: update the minimal libcurl size example
It's only gone up by 7 KiB over the dozen releases in the last year.
2025-04-03 12:16:51 -07:00
Daniel Stenberg
daa8693619
VERSIONS: list all past releases
This document now lists all previous releases.

This allows us to verify that documentation refers to actual release
versions.

Test 971 now verifies options-in-versions and all command line options
documentation individually. Fixed a few discrepancies.

Test 1488 verifies libcurl options "Added-in" to exist. Fixed a few
discrepancies there as well.

Closes #16907
2025-04-03 08:26:33 +02:00
Jay Satiro
e0b4ea889f INSTALL-CMAKE.md: fix typo 2025-04-02 17:45:57 -04:00
Daniel Stenberg
b0c5a1abdb
THANKS: new contributors from 8.13.0 release 2025-04-02 07:46:30 +02:00
Daniel Stenberg
b4dc529fc4
prox/preproxy.md: document argument within <brackets>
... as the argument is mandatory and we use that symbol for all other
options.

Closes #16883
2025-03-31 13:42:29 +02:00
Daniel Stenberg
083da46c60
docs/cmdline-opts: use imperative form
Use 'set', not 'sets' etc. For consistency.

Closes #16879
2025-03-31 08:18:31 +02:00
Daniel Stenberg
c4863e9d3b
docs/internals/PORTING.md: new document
The basic approach I use when porting libcurl to another OS when the
existing configure or cmake build setups are not suitable.

Closes #16860
2025-03-29 14:10:10 +01:00
Viktor Szakats
7be2c421bf
runtests: rewrite genserv.sh in Perl
To remove POSIX shell as an extra dependency for runtests.

Also fix to `chmod 0600` the `.pem` file (was: `.prm`), and apply it
_before_ writing the keys.

Follow-up to 44341e736a3e2f7a2b25a774be3a9796e81abab9 #16824
Closes #16858
2025-03-29 12:35:33 +01:00
Viktor Szakats
c8b0f0c9ad
cmake: add shell completion support
Add the last (*) missing bit for feature parity with autotools.

Also test in CI. Add a new `cmake install` step to GHA/macos.

(*) AFAIK. Let us know if there's something else missing.

Closes #16833
2025-03-28 13:51:38 +01:00
Daniel McCarney
8836e65967
docs: add rustls --ca-native & CURLSSLOPT_NATIVE_CA
The one important caveat is that presently _only_ the native platform
verifier/CAs are consulted when this option is used w/ rustls.

Closes #16848
2025-03-27 22:54:24 +01:00
Viktor Szakats
44341e736a
runtests: generate certs dynamically, bump to EC-256, tidy up
Before this patch the curl repository and source tarball distribution
contained test certificates as binary blobs. Used by runtests.

Drop these certificates in favor of generating them dynamically as
part of the build process. Both via autotools and CMake.

As part of this, improve certificates, the generator script and process,
file layout, and fix any issue to make it work fast and smooth both in
CI and local builds.

Note, cert generator scripts require OpenSSL >=1.0.2
(or LibreSSL >=3.1.0). Generation requires POSIX shell, also with CMake.
Without a POSIX shell tests relying on TLS (and stunnel) will fail.

Details:

- build: generate certs as part of the test run process.
- build, tests: generate certs in the build directory.
- binarycheck: drop concept of known binary files with hashes.
- binarycheck: move binary check logic into spacecheck and drop this
  separate checker tool.
- build: fix to clean all cert files.
- autotools: fix to not run leaf cert generators in parallel. To avoid
  confusion when updating the revocation database and counter.
- scripts: drop `scripts` subdir, merge two scripts into one,
  auto-generate root cert, allow generating multiple leafs at once.
- scripts: switch to EC-256 keys (was: RSA-2048). For key size and perf.
- scripts: drop `-x` echo, text dumps, most other output. To avoid log
  noise and make it quicker in CI.
- scripts: make it non-RSA-specific.
- scripts: delete unused code.
- scripts: use POSIX shell shebang. Some envs don't have bash (Alpine).
- scripts: pass test pseudo-secrets via the command-line. To avoid:
  ```
  + openssl genrsa -out test-ca.key -passout fd:0 2048
  Invalid password argument, starting with "fd:"
  ```
- cmake: fix to launch generator scripts via the detected POSIX shell.
- cmake: fix `build-certs` rule to not depend on `SRPFILES`
  (`srp-verifier-*`).
- cmake: drop `EXCLUDE_FROM_ALL` for the cert subdir. It makes
  the Visual Studio generator miss to create the `clean-certs`,
  `build-certs` targets. No target depend on them, so they don't execute
  implicitly anyway. Fixes:
  ```
  MSBUILD : error MSB1009: Project file does not exist.
  Switch: clean-certs.vcxproj
  ```
- cmake: add `VERBATIM USES_TERMINAL` to `build-certs` target.
- GHA/linux: install openssl on Alpine, for the cert generator scripts.

Follow-up to 556f722fe32e5e9f4e24f0242100c5e9d57c129b #16593
Follow-up to fa461b4eff52b413f88debf543b5350a6cef4724 #14486

Closes #16824
2025-03-27 10:21:57 +01:00
Daniel McCarney
3143efd86a
docs: include rustls-ffi in ECH docs 2025-03-27 08:48:13 +01:00
Yedaya Katsman
1d31f2592f
rustls: Add support for SSLKEYLOGFILE
With rustls-ffi 0.15+ we can set up a callback for writing TLS secrets
hooked up to call Curl_tls_keylog_write. To make sure the associated
file is cleaned up we update the Curl_ssl struct for the rustls-ffi vtls
backend to have a cleanup callback.

Closes #16828
2025-03-27 08:47:43 +01:00
Daniel McCarney
14761d8b61
docs: rework RUSTLS install instructions
Describes using a package manager or pre-built binaries and adopts the
0.15 installation from source instructions.

Previously the rustls docs described installing rustls-ffi from source
using the GNU Makefile. The upstream project has switched to using
cargo-c as a cross-platform solution that works well with the rust
toolchain, pkg-config, and Windows and so this needs an update.

Similarly, for folks that want to avoid the extra cargo-c tool
requirement, rustls-ffi provides binary releases for common platforms,
and some Linux distributions/package managers offer pre-built packages.

The install instructions are expanded to cover these options since
they're generally better for end users than building the dep. from
source (no `rustc` required).
2025-03-27 08:47:43 +01:00
Viktor Szakats
627e9816ff
cmake: add custom command scripts as dependencies where missing
Also some formatting.

Closes #16835
2025-03-26 15:31:53 +01:00
Viktor Szakats
1447726663
cmake: document SH_EXECUTABLE option
Closes #16830
2025-03-26 00:54:04 +01:00
Ben Bodenmiller
38b94c80f3
SSLCERTS: list support for SSL_CERT_FILE and SSL_CERT_DIR
Closes #16762
2025-03-25 08:20:39 +01:00
tiymat
d055a01ce9
scripts: update completion.pl to parse options from docs
Reported-by: kpcyrd on github
Fixes #16072
Closes #16789
2025-03-24 23:48:26 +01:00
Daniel Stenberg
76d7483fe5
INFRASTRUCTURE.md: add IRC and Matrix details
Closes #16809
2025-03-24 15:21:59 +01:00
Viktor Szakats
9465327084
cmake: fix clang-tidy builds to verify tests, fix fallouts
- cmake: disable test bundles for clang-tidy builds.
  clang-tidy ignores #included .c sources, and incompatible with unity
  and bundles. It caused clang-tidy ignoring all test sources. It also
  means this is the first time tests sources are checked with
  clang-tidy. (autotools doesn't run it on tests.)

- cmake: update description for `CURL_TEST_BUNDLES` option.

- fix tests using special `CURLE_*` enums that were missing from
  `curl/curl.h`. Add them as reserved codes.

- fix about ~50 other issues detected by clang-tidy: unchecked results,
  NULL derefs, memory leaks, casts to enums, unused assigments,
  uninitialized `errno` uses, unchecked `open`, indent, and more.

- drop unnecessary casts (lib1533, lib3207).

- suppress a few impossible cases with detailed `NOLINT`s.

- lib/escape.c: drop `NOLINT` no longer necessary.
  Follow-up to 72abf7c13a479edcde80afa60faad3f35f672c0b #13862 (possibly)

- extend two existing `NOLINT` comments with details.

Follow-up to fabfa8e4024473035b3e5c3c30c330be726d9bb4 #15825

Closes #16756
2025-03-24 10:14:58 +01:00
Daniel Stenberg
179c0258f5
curl_ws_recv.md: expand a little on the fragments the API delivers
Closes #16720
2025-03-14 13:36:02 +01:00
Viktor Szakats
a16485a42e
build: do not apply curl debug macros to tests/server by default
It seems unnecessary and possibly unexpected to build test servers with
debug-enabled features and memory tracking whenever the tested curl is
built like that (which is a requirement for some tests, so curl is
mostly built like that when running tests.) It also makes building
servers a little bit faster with cmake for the most common cases.

You can apply debug options to `tests/server` with these new options:
- `./configure`: `--enable-server-debug`.
- cmake: `-DENABLE_SERVER_DEBUG`.

Also sync the way we pass these macros in autotools, with CMake builds.
Before this patch, autotools passed them via `curl_config.h`. After this
patch it passes them on the command-line, like cmake builds do.

This patch also make these option no longer passed to examples and
`http/client` in cmake builds, where they were no-ops anyway.

Ref: #15000
Closes #16705
2025-03-14 12:59:32 +01:00
Calvin Ruocco
3588df9478
ws: fix and extend CURLWS_CONT handling
Follow-up to fa3d1e7d43bf0e4f589aeae737

Add test 2311 to verify

Closes #16687
2025-03-14 11:46:36 +01:00
Viktor Szakats
51d8213579
core: stop redefining E* macros on Windows, map EACCES, related fixes
Before this patch, standard `E*` errno codes were redefined on Windows,
onto matching winsock2 `WSA*` error codes, which have different values.
This broke uses where using the `E*` value in non-socket context, or
other places expecting a POSIX `errno`, e.g. file I/O, threads, IDN or
interfacing with dependencies.

Fix it by introducing a curl-specific `SOCKE*` set of macros that map to
`WSA*` on Windows and standard POSIX codes on other platforms. Then
verify and update the code to use `SOCKE*` or `E*` macro depending on
context.

- Add `SOCKE*` macros that map to either winsock2 or POSIX error codes.
  And use them with `SOCKERRNO` or in contexts requiring
  platform-dependent socket error codes.

  This fixes `E*` uses which were supposed be POSIX values, not `WSA*`
  socket errors, on Windows:
  - lib/curl_multibyte.c
  - lib/curl_threads.c
  - lib/idn.c
  - lib/vtls/gtls.c
  - lib/vtls/rustls.c
  - src/tool_cb_wrt.c
  - src/tool_dirhie.c

- Ban `E*` codes having a `SOCKE*` mapping, via checksrc.
  Authored-by: Daniel Stenberg

- Add exceptions for `E*` codes used in file I/O, or other contexts
  requiring POSIX error codes.

Also:
- ftp: fix missing `SOCKEACCES` mapping for Windows.
- add `SOCKENOMEM` for `Curl_getaddrinfo()` via `asyn-thread.c`.
- tests/server/sockfilt: fix to set `SOCKERRNO` in local `select()`
  override on Windows.
- lib/inet_ntop: fix to return `WSAEINVAL` on Windows, where `ENOSPC` is
  used on other platforms. To simulate Windows' built-in `inet_ntop()`,
  as tested on a Win10 machine.
  Note:
  - WINE returns `STATUS_INVALID_PARAMETER` = `0xC000000D`.
  - Microsoft documentation says it returns `WSA_INVALID_PARAMETER`
    (= `ERROR_INVALID_PARAMETER`) 87:
    https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#return-value
- lib/inet_ntop: drop redundant `CURL_SETERRNO(ENOSPC)`.
  `inet_ntop4()` already sets it before returning `NULL`.
- replace stray `WSAEWOULDBLOCK` with `USE_WINSOCK` macro to detect
  winsock2.
- move existing `SOCKE*` mappings from `tests/server` to
  `curl_setup_once.h`.
- add missing `EINTR`, `EINVAL` constants for WinCE.

Follow-up to abf80aae384319ef9b19ffbd0d69a1fbe7421f1f #16612
Follow-up to d69425ed7d0918aceddd96048b146a9df85638ec #16615
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377

Closes #16621
2025-03-13 00:03:25 +01:00
Daniel Stenberg
06ae0eceb9
STRPARSE: amend with recently added functions
Closes #16647
2025-03-10 12:18:48 +01:00
Daniel Stenberg
124c2bed2a
RELEASE-PROCEDURE.md: explain release candidates
Closes #16622
2025-03-08 10:49:46 +01:00
Viktor Szakats
25f8486f26
zlib: bump minimum to 1.2.5.2 (was: 1.2.0.4)
1.2.5.2 was released on 2011-12-18. (vs. 1.2.0.4 on 2003-08-10)

It allows to:
- use `Z_BLOCK` unconditionally.
- use `inflateReset2()` to replace `inflateEnd()` + `inflateInit2()`
  and save a memory allocation.
- use `Z_CONST` and `z_const` (in a future commit).

Suggested-by: Dan Fandrich
Ref: https://github.com/curl/curl/pull/16142#discussion_r1985449743

Closes #16616
2025-03-08 00:39:04 +01:00
Daniel Stenberg
d398fffae0
docs/HISTORY: add some events from the last year
Closes #16587
2025-03-06 16:06:17 +01:00
Stefan Eissing
9bfa64f850
gnutls: set priority via --ciphers
No longer ignore the `--ciphers` argument in gnutls curl builds, but use
it to set the gnutls priority string.

When the set ciphers start with '+', '-' or '!', it is *appended* to the
curl generated priority string. Otherwise it replaces the curl one
completely.

Add test_17_18 to check various combinations.

Closes #16557
2025-03-05 13:51:56 +01:00
Orgad Shaneh
7298c4320b
docs: adapt to removed --with-random
Amends 269fdd4c6ed5d837d57448ac977f6f300968df15.

Closes #16565
2025-03-05 08:19:15 +01:00
tiymat
6758aa722d
IMAP: add CURLOPT_UPLOAD_FLAGS and --upload-flags
Set properties on the uploaded resource.

Test 3209 and 3210 verify.

Closes #15970
2025-03-04 15:21:16 +01:00
Viktor Szakats
61407464bf
cmake: allow CURL_STATIC_CRT with UCRT VS2015+ builds
After this patch, we're back to 8.12.1, but disallowing
`CURL_STATIC_CRT=ON` with shared curl exe built with VS2013 or older.
Because those may crash. A stable reprducer is with `ENABLE_DEBUG=ON`
and calling `curl.exe -V`.

You can pass the necessary CMake and MSVC linker options manually,
to get around this condition.

Shared build with static UCRT may be crashing too, depending on
conditions. Consult the documentation about limitations of static CRT:
https://learn.microsoft.com/cpp/c-runtime-library/crt-library-features

Follow-up to 049352dd80e1ab73945c49a3bac2e4a08db32f98 #16516
Follow-up to edfa537100d6b5d2ac1b829c66757880afe59407 #16456
Ref: #16394
Closes #16522
2025-03-04 01:01:09 +01:00
Daniel Stenberg
aa18891dda
docs/cmdline-opts: unify HTTP version style in --help output
$ curl -h all | grep -- --http

Now:

     --http0.9                      Allow HTTP/0.9 responses
 -0, --http1.0                      Use HTTP/1.0
     --http1.1                      Use HTTP/1.1
     --http2                        Use HTTP/2
     --http2-prior-knowledge        Use HTTP/2 without HTTP/1.1 Upgrade
     --http3                        Use HTTP/3
     --http3-only                   Use HTTP/3 only

Before:

     --http0.9                      Allow HTTP 0.9 responses
 -0, --http1.0                      Use HTTP 1.0
     --http1.1                      Use HTTP 1.1
     --http2                        Use HTTP/2
     --http2-prior-knowledge        Use HTTP 2 without HTTP/1.1 Upgrade
     --http3                        Use HTTP v3
     --http3-only                   Use HTTP v3 only

Closes #16542
2025-03-03 23:09:19 +01:00
Daniel Stenberg
fb13923dd6
lib: add CURLFOLLOW_OBEYCODE and CURLFOLLOW_FIRSTONLY
With this change, the argument passed to the CURLOPT_FOLLOWLOCATION
option is now instead a "mode" instead of just a boolean. Documentation
is extended to describe the two new modes.

Test 1571 to 1581 verify.

Closes #16473
2025-03-03 11:35:48 +01:00
Stefan Eissing
0d3b5937b3
OpenSSL/quictls: add support for TLSv1.3 early data
based on #16450

Adds support for TLSv1.3 early data for TCP and QUIC via ngtcp2.

Closes #16477
2025-03-03 09:27:04 +01:00
Viktor Szakats
b4834a7d6d
examples: prefer return over exit() (cont.)
Some of these calls were not in callbacks. These examples may leak
handles.

Also fix some whitespace.

Follow-up to 08c7c937dc0dbd1f92f73360e5d8b2bb2ee6afa8 #16507
Closes #16524
2025-03-01 02:09:02 +01:00