Commit Graph

35528 Commits

Author SHA1 Message Date
Viktor Szakats
05263820e5
memdebug.h: eliminate global macro CURL_MT_LOGFNAME_BUFSIZE
It had a single use in `src/tool_main.c`. Replace with a literal and
`sizeof()`s.

Follow-up to aaab5fa299
Cherry-picked from #17827
Closes #17833
2025-07-06 20:08:58 +02:00
Viktor Szakats
26f3ee25a4
ws: drop redundant CURL_EXTERN from function definitions
Cherry-picked from #17827
Closes #17832
2025-07-06 20:08:58 +02:00
Viktor Szakats
9e17d281bf
curl_memory.h: fix to undefine accept4
Follow-up to 3d02872be7 #16979
Cherry-picked from #17827
Closes #17831
2025-07-06 20:08:58 +02:00
Viktor Szakats
cbf261e2de
rustls: apply memory function overrides, fixing an ECH buffer free
Fixing:

- a raw `free()` in ECH code that's malloced in lib code, causing
  an invalid free, also reported by valgrind (in non-unity builds).

  And in unity builds adjusted to behave like non-unity via #17827:
  Ref: https://github.com/curl/curl/actions/runs/16093372427/job/45421778472?pr=17827#step:39:3321

- a local pair of `malloc()`/`free()` to use curl's memory allocators,
  and participate in memory tracking when enabled.

Cherry-picked from #17827
Closes #17830
2025-07-06 20:08:58 +02:00
Viktor Szakats
822e47cdce
memdebug.h: #undef fclose before defining it
Just in case, and to match the pattern used for similar redefines.

Cherry-picked from #17827
2025-07-06 19:58:04 +02:00
Viktor Szakats
ed3a482cd1
memdebug.h: fix whitespace/indentation
Cherry-picked from #17827
2025-07-06 19:57:22 +02:00
Daniel Stenberg
beb64e6f3f
tests: make all names < 75 characters long
- no need to make them long and complicated
- increases the chances of them looking better in terminal outputs

Closes #17824
2025-07-06 10:56:08 +02:00
Daniel Stenberg
9b61f81149
tests/http/requirements: remove multipart
This is not actually used.

Reported-by: defnull
URL: https://chaos.social/@defnull/114801392456999379

Closes #17825
2025-07-05 18:13:29 +02:00
Patrick Monnerat
a1449aa704
os400: upgrade ILE/RPG bindings with latest definitions.
Closes #17822
2025-07-05 11:59:42 +02:00
Viktor Szakats
e54c80b397
cmake: curl_add_clang_tidy_test_target tidy-ups
- simplify gathering header directories and compiler definitions
  recursively.

- handle the case when the cmake directory object doesn't define header
  directories or compiler definitions.

- honor more corners cases:
  - `INTERFACE_INCLUDE_DIRECTORIES` of the initial target.
  - handle no header directory for initial target.

- de-duplicate header directories and compiler redefinitions to mimic
  CMake.

- drop unnecessary `unset()`s.

Note that the order of header directories remains different compared to
how CMake passes them to the compiler when building tests. The order is
already different in the test target `INCLUDE_DIRECTORIES` property,
preventing to reproduce the exact CMake order. The distinction between
`-I` and `-isystem` is also missing from target properties.

Cherry-picked from #17768

Closes #17814
2025-07-05 00:40:32 +02:00
Viktor Szakats
5af2457848
lib: fix unused parameter/function compiler warnings
- hostip: fix unused variable with `CURL_DISABLE_SHUFFLE_DNS`
  ```
  lib/hostip.c: In function 'Curl_dnscache_mk_entry':
  lib/hostip.c:490:42: warning: unused parameter 'data' [-Wunused-parameter]
    490 | Curl_dnscache_mk_entry(struct Curl_easy *data,
        |                        ~~~~~~~~~~~~~~~~~~^~~~
  ```

