Commit graph

37845 commits

Author SHA1 Message Date
Viktor Szakats
4b4637a445
build: disable typecheck via the command-line instead of curl_config.h
To make it apply to examples. This in turn makes analyzers run quicker
and with fewer false positives.

It's a special disable option, having its effect via `curl/curl.h`.

Bug: https://github.com/curl/curl/pull/20649#issuecomment-3934885021
Follow-up to 9e6f1c5efb #19637

Closes #20650
2026-02-20 16:32:37 +01:00
Viktor Szakats
1eb79cf54b
cmake: include curl/curl.h as system header in integration tests
Follow-up to fb70812437 #16126

Closes #20651
2026-02-20 16:32:37 +01:00
Viktor Szakats
dd82205bb2
memdebug: include backtrace.h as system header
Closes #20642
2026-02-20 16:32:37 +01:00
Daniel Lublin
d4234d9f46
docs: clarify --ipv4 and --ipv6
Try to make the wording more clear. It is the addresses in the resolver
result that are affected, not anything regarding *how* resolving is
done.

Closes #20585
2026-02-20 12:50:10 +01:00
Anna Liberty
3699976b79
docs: reword explanation of --variable option
Simplify the language expaining the --variable option, reducing
repetition. Also fix some minor grammar issues and makes language for
examples more consistent.

Closes #20636
2026-02-20 12:08:52 +01:00
Viktor Szakats
aa1854a8ff
tests/server/sockfilt: check for NULL tv to silence clang-tidy
A NULL dereference cannot happen with existing use of this code.

linux-mingw, CM clang-tidy:
```
/home/runner/work/curl/curl/tests/server/sockfilt.c:720:24: error: Access
 to field 'tv_sec' results in a dereference of a null pointer (loaded from
 variable 'tv') [clang-analyzer-core.NullDereference,-warnings-as-errors]
  720 |             tv->tv_sec = 0;
      |             ~~         ^
```
Ref: https://github.com/curl/curl/actions/runs/22191200093/job/64179197235?pr=20631#step:10:283

Cherry-picked from #20631

Closes #20639
2026-02-20 12:08:52 +01:00
Viktor Szakats
4042e7d9d8
clang-tidy: work around clang-tidy <=20 false positive (Windows)
clang-tidy <= v20 (as seen between 18.1.3 and 20.1.2) report
`readability-uppercase-literal-suffix` originating from mingw-w64 system
header `_mingw_mac.h` via `define __MSABI_LONG(x) x ## l`

Triggered by `SOCKENOMEM` (e.g. in tests/server/sockfilt.c):
```
warning: integer literal has suffix 'l', which is not uppercase [readability-uppercase-literal-suffix]
```

Work around by replacing Windows macro `WSA_NOT_ENOUGH_MEMORY`
with its literal value.

Bug: https://github.com/curl/curl/pull/20631#issuecomment-3930619868
Follow-up to c07c3cac74 #20629
Cherry-picked from #20631

Closes #20638
2026-02-20 12:08:52 +01:00
Viktor Szakats
c927b18d6b
INSTALL-CMAKE.md: document more settings requiring absolute paths
Cherry-picked from #20631

Closes #20637
2026-02-20 12:08:52 +01:00
Viktor Szakats
6dc5f2948c
cmake: improve clang-tidy invocation for tests in cross-builds
By passing to clang-tidy the C compiler with `--target` and sysroot
options, if any.

Fixing (GHA/windows, linux-mingw, CM clang-tidy):
```
lib/curl_setup.h:841:10: error: 'io.h' file not found [clang-diagnostic-error]
  841 | #include <io.h>
      |          ^~~~~~
Found compiler error(s).
FAILED: [code=1] tests/server/CMakeFiles/servers-clang-tidy bld/tests/server/CMakeFiles/servers-clang-tidy
cd tests/server && /usr/bin/clang-tidy --config-file=.clang-tidy.yml
--warnings-as-errors=* --checks=-clang-diagnostic-unused-function first.c getpart.c util.c dnsd.c [...]
-- <-D-options> <-I-options> <cflags>
```

