500 Commits

Author SHA1 Message Date
Daniel Stenberg
8df0a5ba32 release-notes: fix warning
Follow-up to 2ec54556d4

Closes #18133
2025-08-01 16:02:54 +02:00
Daniel Stenberg
4b1a5fe436 top-complexity: set cutoff level to 80
Closes #18080
2025-07-30 09:13:50 +02:00
Daniel Stenberg
7b8594176d delta: fix counters
Follow-up to b1df1d38af

Closes #18072
2025-07-29 09:45:07 +02:00
Viktor Szakats
577ec09412 contrithanks: fix for BSD sed tool
Fixing on macOS, and possibly other BSDs:
```
sed: 83: ./docs/THANKS-filter: RE error: illegal byte sequence
```
Where line 83 contains `\xED`.

Switch to raw encoding to avoid `sed` evaluating the stream of bytes.

Ref: #18061

Closes #18062
2025-07-28 17:29:26 +02:00
Viktor Szakats
b1df1d38af delta: fix warnings, fix for non-GNU date tool
It makes the script run on BSD-like envs.

Follow-up to f63bdea790 #18058
Follow-up to 2ec54556d4 #17877

Closes #18061
2025-07-28 17:29:26 +02:00
Daniel Stenberg
f63bdea790 delta: drop the warnings+strict
They really don't do much good here and I rather do this than adding
'my' on 40+ lines.

Follow-up from 2ec54556d4

Closes #18058
2025-07-28 14:02:52 +02:00
Viktor Szakats
2ec54556d4 scripts: enable strict warnings in Perl where missing, fix fallouts
- add 'use warnings' and 'use strict' where missing from Perl scripts.
- fix 'Use of uninitialized value'.
- fix missing declarations.
- test1140.pl: fix 'Possible precedence issue with control flow operator'.
- fix other misc issues.

Most actual errors found during this PR were fixed and merged via
separate PRs.

Likely there are remaining warnings not found and fixed in this PR.

Closes #17877
2025-07-27 22:35:18 +02:00
Viktor Szakats
89771d19d5 tidy-up: prefer ifdef/ifndef for single checks
Closes #18018
2025-07-27 22:35:17 +02:00
Viktor Szakats
c37e06c642 build: fix build errors/warnings in rare configurations
- vtls: fix unused variable and symbols.
- ftp: fix unused variable.
- http: fix unused variables.
- smtp: fix unsued variable.
- wolfssl: fix unused variable with !proxy.
- libssh: fix unused argument.
- curl_trc: sync guards between declaration and definition.
- curl_trc: add missing guard for `Curl_trc_ssls` when !verbose.
- curl_trc: fix errors with !http + http3.
- curl_trc: fix missing function with !http + nghttp2.
- cf-h2-proxy: disable when !http + nghttp2, to avoid calling undeclared
  functions.
- sha256: fix missing declaration in rare configs.
- md4: fix symbol conflict when building GnuTLS together with AWS-LC or
  wolfSSL. By prioritizing the latter two. AWS-LC has no option
  to disable the clashing symbol. wolfSSL does, but the most seamless is
  to skip including GnuTLS's standalone `md4.h` to avoid the clash.
- build: fix errors with !http + nghttp2.
- build: catch !ssl + ssls-export combination in source. Convert
  build-level errors to warnings.
- build: fix errors with !http + http3.
- build: fix building curl tool and unit1302 in rare combinations.
  By always compiling base64 curlx functions.

- cmake: add `_CURL_SKIP_BUILD_CERTS` internal option.
  To disable automatically building certs with the testdeps target.
  To improve performance when testing builds.
  (used locally to find the failing builds fixed in this PR.)

Closes #17962
2025-07-23 22:17:03 +02:00
Daniel Stenberg
1962573a93 release-notes.pl: ignore dupes on input and output
Re-running this script now makes it track the already mentioned
changelog entries and not add them again even if the git log contains
them.

This makes the script better handle reruns in a release branch after
rebasing on a later version of master.