- setopt: fix unused function with `CURL_DISABLE_HTTP`
  ```
  lib/setopt.c:214:17: warning: 'httpauth' defined but not used [-Wunused-function]
    214 | static CURLcode httpauth(struct Curl_easy *data, bool proxy,
        |                 ^~~~~~~~
  ```

- url: fix unused function with `CURL_DISABLE_NETRC`
  ```
  lib/url.c:2760:13: warning: 'str_has_ctrl' defined but not used [-Wunused-function]
   2760 | static bool str_has_ctrl(const char *input)
        |             ^~~~~~~~~~~~
  ```

Seen with a minimal curl-for-win build:
```
CW_CONFIG=dev-x64-zero-osnotls-osnoidn-nohttp-nocurltool-linux-unity
```

Closes #17818
2025-07-04 16:46:53 +02:00
Daniel Stenberg
7e2bdd8662
RELEASE-NOTES: synced 2025-07-04 12:58:03 +02:00
Stefan Eissing
d9c2d4bc10
docs: warn about lifetime in CURLOPT_CLOSESOCKET*
Callback and data set via CURLOPT_CLOSESOCKETFUNCTION and
CURLOPT_CLOSESOCKETDATA may get used after the easy handle has been
cleaned up. Inform about that.

Closes #17816
2025-07-04 12:55:26 +02:00
Daniel Stenberg
bed49a0462
test1499: verify two chunked responses on reused connection
It triggered a memory leak back in 7.88.1

Closes #17815
2025-07-04 11:23:25 +02:00
Piotr Nakraszewicz
e022da0e83
openssl: fix pkcs11 provider available check
Commit f2ce6c46 among other things added the use of own library context
instead of the default context. Default context has access to OpenSSL
configuration file, own context doesn't have it.
Therefore if a pkcs11 provider is loaded via config file, the function
OSSL_PROVIDER_available() incorrectly detects the provider as
unavailable.

Fix this by loading the OpenSSL config to the library context according
to OpenSSL documentation:
"OSSL_LIB_CTX_load_config() loads a configuration file using the given
ctx. This can be used to associate a library context with providers that
are loaded from a configuration."

Moreover use the provider_loaded flag instead of provider pointer to
determine if a provider is available, as the latter is not set when the
provider is loaded from a configuration.

Closes #17804
2025-07-04 08:28:46 +02:00
Viktor Szakats
42fdc65a98
cmake: fix curl_add_clang_tidy_test_target when no -D option
Fix `curl_add_clang_tidy_test_target` generating an invalid option for
`clang-tidy` if the tested target has no custom macro definition.

Current build doesn't hit this case, but a pending PR does.

Fixing:
```
[...] -Ilib -Itests/client -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -D_definitions_t-NOTFOUND
```
error: ISO C99 requires whitespace after the macro name [clang-diagnostic-c99-extensions,-warnings-as-errors]

Cherry-picked from #17768
Closes #17813
2025-07-04 06:28:40 +02:00
Viktor Szakats
b2c9e5ea10
cmake: gather options recursively in curl_add_clang_tidy_test_target
Also look into `INTERFACE_INCLUDE_DIRECTORIES` target properties
for include directories.

Ref: #16973

Closes #17812
2025-07-04 05:57:33 +02:00
Viktor Szakats
5fb10b5476
tool1621: drop unused internal libcurl headers
Closes #17811
2025-07-04 05:48:30 +02:00
Viktor Szakats
7ad985cad5
tests/unit: hook up unitprotos to the units-clang-tidy target
To make `ninja units-clang-tidy` target work without manually building
core components first.

Also rename the clang-tidy test target generator macro to align its name
with the built-in `add_custom_target()` function.

Follow-up to c9bb9cd165 #17750

Closes #17810
2025-07-03 23:49:25 +02:00
Viktor Szakats
a88907fd96
cmake/FindGSS: initialize result variables
Also rename `_GSS*` local variables to `_gss*` to please `clang-lint`,
which emitted new warnings after adding the initializations.