For reference, this is CMake's built-in clang-tidy invocation:
```
/usr/local/bin/cmake -E __run_co_compile --tidy="/usr/bin/clang-tidy;--config-file=.clang-tidy.yml;
--warnings-as-errors=*;--extra-arg-before=--driver-mode=gcc" --source=lib/curl_fopen.c
-- /usr/bin/clang --target=x86_64-w64-mingw32 <-D-options> <-I-options> <cflags>
```

Also:
- bump cmakelint `--max-statements`. Needs 59 after this patch.
- use undocumented CMake variables:
  - `CMAKE_C_COMPILE_OPTIONS_TARGET` for `--target=`
  - `CMAKE_C_COMPILE_OPTIONS_SYSROOT` for `--sysroot=`

Cherry-picked from #20631

Closes #20640
2026-02-20 12:08:52 +01:00
Viktor Szakats
1858126cca
cmake: sync clang-tidy arg order in tests with C compiler
Pass macro definitions first. For uniformity, no functional difference.

To match:
```
CMAKE_C_COMPILE_OBJECT = '<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> [...]'
```

Closes #20635
2026-02-19 19:08:31 +01:00
Viktor Szakats
b5a6d617d1
clang-tidy: sort list [ci skip]
Follow-up to b7ecd14725 #20632
2026-02-19 16:34:01 +01:00
Viktor Szakats
b7ecd14725
clang-tidy: replace comma-separated string with list in config
Bump required clang-tidy version to v17.0.0 for this.

Ref: https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/index.html
Follow-up to 4497dbd9ac #20605

Closes #20632
2026-02-19 16:27:08 +01:00
Viktor Szakats
8712fac111
clang-tidy: drop redundant casts
Found via `readability-redundant-casting`. Prone to false positives, not
enabled.

Ref: https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-casting.html

Closes #20630
2026-02-19 15:27:17 +01:00
Viktor Szakats
c07c3cac74
clang-tidy: enable and fix readability-uppercase-literal-suffix
Ref: https://clang.llvm.org/extra/clang-tidy/checks/readability/uppercase-literal-suffix.html

Closes #20629
2026-02-19 15:27:17 +01:00
Viktor Szakats
3cdc167425
clang-tidy: check readability-redundant-preprocessor, fix fallouts
Also:
- cipher_suite: merge `USE_MBEDTLS` `#if` blocks.

Ref: https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-preprocessor.html

Closes #20628
2026-02-19 15:27:17 +01:00
Viktor Szakats
bd60df527c
clang-tidy: check readability-redundant-control-flow
Also fix fallouts.

Ref: https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-control-flow.html

Closes #20625
2026-02-19 12:44:52 +01:00
Viktor Szakats
c878160e9c
clang-tidy: sync argument names in prototype and definition
Discovered with clang-tidy checker
`readability-inconsistent-declaration-parameter-name`.

Also:
- do not enforce the above because of inconsistencies still present
  between public API prototypes and definitions. (Also betwen man page
  protos, and man page examples, and other parts of the code, e.g.
  `easy` vs `curl` vs `d` vs `handle`) Perhaps subject for a future
  effort:
  https://github.com/curl/curl/actions/runs/22166472728/job/64094691653
- enable and fix `readability-named-parameter` where missing.

Refs:
https://clang.llvm.org/extra/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.html
https://clang.llvm.org/extra/clang-tidy/checks/readability/named-parameter.html

Closes #20624
2026-02-19 12:44:37 +01:00
Viktor Szakats
7c01bb23bc
rtspd: fix to check realloc() result
Also enable `bugprone-suspicious-realloc-usage` clang-tidy option
to verify.

Fixing:
```
tests/server/rtspd.c:328:37: error: 'req->rtp_buffer' may be set to null if 'realloc' fails,
 which may result in a leak of the original buffer
 [bugprone-suspicious-realloc-usage,-warnings-as-errors]
  328 |                   req->rtp_buffer = realloc(req->rtp_buffer,
      |                   ~~~~~~~~~~~~~~~   ^       ~~~~~~~~~~~~~~~
```

Ref: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/suspicious-realloc-usage.html