Closes #17937
2025-07-15 18:28:37 +02:00
Daniel Stenberg
f5a44e1549 top-complexity: also output average complexity
Closes #17920
2025-07-14 08:38:45 +02:00
Viktor Szakats
9bdd08b3b2 GHA: minor tidy-ups
- GHA/checksrc: make a step name more accurate.
- cmakelint.sh: make sure to run from project root.
  To make it easier to run locally.
- cmakelint.sh: use `set -eu`.

Closes #17915
2025-07-13 11:52:08 +02:00
Patrick Stoeckle
86f43af951 misc: fix typos
Just fixing some typos using: https://github.com/crate-ci/typos

Closes #17904
2025-07-12 08:59:44 +02:00
Viktor Szakats
75395eb003 scripts: fix to quote the copyright email address
Also:
- fix the generated output in repo files.

Cherry-picked from #17877
Closes #17903
2025-07-12 08:59:44 +02:00
Viktor Szakats
ddcfd2d511 tidy-up: whitespace (more in Perl)
Follow-up to 8eab2b7086 #17896
Cherry-picked from #17877
Closes #17901
2025-07-12 08:59:44 +02:00
Viktor Szakats
88ff396549 checksrc-all: rewrite in Perl, remove checksrc.bat
`checksrc.bat` was outdated and required Perl for `checksrc.pl` anyway.
Rewrite `checksrc-all.sh` in Perl, making it usable in envs without
a POSIX shell.

Closes #17882
2025-07-11 12:28:46 +02:00
Viktor Szakats
ef2ccf862f memory: stop overriding unused wcsdup()/_wcsdup() system functions
Also ban them via `checksrc`.

The code continues to use `_tcsdup()`.

Assisted-by: Daniel Stenberg

Closes #17840
2025-07-07 15:03:31 +02:00
Daniel Stenberg
c9bb9cd165 unit tests: extract "private" prototypes at build time
In order to do unit tests for private functions, functions that are
marked UNITTEST but without a global scope in the library, functions
that do not have prototypes in their corresponding header file, unit
tests previously brought their own private prototype *copy* into the
unit test.

This was error-prone when the internal function changes but the change
might be missed in the unit test which then uses an outdated prototype
copy for testing.

This change removes the private prototypes from unit tests and instead
introduces a C file parser that parses the specific C files and extracts
the necessary unit test prototypes into a generated header file for unit
tests to use. This geneated lib/unitprotos.h header is then included by
unit tests that need private prototypes.

Assisted-by: Viktor Szakats
Closes #17750
2025-06-30 23:16:40 +02:00
Dan Fandrich
0b98f596c8 firefox-db2pem: avoid use of eval in script
This could potentially be exploited by manipulating nicknames in the
cert DB.