Ref: https://github.com/curl/curl/issues/17802#issuecomment-3029455984

Closes #17806
2025-07-03 17:51:51 +02:00
Viktor Szakats
24c91d999e
cmake/FindGSS: fix processing C header path options
When processing `--cflags` received from `krb5-config` for `gssapi`:

- fix to not break on multiple `-I` options. Before this patch only
  the first `-I` option was processed as a header directory, subsequent
  ones ended up in C flags as a raw directory, without the `-I` arg.
  Follow-up to 558814e16d

- fix to not duplicate C flags.
  Regression from 146759716c #14430

- drop local variable `_val` by re-using `_flag`.

- tidy up comments.

Ref: https://github.com/curl/curl/issues/17802#issuecomment-3029455984

Closes #17805
2025-07-03 13:50:20 +02:00
Dan Fandrich
ab667c73a4 CI: skip CI builds that just touch Dockerfile
This file sees regular updates but isn't used by any CI build.
2025-07-02 18:28:24 -07:00
Jay Satiro
cd9d791651 CURLSHOPT_SHARE.md: mention multi-threading requires callbacks
- Explain that if data is shared in multiple threads then the user must
  set mutex callbacks.

Reported-by: afengsoft@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/17774
Closes https://github.com/curl/curl/pull/17782
2025-07-02 11:11:25 -04:00
Daniel Stenberg
dc263e15e1
VULN-DISCLOSURE-POLICY: minor language polish
Closes #17799
2025-07-01 22:54:43 +02:00
Ameda Amahru
84ac0c2cb4
docs: fix two typos
Closes #17795
2025-07-01 22:53:04 +02:00
Marcel Lang
10432ffb6a
VULN-DISCLOSURE-POLICY.md: fix typos
Closes #17796
2025-07-01 22:50:45 +02:00
Viktor Szakats
dc28bb86c1
appveyor: drop VS2008 CI job, move OpenSSL 1.0.2 to VS2010
It became flaky today, possible due to an upstream issue. Drop this CI job
also because VS2008 is going to be deprecated soon.

Example:
```
1>------ Build started: Project: curlu, Configuration: Debug Win32 ------
1>Compiling...
1>Project : error PRJ0003 : Error spawning 'cl.exe'.
1>Build log was saved at "file://c:\projects\curl\_bld\lib\curlu.dir\Debug\BuildLog.htm"
1>curlu - 1 error(s), 0 warning(s)
[...]
8>Linking...
8>LINK : fatal error LNK1104: cannot open file '..\..\lib\Debug\curlu-d.lib'
8>Build log was saved at "file://c:\projects\curl\_bld\tests\unit\units.dir\Debug\BuildLog.htm"
8>Test units - 1 error(s), 0 warning(s)
[...]
========== Build: 7 succeeded, 2 failed, 5 up-to-date, 0 skipped ==========
[...]
Command exited with code 1
```