Closes #20621
2026-02-19 12:38:49 +01:00
Viktor Szakats
7e203c15e6
cmake/FindMbedTLS: add workaround for missing static MSVC mbedcrypto.lib 4.0.0
Seen with mbedTLS 4.0.0. mbedTLS 4.0.0 renamed `mbedcrypto` lib to
`tfpsacrypto`, while also keeping a copy under the old name to aid
transition. However, this compatibility logic is broken for MSVC static
builds, and the old name missing.

Work around by looking for the new name in the raw detection codepath.

Note that using `pkg-config`-based detection also works as a workaround.

Reported-by: tawmoto on github
Fixes #20616
Ref: https://github.com/Mbed-TLS/mbedtls/blob/v4.0.0/library/CMakeLists.txt#L275-L282
Ref: https://github.com/Mbed-TLS/mbedtls/issues/10605

Closes #20617
2026-02-19 12:38:49 +01:00
Viktor Szakats
4497dbd9ac
clang-tidy: fixes and improvements
Fix bigger and smaller kinks in how clang-tidy is configured and used.
Sync behavior more between autotools and cmake, lib/src and tests. Bump
clang-tidy minimum version and prepare logic to allow using clang-tidy
to a fuller extent.

- move clang-tidy settings from builds to a new `.clang-tidy.yml`.
  To make it easy to see and edit checks at one place. Also to allow
  using the `--checks=` option internally to silence tests-specific
  checks. (clang-tidy does not support multiple `--check=` options via
  the command-line.)
  Use explicit `--config-file=` option to point to the configuration.
- .clang-tidy.yml: link to documentation.
- suppress `clang-diagnostic-nullability-extension` due to a false
  positive in libtests with `CURL_WERROR=ON` and `PICKY_COMPILER=OFF`.
- .clang-tidy.yml: enable `portability-*`, `misc-const-correctness`.
- drop `--quiet` clang-tidy option by default to make its working a bit
  more transparent. The extra output is minimial.
- consistently use double-dashes in clang-tidy command-line options.
  Supported by clang-tidy 9.0.0+ (2019-09-19). Before this patch single
  and double were used arbitrarily.
- src/tool_parsecfg: silence false positive `clang-analyzer-unix.Stream`.
  Seen with clang 18 + clang-tidy 19 and 20 (only with autotools.)
- INTERNALS: require clang-tidy 14.0.0+. For the `--config-file` option.
- INTERNALS: recommend clang-tidy 19.1.0+, to avoid bogus
  `clang-analyzer-valist.Uninitialized` warnings. (bug details below)

autotools:

- allow configuring the clang-tidy tool via `CLANG_TIDY` env.
  Also to use in GHA to point to a suffixed clang-tody tool.
- fix to pass CFLAGS to lib, src sources.
  (keep omitting them when using a non-clang compiler.)
- fix to pass `--warnings-as-errors=*` in quotes to avoid globbing.

cmake:

- fix to not pass an empty `-I` to clang-tidy.
- fix to pass CFLAGS (picky warnings) to clang-tidy for test sources.
  (keep omitting them when using a non-clang compiler.)
- fix to disable `clang-diagnostic-unused-function` for test sources.
  (tests have static entry points, which trigger this check when
  checking them as individidual sources.)
- fix forwarding `CURL_CLANG_TIDYFLAGS` to clang-tidy.
- force disable picky warnings when running clang-tidy with a non-clang
  compiler. To not pass these flags when checking lib and src.

CI:

- GHA/linux: avoid clang-tidy bug by upgrading to v19, and drop the
  workaround.
- GHA/linux: switch to clang from gcc in the clang-tidy job. Using gcc
  doesn't allow passing CFLAGS to clang-tidy, making it less effective.
  (My guess this was one factor contributing to this job often missing
  to find certain issues compared to GHA/macos.)

I recomment using clang-tidy with a clang compiler, preferably the same
version or one that's compatible. Other cases are best effort, and may
fail if a C flag is passed to clang-tidy that it does not understand.
Picky warnings are mostly omitted when using a non-clang compiler,
reducing its usefulness.

Details and reproducer for the v18 (and earlier) clang-tidy bug,
previously affecting the GHA/linux job:

clang-tidy <=18 emits false warnings way when passing multiple C sources
at once (as done with autotools):

```sh
cat > src1.c <<EOF
#include <string.h>
static void dummy(void *p) { memcmp(p, p, 0); }
EOF

cat > src2.c <<EOF
#include <stdarg.h>
void vafunc(int option, ...)
{
  va_list param;
  va_start(param, option);
  if(option)
    (void)va_arg(param, int);
  va_end(param);
}
EOF

/opt/homebrew/opt/llvm@18/bin/clang-tidy --checks=clang-analyzer-valist.Uninitialized src1.c src2.c

# src2.c:7:11: warning: va_arg() is called on an uninitialized va_list [clang-analyzer-valist.Uninitialized]
```

Follow-up to e86542038d #17047

Closes #20605
2026-02-19 00:02:11 +01:00
Viktor Szakats
5fa5cb3825
build: fix -Wunused-macros warnings, and related tidy-ups
- fix internal macro `AN_APPLE_OS` reused between sources without
  resetting it. It may potentially have left the system sha256
  function unused.
- fix to define `WOLFSSL_OPTIONS_IGNORE_SYS` so that it always applies
  to wolfSSL headers, also during feature detection.
- md4, md5, sha256: simplify fallback logic.
- delete 20+ unused macros.
- scope or move macros to avoid `-Wunused-macros` warnings.
- examples: delete unused code.

The warning detects macros defined but not used within the same C
source. It does not warn for macros defined in headers. It also works
with unity builds, but to a lesser extent.

Closes #20593
2026-02-19 00:00:48 +01:00
Viktor Szakats
633ec719d5
curl_ntlm_core: merge two #if blocks
Cherry-picked from #20593

Closes #20620
2026-02-18 22:04:45 +01:00
Viktor Szakats
dc08922a61
openssl: disable local keylog feature if built-in upstream
Reported-by: Paul Howarth
Fixes #20611

Closes #20614
2026-02-18 12:04:23 +01:00
Stefan Eissing
f1c9d5e484
easy: reset errorbuf on eyeballing success
Any failf() that fill the errorbuf need to be forgotten once happy
eyeballing finds a succssful winner. Because the errorbuf, once set, is
not overwritten with future error information.

Adds test_05_05 to verify.

Reported-by: Tim Friedrich Brüggemann
Fixes #20608

Closes #20613
2026-02-18 12:04:23 +01:00
Dan Fandrich
36c2c7626f libcurl-security.md: Fix typos and add a point about URLs 2026-02-17 12:38:26 -08:00
Viktor Szakats
970e59a82f
GHA/windows: mark 3023/3024 flaky
Same as the other two tests, but for Schannel.

Follow-up to dead29362a #20602
Follow-up to 3ae234b2a3 #20462

Closes #20609
2026-02-16 21:13:43 +01:00
Viktor Szakats
8fb87f5a4a
lib: delete unused local includes
Filtered from `clang-tidy` `misc-include-cleaner` hits.

Also:
- pingping: scope includes.
- doh: say the reason for an include.

Closes #20607
2026-02-16 21:13:43 +01:00
Viktor Szakats
daa6b27b4d
include: avoid recursive macros
To fix potential `-Wdisabled-macro-expansion` warnings when using these
macros within other macros. Fixing for example:
```
lib/doh.c:328:3: error: disabled expansion of recursive macro [clang-diagnostic-disabled-macro-expansion,-warnings-as-errors]
  328 |   ERROR_CHECK_SETOPT(CURLOPT_URL, url);
      |   ^
lib/doh.c:271:14: note: expanded from macro 'ERROR_CHECK_SETOPT'
  271 |     result = curl_easy_setopt((CURL *)doh, x, y);       \
      |              ^
include/curl/curl.h:3332:44: note: expanded from macro 'curl_easy_setopt'
 3332 | #define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)
      |                                            ^
[...]
```

Also update comments on why curl continues to disable
`-Wdisabled-macro-expansion` and `-Wused-but-marked-unused` warnings.

Follow-up to 92f215fea1 #18477