Reported-by: behindtheblackwall on hackerone
Closes #17766
2025-06-28 21:12:27 -07:00
Viktor Szakats
f9656445ba checksrc: reduce exceptions, apply again to curlx
- tests/libtest: move exception to `stub_gssapi.h`.
- tests/libtest: move remaining exception to `testtrace.c`.
- tests/server: drop obsolete exception.
- docs/examples: move `BANNEDFUNC` exceptions to local files (3 lines).
- docs/examples: move `ERRNOVAR` exception to `ephiperfifo.c`.
- docs/examples: drop `typedef struct` (8 files).
- lib/curlx: add `.checksrc` with banned funcs copied from lib.
- checksrc: ban `strncpy`, `strtok_r`, `strtoul` by default.
  Drop local bans. Add exception for `strtoul` to `tests/server'.
- lib, src: sync banned funcs.

Also:
- REUSE: drop `stunnel.pem`, it no longer exists.
- docs/examples: formatting.
- docs/examples: simplify some `sizeof()`s.

Closes #17764
2025-06-27 17:33:35 +02:00
Viktor Szakats
e088e10454 cmake: replace the way clang-tidy verifies tests, fix issues found
Replace existing `mk-unity.pl` `--embed` workaround with running
`clang-tidy` manually on individual test source instead. This aligns
with how clang-tidy works and removes `mk-unity.pl` from the solution.

Also:
- mqttd: fix potentially uninitialized buffer by zero filling it.
  ```
  tests/server/mqttd.c:484:41: error: The left operand of '<<' is a garbage value
    [clang-analyzer-core.UndefinedBinaryOperatorResult,-warnings-as-errors]
    484 |       payload_len = (size_t)(buffer[10] << 8) | buffer[11];
        |                                         ^
  [...]
  tests/server/mqttd.c:606:45: error: The left operand of '<<' is a garbage value
    [clang-analyzer-core.UndefinedBinaryOperatorResult,-warnings-as-errors]
    606 |       topiclen = (size_t)(buffer[1 + bytes] << 8) | buffer[2 + bytes];
        |                                             ^
  ```
- sockfilt: fix potential out-of-bound pointer:
  ```
  tests/server/sockfilt.c:1128:33: error: The 2nd argument to 'send' is a buffer
     with size 17010 but should be a buffer with size equal to or greater than
     the value of the 3rd argument (which is 18446744073709551615)
     [clang-analyzer-unix.StdCLibraryFunctions,-warnings-as-errors]
   1128 |         ssize_t bytes_written = swrite(sockfd, buffer, buffer_len);
        |                                 ^
  ```
- clang-tidy: suppress bogus `bzero()` warnings that happens
  inside the notorious `FD_ZERO()` macros, on macOS.

Ref: https://github.com/curl/curl/pull/17680#issuecomment-2991730158

Closes #17705
2025-06-22 23:08:46 +02:00
Viktor Szakats
6a0cd4feb7 tests: make individual test sources compile cleanly
Tidy up headers and includes to ensure all individual test source
compile cleanly (but not link). To allow running clang-tidy (and
possibly other static analyzers) on them. It also improves readability
and allows to verify them locally, without the bundle logic.

clang-tidy ignores #included C files, so it's blind to bundle C files
the include these tests. The current workaround of embedding has
a couple of downsides:. meaningless filenames and line numbers,
missing issues, messing up self header paths. Thus, running it on
individual sources would be beneficial.

Also:
- de-duplicate includes.
- untangle some includes.
- formatting/indentation fixes.
- merge `getpart.h` into `first.h`.

Ref: https://github.com/curl/curl/pull/17680#issuecomment-2991730158

Closes #17703
2025-06-22 15:58:15 +02:00
Daniel Stenberg
84b62696d9 top-complexity: lower max allowed complexity threshold to 90
Down from 100. Also make it show all functions with complexity > 65
(down from 70).

Closes #17689
2025-06-21 10:52:15 +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
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
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
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
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
Daniel Stenberg
698491f444 tool_getparam: refactored, simplified
- add dedicated option functions for bools/none/strings
- simplify clearing (some) arguments, use '*' instead of ' '
- scripts/top-complexity: remove getparameter from whitelist
- handle --help separately
- getstr and getstrn do not allow a NULL input
- improve the ;auto check, it needs to be trailing
- add toggle bit helper function
- unify an error message for bad --no- use
- introduce generic handling of deprecated options: ARG_DEPR
- handle --no- prefix on more booleans:

    --cert-status
    --doh-cert-status
    --false-start
    --mptcp
    --ssl-no-revoke
    --ssl-revoke-best-effort
    --tcp-fastopen

Closes #17448
2025-05-28 14:25:32 +02:00
Samuel Henrique
d3a3d7afb6 wcurl: update to v2025.05.26
This release fixes a small issue with the retry strategy:

 * Increase number of retries to 5 (32 sec total time), fixing the
   problem with misleading output. Previously, it was showing a higher
   number of retries than what would be done and it always did only 3.

Closes #17461
2025-05-27 09:29:43 +02:00
Daniel Stenberg
ed07f59841 tool_operate: split up single_transfer
Complexity reduced from 124 to 83

Remove whitelisting of this function from the complexity script.

Closes #17437
2025-05-24 15:43:08 +02:00
Daniel Stenberg
203b4349af GHA: add a job to check function complexity
- Done with the new top-complexity script which uses the pmccabe tool.

- Any function scoring over 100 makes the test fail

- The script outputs all functions scoring over 70

- Two >100 functions are whitelisted by name, but they are not allowed
  to increase their scores.

Closes #17398
2025-05-21 22:59:13 +02:00
Viktor Szakats
e785e898a6 checksrc: avoid extra runs in CI, enable more check locally, fix fallouts
To avoid redundant work in CI and to avoid a single checksrc issue make
all autotools jobs fail. After this patch checksrc issues make fail
the checksrc job, the `dist / verify-out-of-tree-autotools-debug`,
`dist / maketgz-and-verify-in-tree`  jobs and the fuzzer job (if run).
Of these, the `dist` jobs replicate local builds, also testing the build
logic.

Also add a script to check the complete local repository, optionally
with the build tree to verify generated C files.

Also:
- automatically run checksrc in subdirectories having a `checksrc`
  target. (examples, OS400, tests http/client, unit and tunit)
- tests/libtest: make sure to run `checksrc` on generated `lib1521.c`.
  (requires in-tree autotools build.)
- tests: run `checksrc` on targets also for non-`DEBUGBUILD`
  builds. It ensures to check `lib1521.c` in CI via job
  `dist / maketgz-and-verify-in-tree`.
- src: drop redundant `$(builddir)` in autotools builds.
- scripts: add `checksrc-all.sh` script to check all C sources and
  the build directory as an option.
- use the above from CI, also make it verify all generated sources.
- silence `checksrc` issues in generated C sources.
- checksrc: add `-v` option to enable verbose mode.
- checksrc: make verbose mode show checked filename and fix to only
  return error on failure.
- make sure that generated C files pass `checksrc`.

Assisted-by: Daniel Stenberg

Closes #17376
2025-05-19 18:59:50 +02:00
Dan Fandrich
028c12948c scripts: move the ruff linter command into a script
This makes it easier for users to run it with the correct options
locally. Also, update the ruff, pytype and cmakelint versions to the
latest current ones.

Closes #17343
2025-05-13 16:41:32 -07:00
Daniel Stenberg
4f055feee2 mk-ca-bundle: switch URLs to GitHub versions
The offical Firefox source code has moved to GitHub:
https://github.com/mozilla-firefox/firefox

This change adjusts to the new URLs. The old branches nss and central
are not provided so they are removed and the new 'autoland' is added.

Closes #17321
2025-05-12 11:09:17 +02:00
Viktor Szakats
3fcddc835c scripts: fix perl indentation, whitespace, semicolons
Ref: #17116

Closes #17209
2025-04-29 19:35:55 +02:00
Viktor Szakats
c1c99054ab cmake: install shell completions for cross-builds
Also:
- omit auto-detecting `CURL_COMPLETION_FISH_DIR` via `pkg-config`
  for cross-builds and when `CMAKE_INSTALL_PREFIX` is set.
- flatten nested `if`s.

Note:
On macOS with Homebrew, `pkg-config --variable completionsdir fish`
returns the version-specific Cellar path instead of the permanent path
`/opt/homebrew/share/fish/vendor_completions.d/`. This mimics what
autotools does, but may need further fixing, possibly upstream.
9c13e62b00/Formula/f/fish.rb
ce631fd2fb/cmake/Install.cmake (L15-L21)

Ref: #17147
Ref: 51170b52d1 #17159
Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103938

Closes #17145
2025-04-24 10:04:17 +02:00
Helmut Grohne
51170b52d1 autotools: install shell completion files on cross build
Before 8.13.0, it was not possible to generate them as it required
 calling the compiled binary, but this has been fixed.

Co-authored-by: Samuel Henrique <samueloph@debian.org>

Closes #17159
2025-04-23 23:21:05 +02:00
Viktor Szakats
73b6f8d2fe cmake: fix fish install directory detection via pkg-config
Follow-up to c8b0f0c9ad #16833

Closes #17147
2025-04-23 11:34:27 +02:00
Daniel Stenberg
23bed347b3 wcurl: import v2025.04.20 script + docs
Build/install the man page. Install the script.

This an "import" rather than just adding the script into the release tarball
with maketgz to make sure the tarball build is completely reproducible.

wcurl development, issues etc is still to be done at
https://github.com/curl/wcurl

Assisted-by: Viktor Szakats
Assisted-by: Samuel Henrique

Closes #17035
2025-04-21 11:06:44 +02:00
Viktor Szakats
f616704980 cmake: fix shell completion install when just one flavor is enabled
Also:
- tidy up the `if` tree.
- drop `include(GNUInstallDirs)` in favor of the upper-level one.

Reported-by: Daniel Engberg
Bug: https://github.com/curl/curl/issues/16946#issuecomment-2814663246
Follow-up to c8b0f0c9ad #16833

Closes #17094
2025-04-18 10:34:11 +02:00
Stefan Eissing
1ebd92d0fd async: DoH improvements
Adds a "meta_hash" to each easy handle for keeping special data during
operations. All meta data set needs to add its destructor callback, so
that meta data gets destroyed properly when the easy handle is cleaned
up or reset.

Add data->master_mid for "sub" transfers that belong to a "master" easy
handle. When a "sub" transfer is done, the corresponding "master" can
add a callback to be invoked. Used in DoH name resolution.

DoH: use easy meta hash to add internal structs for DoH name resolution.
One in each in each probe easy handle. When probes are done, response
data is copied from the probe to the initiating easy.

This allows DoH using transfers and their probes to be cleaned up in any
sequence correctly.

Fold DoH cleanup into the Curl_async_shutdown() and Curl_async_destroy()
functions.

Closes #16384
2025-04-16 16:06:03 +02:00
Daniel Stenberg
625f2c1644 lib: include files using known path
by including headers using "../[header]" when done from C files in
subdirectories, we do not need to specify the lib source dir as an
include path and we reduce the risk of header name collisions with
headers in the SDK using the same file names.

Idea-by: Kai Pastor

Ref: #16949
Closes #16991
2025-04-08 17:00:00 +02:00
Daniel Stenberg
eeed87f056 mk-ca-bundle.pl: follow redirects
The Mozilla hosted files have started to redirect. Follow them to restore
script functionality.

Reported-by: Harry Sintonen
Closes #16995
2025-04-08 11:47:05 +02:00
Carlos Henrique Lima Melara
2f5e4e0db4 scripts: completion.pl: sort the completion file for all shells
The reproducible builds effort in Debian has caught a regression in curl
8.13.0-rc1 but we were a bit slow to realize it. The ordering of the
completion file for fish is not deterministic so it can differ between
builds. Since there is no restriction about the order of the completion
file for fish, let's just sort it too.

Closes #16985
2025-04-06 11:35:38 +02:00
Daniel Stenberg
f3527ed443 randdisable: build randomizer
This script makes a "random" build using configure and verifies that it
builds curl correctly. It randomly adds a number of the available
--disable-* flags to configure. When it detects a problem the script
stops, otherwise it continues trying more combinations.

Closes #16962
2025-04-05 14:59:17 +02:00
Viktor Szakats
b809629f8c cmake: use absolute paths for completion targets
Fixing potential:
```
CMake Error at scripts/CMakeLists.txt:72 (install):
  install FILES given directory "/usr/ports/ftp/curl/work/.build/scripts/" to
  install.
```

Reported-by: Daniel Engberg
Fixes #16946
Follow-up to c8b0f0c9ad #16833
Closes #16954
2025-04-04 02:34:52 +02:00
Dan Fandrich
eb0c622a5b scripts: fix --opts-dir help in completion.pl
The help text gave the wrong option name.

Reported-by: Daniel Engberg
Ref: #16946
2025-04-03 16:14:34 -07:00