Other times with no visible error all:
```
========== Build: 9 succeeded, 0 failed, 5 up-to-date, 0 skipped ==========
[...]
Command exited with code 1
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/52330703/job/ooqxq0b8ftbsv640#L413

Follow-up to 8c9a9b87c2 #17725
Follow-up to 63e513b106 #17380

Closes #17798
2025-07-01 19:47:01 +02:00
renovate[bot]
412a370ab6
Dockerfile: update debian:bookworm-slim Docker digest to 6ac2c08
Closes #17788
2025-07-01 18:56:28 +02:00
Viktor Szakats
31a7905ce1
easygetopt: fix curl logo in header comment
Closes #17793
2025-07-01 13:47:59 +02:00
Daniel Stenberg
b2ca61a0ac
curlinfo: provide the 'digest' feature
... since the tests check for the feature using this name, we
accidentally had lots tests not run because this provided the
`digest-auth` feature that was not checked for.

Closes #17786
2025-07-01 09:53:15 +02:00
Viktor Szakats
73840836a5
tests: move GSS-API dynamic stub into debug-mode libcurl
Replace the `libstubgss.so`-based overload solution with one built into
libcurl at compile-time.

The previous, `LD_PRELOAD`-based, solution was non-portable, allowlisted
for Linux, BSD and Solaris. It also required non-debug builds, which
turned out to be an accidental condition:
7d342c723c. It also required a curl tool
built against a shared libcurl. Detecting this condition wasn't always
accurate, e.g. with certain cmake configurations.

The overload solution also didn't work on macOS, though it theoretically
should have:
- #17653
- #2394

Experiments on making the overload solution work in more envs:
- #17759
  That revealed that it also did not work on NetBSD, in CI.

The replacement solution is overloading the necessary GSS-API functions
for test 2056 and 2057 at compile time. It requires a debug-enabled curl
build (due to its insecure nature).

This makes these tests run on all platforms. Including most GSS jobs in
CI, that are running tests. (the exception is old-linux, non-debug jobs,
where it felt overkill to enable debug for this.)

The refactored GSS stub code needs to overload less than before because
it's free to use the official GSS API. (This didn't work with
the overload solution on Alpine for example). It can also use libcurl
functions, allowing to replace `snprintf()` with `msnprintf()`.

OS/400 is also overloading GSS API functions. I haven't tested how this
works after this PR. In theory it should, because this PR doesn't rely
on preprocessor overrides.

Note that for future GSS tests, it may be necessary to stub these GSS
API functions: `gss_inquire_context()`, `gss_unwrap()`, `gss_wrap()`.
They are on codepaths not (yet) touched by tests.

Also:
- stub-gss: check for token buffer overrun.
- stub-gss: replace size macros with `sizeof()`.
- GHA: enable debug for some jobs with GSS.
- GHA/linux: ignore results for 2056 and 2057 in the valgrind job.
  They leak the same way as seen with 2077 and 2078.
  Ref: 7020ba7979 #17462
  Ref: 146759716c #14430
- GHA/linux: fix to ignore `gss_import_name()` leaks in valgrind builds.
  only.
- lib/vauth/krb5_gssapi: reduce variable scope.
- lib/vauth/spnego_gssapi: reduce variable scope.
- tests/libtest: drop code and build logic dealing with `libstubgss`.
- runtests:
  - drop `ld_preload` feature.
  - drop special handling of `LD_PRELOAD` env in tests.
  - drop logic dealing with shared curl tool detection.
  - drop `LD_PRELOAD` envs from tests.

Follow-up to 56d949d31a #1687

Closes #17752
2025-07-01 00:17:15 +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
Viktor Szakats
48d3407d7c
GHA: fix zizmor 1.10.0 warnings, update names
Job `name:` now mandatory in zizmor.

Also:
- enclose `name:` values in single-quotes, for uniformity.
- drop `name: checkout` where set, for uniformity.
- dist: also install with cmake.
- dist: replace `make` with `cmake --build` for cmake.
  (to make this make-tool agnostic)
- appveyor-status: double-quote shell arguments.
- tweak existing names to be shorter, to sync terms and style across
  jobs and steps.

Ref: https://github.com/zizmorcore/zizmor/releases/tag/v1.10.0

Closes #17773
2025-06-30 18:38:56 +02:00
Viktor Szakats
a3787f98ac
lib: drop two interim macros in favor of native libcurl API calls
Drop `strcasecompare` and `strncasecompare` in favor of libcurl API
calls `curl_strequal` and `curl_strnequal` respectively.

Also drop unnecessary `strcase.h` includes. Include `curl/curl.h`
instead where it wasn't included before.

Closes #17772
2025-06-30 18:38:56 +02:00
Fabrício Canedo
d553f7e9f0
docs/CONTRIBUTE: fix broken link
Add the missing "docs" directory in the link.

Closes #17780
2025-06-30 13:47:06 +02:00
Stefan Eissing
a29133e909
multi: remove careful bounds check as coverity says it is not needed
And we all hope that future code changes will not make it necessary
again or this will all be blamed on you, coverity!

Closes #17784
2025-06-30 13:46:06 +02:00
Stefan Eissing
21ecc7e376
cf-socket: make socket data_pending a nop
Eliminating the socket readability check in the socket connection
filters for the 'data_pending' callback. Improves performance of
handling of transfers, up to ~30%, depending on parallelism and response
size.

Whatever `data_pending()` once was, its semantics are now:
"Is there anything buffered in the connection filters that needs
 receive?"
Any checks of the socket's readability are done via `multi_wait()`
and friends.

Fix the one place in HTTP/1 proxy code that checked `data_pending()` and
did an early return if false. Remove that check and actually try to
receive data every time.

Closes #17785
2025-06-30 13:44:24 +02:00
Daniel Stenberg
a487a4e4bd
RELEASE-NOTES: synced 2025-06-29 17:02:37 +02:00
Daniel Stenberg
a3272c526c
GHA: make the spacecheck say line number for trailing space errors
As it can be quite confusing and frustrating without it.

Closes #17777
2025-06-29 16:43:41 +02:00
Daniel Stenberg
ff15eef2d6
VULN-DISCLOSURE-POLICY: all reports should be disclosed
As a matter of policy.

Closes #17778
2025-06-29 16:42:03 +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
d2a408587a
cmake: fix generator expression in docs/examples
To pass the MSVC-specific macro to MSVC only.

Closes #17767
2025-06-28 02:00:09 +02: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
081e78b023
lib: replace scache no-op macros with #ifdef
To avoid warning/error in no-SSL, non-unity builds:
```
lib/multi.c:273:5: error: code will never be executed [-Werror,-Wunreachable-code]
273 |     goto error;
    |     ^~~~~~~~~~