Closes #20597
2026-02-15 22:54:32 +01:00
Viktor Szakats
1eec8b8d03
mprintf: rename internal enum to avoid collision with AmigaOS symbol
Also:
- drop AmigaOS workaround.

Closes #20584
2026-02-15 22:54:31 +01:00
Viktor Szakats
dead29362a
GHA/windows: mark test 3000 flaky too
Similar to test 3001 marked flaky earlier.

Example:
https://github.com/curl/curl/actions/runs/22035738719/job/63668228484?pr=20597#step:14:4099

Follow-up to 3ae234b2a3 #20462

Closes #20602
2026-02-15 22:54:31 +01:00
Viktor Szakats
a55f160b13
src: simplify declaring curl_ca_embed
Also to avoid `-Wunused-macros` warnings.

Follow-up to 8a3740bc8e #14059
Cherry-picked from #20593

Closes #20601
2026-02-15 12:48:46 +01:00
Viktor Szakats
298f73f95b
cmake: enable binutils ld workaround for all toolchains at build-time (revert)
The change was valid, but caused an annoying warning with perfectly
working non-binutils ld linkers:
```
ld: warning: ignoring duplicate libraries: 'my/path/usr/local/lib/libcrypto.a'
```
(seen with Apple clang, when using static `libcrypto.a`)

It means that for the binutil ld hack to work at consumption-time, curl
must be built with the same picky binutils (gcc) toolchain.

Reverts 795433b923 #20434

Closes #20594
2026-02-15 12:48:46 +01:00
Viktor Szakats
9e1e5ea67c
curl_setup.h: update/expand OPENSSL_SUPPRESS_DEPRECATED comment
Document functions/features requiring it.

Follow-up to cab040248d #10543
Cherry-picked from #20593

Closes #20600
2026-02-15 12:48:46 +01:00
Viktor Szakats
8494012196
examples/usercertinmem: use modern OpenSSL API, drop mentions of RSA
Replacing API calls deprecated by OpenSSL 3, and also missing
from OpenSSL 3 no-deprecated builds, fixing builds with the latter:
`PEM_read_bio_RSAPrivateKey()`, `RSA_free()`,
`SSL_CTX_use_RSAPrivateKey()`

Also: rename callback to match its `cacertinmem.c` sibling.

Fixes #20595
Closes #20596
2026-02-14 14:07:55 +01:00
Viktor Szakats
d445f2d930
lib: skip compiling code with features disabled
In non-SSL, non-SSH, non-H3, non-AppleSecTrust builds.

Also:
- drop unused internal macro `SSL_SYSTEM_VERIFIER`.

Closes #20587
2026-02-13 15:48:23 +01:00
Viktor Szakats
0649eb0825
GHA/windows: bump cygwin/cygwin-install-action to v6.1
Previous tag v6 changed upstream and points to a different commit. This
made zizmor unhappy. Previous commit is now tagged v6.0 in case we need
it.

Closes #20591
2026-02-13 15:41:04 +01:00
Viktor Szakats
cf9e445e03
cmake: normalize uppercase hex winver (for display)
For display and consistency with other regexp. It did not cause harm.

Follow-up to 2100d9fde2 #12044

Closes #20586
2026-02-13 11:56:13 +01:00
Viktor Szakats
20ae14a322
cmake: warn for invalid CURL_TARGET_WINDOWS_VERSION values
Also:
- INSTALL-CMAKE.md: add an example for `CURL_TARGET_WINDOWS_VERSION`.

Reported-by: nono303 on github
Ref: #20575
Closes #20582
2026-02-13 00:24:49 +01:00
Viktor Szakats
fb5541c28b
GHA/windows: replace Cygwin distro server
`mirrors.kernel.org` is down.

Also:
- link to `mirrors.kernel.org` status page.
- link to list of mirrors.

Ref: https://archlinux.org/mirrors/kernel.org/

Closes #20583
2026-02-13 00:22:57 +01:00
Daniel Stenberg
207ab758f5
ws/tftp: include header file even when protocol disabled
As the scheme details are still needed. clang 21 warned for this in HTTP-only
builds.

Reported-by: Marcel Raad
URL: https://curl.se/mail/lib-2026-02/0008.html
Closes #20568
2026-02-12 22:47:53 +01:00
Daniel Stenberg
36dc50b7e3
smb: include arpa/inet.h for NonStop
Reported-by: Randall S. Becker
URL: https://curl.se/mail/lib-2026-02/0010.html
Closes #20579
2026-02-12 22:46:56 +01:00
Daniel Stenberg
10bb489b22
schannel: refactor: reduce variable scopes, fix comment, fix indent
Refactor and simplify the Schannel code, primarily by reducing
duplicated buffer-management and credential-setup logic.

- split client certificate selection into get_client_cert() and SSPI
  credential acquisition into acquire_sspi_handle()
- introduce a struct sbuffer for encrypted/decrypted buffering
- Add ensure_encoding_size() and ensure_decoding_size() helpers to
  centralize buffer growth/realloc decisions
- Tighten variable scopes and tidy indentation/logging in the handshake
  and receive/decrypt loops.
- Update comments and adjusts some receive error-condition handling to
  better preserve buffered-data behavior.

Closes #20569
2026-02-12 22:34:58 +01:00
Daniel Stenberg
df6f3ae60a
multi: split multi_runsingle into sub functions
To reduce complexity.

- is_finished() checks if the individual transfer is done

- handle_completed() is the logic that runs for a completed
  transfer

Closes #20573
2026-02-12 22:34:23 +01:00
Viktor Szakats
3ce596a956
msvc: VS2026: unlock picky warning in cmake, test in CI
Upgrade a GHA/windows job to VS2026 (from VS2022), using a runner image
released a week ago. It also comes with the same Windows SDK as VS2022:
v10.0.26100.0.

The runner image uses Windows 2025 unfortunately, which makes the job
run significantly slower than before this patch:
- configure: 49s -> 1m10s
- build: 3s -> 5s
- install test prereqs: 23s -> 27s
- run tests: 3m18s -> 4m11s
- build examples: 15s -> 25s

It's a shame.

Also:
- cmake: enable picky warnings for VS2026 internal version 19.50.
  Build is clean with existing options.
- GHA/windows: make the built-in OpenSSH intall path recognize
  the windows-2025-vs2026 image as windows-2025.
- windows-2025-vs2026 is able to load the cached stunnel made on
  the windows-2022 runner.
- disk use of the build is almost identical to VS2022.

Before: https://github.com/curl/curl/actions/runs/21955482367/job/63418133880
After: https://github.com/curl/curl/actions/runs/21957589847/job/63426546943

Ref: 71f0157880/images/windows/Windows2025-VS2026-Readme.md
Ref: #20575

Closes #20577
2026-02-12 19:04:51 +01:00
renovate[bot]
aece530e26
GHA: update google/boringssl to v0.20260211.0
Closes #20566
2026-02-12 17:38:35 +01:00
Viktor Szakats
5edd79aa93
cmake: add CURL_PATCHSTAMP configuration variable, test in CI
Also:
- INSTALL-CMAKE.md: alpha sort.

Closes #20576
2026-02-12 17:29:22 +01:00
Viktor Szakats
516a0cd382
cmake: add BORINGSSL_VERSION configuration variable, test in CI
To simplify setting BoringSSL version, using:
`-DBORINGSSL_VERSION=0.20260211.0`
or
`-DBORINGSSL_VERSION=${boringssl_version}`

Previously it could be set via C flags, using complicated shell quotes:
`-DCMAKE_C_FLAGS="-DCURL_BORINGSSL_VERSION=\\\"${boringssl_version}\\\""`
(the C flags method remains, also for autotools)

It'd be nice if BoringSSL published its version not just via
`MODULE.bazel` in its source tree, but from its public headers, to make
these workarounds unnecessary.

Also:
- GHA/http3-linux: test both options.

Closes #20571
2026-02-12 16:29:49 +01:00
Viktor Szakats
61df5f466c
tidy-up: miscellaneous
- curl_ntlm_core, smtp, schannel: fix comments.
- curl_setup.h: fix to undef before define.
- tool_doswin, server/sockfilt: reduce variables scopes.
- tool_doswin: drop an interim variable.
- windows: replace `SOCKET_ERROR` with `0` to align with rest of code.
- libssh2: rename variable to align with rest of code.
- gtls, unit1398: use `#if 0`.
- curl_trc.h, curlx/inet_ntop.h: add missing parentheses in macro
  expressions.