```

Reported-by: Marcel Raad
Fixes #17754
Closes #17760
2025-06-27 17:33:34 +02:00
Viktor Szakats
3f36e1e502
lib2082: drop typedef struct
To not need the checksrc exception `disable TYPEDEFSTRUCT`.

Follow-up to a517378de5 #7477

Closes #17763
2025-06-27 14:16:30 +02:00
Viktor Szakats
344ccb077c
tests/libtest: drop a checksrc exception
Follow-up to a0a1df5af9 #17414

Closes #17762
2025-06-27 14:16:21 +02:00
Stefan Eissing
d4983ffc13
bufq: change read/write signatures
Change the signature of `bufq` functions from

* `ssize_t Curl_bufq_*(..., CURLcode *err)` to
* `CURLcode Curl_bufq_*(..., size_t *pn)`

This allows us to write slightly less code and avoids the ssize_t/size_t
conversions in many cases. Also, it gets the function in line with all
the other send/recv signatures.

Added helper functions in `cfilters.h` for sending from/receving into
a bufq.

Fuzzer now fails to build due to these changes and its testing of
the bufq API.

Closes #17396
2025-06-27 14:16:21 +02:00
Daniel Gustafsson
86eb054286 VULN-DISCLOSURE-POLICY: exclude not installed software
Flaws in any script or compiled artifact which isn't installed by
default is not considered to be security vulnerabilities.

Closes #17761
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2025-06-27 12:08:01 +02:00
Viktor Szakats
cf8c0e9cbd
curl-config: fix whitespace in usage text
Closes #17758
2025-06-27 01:03:08 +02:00
Viktor Szakats
7b0b03c057
runtests: fix LD_PRELOAD detection for cmake-built curl binaries
CMake builds by default don't include a triplet in the `curl -V` output,
but a CMake-specific OS string, which is usually capitalized or stylized,
e.g. "Linux", or "FreeBSD". Make the regexp expression case-insensitive
to handle this.

Follow-up to 171b623759 #17653

Closes #17756
2025-06-27 00:24:13 +02:00