- ldap.c: set empty macro to `do {} while(0)`.
- examples/crawler: rename a non-CURLcode `result` variable.
- CURLINFO_TLS_SESSION: drop stray colon.
- add `const` to casts where missing.
- drop unnecessary parentheses.
- fix indent.
- quote style.
- comment style.
- whitespace, newlines, fold/unfold.

Closes #20554
2026-02-12 14:52:16 +01:00
Viktor Szakats
2a92c39a21
windows: tidy up wincrypt.h / BoringSSL/AWS-LC coexist workaround
- openssl: move and expand explanatory comment.

- openssl: drop duplicate workaround.

- schannel: drop workaround. Unnecessary, because OpenSSL headers are
  not included in or after schannel code.

- schannel: drop explicit `wincrypt.h` include. It's indirectly
  included by system `<schannel.h>`.

- ldap: drop explicit `wincrypt.h` include.
  It isn't used there, and also not required for the workaround.
  `winldap.h` keeps including it indirectly.

Tested with BoringSSL and AWS-LC (MultiSSL with Schannel), also LDAP
enabled, and H3, unity and non-unity, and all tested cases build fine.

In lib in general, the point is to have the `#undef`s between the first
`wincrypt.h` include [1] and the first OpenSSL include [2], within a
single compilation unit. For non-unity builds the only such source is
`openssl.c`. For unity ones, depending on batch size, in theory we
should `#undef` after each `wincrypt.h` include. In practice this is
overkill and most cases are covered by `#undef`-fing _first_ in
`vtls/openssl.c`, and `#undef` in `ldap.c`. It's not impossible that we
need to add more undefs after further `wincrypt.h` includes to cover so
far undiscovered build cases [3]. Though I could not find more with the
current sources and source order.

It's also an option to include OpenSSL first, then `wincrypt.h`, as
done in libtests, but for lib and `vtls/openssl.c` it's more practical
to do the opposite.

[1] can be indirect, e.g. via `iphlpapi.h`, `schannel.h`, `winldap.h`.

[2] in
- BoringSSL/AWS-LC: any include (due to `openssl/base.h`).
  Original fix removed by BoringSSL in year
  [2014](ded93581f1 (diff-878093ea6426091505b4c49c59b78924f42859af0eb4ce39b8089bda9577e013)).
- OpenSSL: `openssl/ssl.h`, `openssl/x509v3.h`, and some more affected,
  and including `openssl/ossl_typ.h` does the `#undef` automatically.
  Since [3.1.0+](fbb9a1f997)
  each inclusion does the `#undef`, in 3.0.x (and earlier) only
  the first inclusion did. Initially fixed in
  [0.9.6d](1955b87423)
- LibreSSL [2.3.0+](0fa826d34f):
  not affected, though to suppress another warning 3.8.2+ and
  a [define](e7fe6caab2)
  is necessary.

[3] `lib/Makefile.inc` defines the order of unity sources.

For libtests, the case is simpler: There is always one compilation unit,
with a fixed order, and at the moment `cli_hx_download.c` is including
OpenSSL first, then wincrypt, and in this order they don't bother each
other. Also, at the moment `lib758.c` is the only other OpenSSL header
user, but it's compiled after `cli_hx_download.c` so the include is
skipped there. We may need to revisit this if either header gets
included before it.

All this said it'd be nice if BoringSSL/AWS-LC restored the built-in
workaround to behave like LibreSSL and OpenSSL and not require local
workarounds like these.

Ref: https://github.com/curl/curl/pull/20556#issuecomment-3888425644

Follow-up to 4c46c829f5 #9110
Follow-up to fbe07c6829 #5669 #5857

Closes #20567
2026-02-12 14:31:39 +01:00
Daniel Stenberg
208b2e8975
RELEASE-NOTES: synced 2026-02-12 09:25:50 +01:00