Commit Graph

35764 Commits

Author SHA1 Message Date
Viktor Szakats
26326c5297
build: stubgss tidy-ups (in tests)
- cmake: avoid running clang-tidy twice.
- autotools: do not pass curl/libtest-specific macros.

Also:
- autotools: drop `CFLAG_CURL_SYMBOL_HIDING` from libtests.
   Unused since 09437d8cd4 #14695

Closes #17738
2025-06-25 09:57:06 +02:00
Viktor Szakats
f4649425f2
build: fix libcurltool with cmake and tunits, related tidy-ups
Sync how libcurltool is built in different modes and build systems.

cmake:
- build libcurltool with curlx when building shared libcurl.
  To make it possible to use standard libcurl when linking tunits.
  Also syncing this with autotools.
  The remaining difference is that cmake allows to select shared or
  static for curl tool and tests/examples independently.
- fix to link with libcurl instead of libcurlu.
  To sync with autotools and to link with the standard libcurl for
  tool unit tests.
- fix `source_group()` to always include curlx sources.
- add missing 'curlx header files' source group.

autotools:
- build libcurltool without curlx when building static libcurl in
  non-unity builds.
  To avoid double compilation, just to be thrown away at link time.
  Also to sync with unity builds.

both:
- sync source order between autotools and cmake.
- make sure to pass all headers with both autotools and cmake.
  This is a no-op with cmake. Maybe a future patch should make sure
  to not pass those to remove that noise.

Ref: #17696

Closes #17727
2025-06-25 09:57:06 +02:00
Viktor Szakats
1ec0da0149
tests: constify, make consts static
- lib509: constify an input string.
- add `static` to const data, where missing.
- tool1394: fix indentation.

Closes #17736
2025-06-25 09:57:06 +02:00
Viktor Szakats
db512ee267
tests/server: move memory init to memptr.c
To sync with tests/libtest.

Closes #17735
2025-06-25 01:37:56 +02:00
Viktor Szakats
04e90d4814
mk-lib1521: replace printf with curl_mprintf
Ref: #17731

Closes #17732
2025-06-25 01:37:56 +02:00
Stefan Eissing
e80c893254
multi: xfer table/bitset, handle limits
* calculate capacity growth on multi's xfer table and bitsets to
  work correctly when approaching UINT_MAX
* uint-bset: track the first 64bit slot used. This avoids slot scans
  on empty sets.
* uint-tbl: remove restriction to grow ot UINT_MAX, it is multi's
  job to enforce limits suitable for its use
* test751: use curl_mfprintf() for error messages

Closes #17731
2025-06-24 15:02:52 +02:00
Daniel Stenberg
65f8253336
bufq: remove the unused Curl_bufq_unwrite function
Follow-up to 02edae54e8

Closes #17730
2025-06-24 10:56:54 +02:00
Joel Depooter
c153d9eadf
cmake: check USE_WINDOWS_SSPI when adding secur32 to CURL_LIBS
Instead of CURL_WINDOWS_SSPI.

When running CMake on Windows with no additional parameters (ie default
build configuration), the generated project files do not include the
`secur32.lib` library in the linker settings. This is because
the relevant check was looking at `CURL_WINDOWS_SSPI` instead of
`USE_WINDOWS_SSPI`.

`USE_WINDOWS_SSPI` is enabled when building with SChannel (the default
on Windows), or if `CURL_WINDOWS_SSPI` is specified on the command line.

Follow-up to 0d71b18153 #17413

Closes #17728
2025-06-24 09:57:42 +02:00
Viktor Szakats
8c9a9b87c2
appveyor: move old cmake from VS2008 to VS2010
In preparation of dropping the VS2008 job. To keep testing old cmake
(3.12.2) after that.

Closes #17725
2025-06-24 09:44:28 +02:00
Viktor Szakats
3ea0f71ffa
build: stop checking for sys/stat.h
It has been used unconditionally in `src` and `tests` since at least
2011-09-19 via fdecb56cbf. There are
earlier unguarded references in `tests`.

Also de-duplicate to include it just once.

Ref: https://github.com/curl/curl/pull/17717#issuecomment-2996631026

Closes #17724
2025-06-24 09:44:28 +02:00
Viktor Szakats
c4f9487089
tidy-up: replace <memdebug.h> with "memdebug.h" (src, units)
Closes #17722
2025-06-24 09:44:28 +02:00
Daniel Stenberg
c0cb3485fe
unit1302: expand the base64 encode/decode tests
Closes #17726
2025-06-24 07:55:16 +02:00
Viktor Szakats
bb50dee510
tests/server: de-dupe/merge three sockdaemon() clones into one
Also: tidy up `if()` expressions here and there.

Follow-up to f4f25505df #15000

Closes #17719
2025-06-23 17:02:43 +02:00
Viktor Szakats
1a70977a83
build: drop explicit curlx from hdr paths, refer headers with curlx/ prefix
To make all src and test code refer to curlx headers the same way.

Also:
- src: move `curlx.h` include to `tool_setup.h`.
- src/tool_setup.h: drop stray `curlx/timeval.h`.
- servers: de-duplicate `curlx.h` and `curl_setup.h` includes.
- libtests, units: drop stray curlx sub-headers in favor of
  `<curlx/curlx.h>`.
- tests: include `curlx.h` with `<>` instead of `""`. To match
  other parts of the codebase.

Closes #17680
2025-06-23 17:02:43 +02:00
Daniel Stenberg
63011ac638
tests: use %b64[] to base64 data
... instead of storing the data base64 encoded.

Closes #17721
2025-06-23 16:47:14 +02:00
NINIKA
05382f3e78
asyn-ares: remove redundant NULL check
Closes #17720
2025-06-23 16:34:43 +02:00
Viktor Szakats
2636828eee
tests: drop unused or redundant includes
Closes #17717
2025-06-23 13:49:03 +02:00
Daniel Stenberg
36a3cd5374
RELEASE-NOTES: synced 2025-06-23 13:41:12 +02:00
Stefan Eissing
c7a6319698
multi: clear the dirty set of transfers no longer processing
When a transfer is no longer processed, it might still apear in the
dirty bitset. Clear the dirty bit when this condition is encountered.

Closes #17718
2025-06-23 13:36:33 +02:00
Viktor Szakats
6425ce47df
tests/libtest: use curltime from curlx
Replacing the local implementation.

Closes #17716
2025-06-23 11:29:41 +02:00
Viktor Szakats
a2de3f08e3
tests/libtest: call curlx_now_init() for unit 1399, 2600 (Windows)
Follow-up to 35d0c047ce #17641

Closes #17714
2025-06-23 10:55:31 +02:00
Daniel Stenberg
aed828cc51
tests/dnsd: read config from file
Make the <dns> tag in a test case control what is stored there. Also
documented. Make test 2102 and 2103 use the new tag.

Lets the test case config the A and AAAA contents the server replies
with. Initial work for the HTTPS RR exists, but does not yet work.

Closes #17543
2025-06-23 08:24:09 +02:00
Daniel Stenberg
2cdc02f49f
libcurl-env.md: drop LOGNAME, USER and NTLMUSER
They were used for NTLM-WB, which support was removed for back in 8.8.0

Closes #17713
2025-06-23 08:21:05 +02:00
Viktor Szakats
85bf8b19ac
cmake: sync tests scripts with each other and autotools (more)
Closes #17711
2025-06-22 23:42:14 +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
9837dd429a
GHA/windows: drop MSYS2 runtime downgrades
No longer necessary after bumping the default runtime to a version
fixing the previously experienced performance drop.

Thanks to MSYS2/Cygwin teams for the help and fix.

Follow-up to 9a26be1e6a #17708
Follow-up to d4896d94f2 #16424

Closes #17710
2025-06-22 23:08:46 +02:00
renovate[bot]
9a26be1e6a
GHA: update msys2/setup-msys2 digest to 40677d3
After:
MINGW64_NT-10.0-20348 runnervmdy573 3.6.3-1f8def9f.x86_64 2025-06-18 07:19 UTC x86_64 Msys

Before:
MINGW64_NT-10.0-20348 runnervmdy573 3.5.7-2644508f.x86_64 2025-02-06 19:32 UTC x86_64 Msys

Closes #17708
2025-06-22 22:43:15 +02:00
Yedaya Katsman
8128a17e71
rustls: don't try printing the not provided file
Caught by gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0:
```
vtls/rustls.c: In function ‘cr_connect’:
vtls/rustls.c:857:61: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  857 |     failf(data, "rustls: must provide certificate with key '%s'",
      |                                                             ^~
```

Closes #17704
2025-06-22 22:31:11 +02:00
Viktor Szakats
83a8818cfe
h2_serverpush: fix file handle leaks reported by clang-tidy
clang-tidy (20.1.6) found it locally consistently. Missed in CI.

Closes #17706
2025-06-22 21:42:53 +02:00
Viktor Szakats
d1f036c424
cmake: configure c-ares header directory in project root (was: lib)
The c-ares header directory was added to the header path within `lib`,
as opposed to every other dependency which added them in the root
`CMakeLists.txt`. Such exception is no longer necessary. This patch
aligns c-ares header setup with the rest of dependencies. And also with
autotools, which also makes no exception here.

Cherry-picked from #17705
Cherry-picked from #16973

Closes #17707
2025-06-22 21:41:03 +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
Viktor Szakats
4d4d09eb7f
cmake: drop reference to future variable [ci skip]
Follow-up to 855acb3bb0 #17701
2025-06-22 13:19:15 +02:00
Viktor Szakats
855ae76513
tests/libtest: drop TEST_HANG_TIMEOUT redefinition hack
Before this patch the code relied on re-initializing `TEST_HANG_TIMEOUT`
macro before compiling each test, to allow them each to override it to
a custom value for single tests. Thie required re-including `test.h`
into each test.

After this patch this macro becomes a global, immutable, default. Tests
which want to override it can now use alternate macros that do accept
a custom timeout. The only test currently affected is lib1501.

Follow-up to 2c27a67daa #17590

Closes #17702
2025-06-22 13:15:13 +02:00
Viktor Szakats
855acb3bb0
cmake: add target property dumper helper function
It's pretty rough and a giant hack, but helps debugging and findind ways
while navigating the CMake maze. I find it sad CMake doesn't have
a built-in function for this that works correctly in all situations.
It's invaluable to be able to see what properties and values an object
has.

It's also possible there is a better solution to this, but I could not
find it.

Cherry-picked from #16973

Closes #17701
2025-06-22 13:15:13 +02:00
Daniel Stenberg
52f58ebb10
curl_get_line: make sure lines end with newline
Verify with test 792 and 793

Reported-by: z2_
Closes #17697
2025-06-22 12:58:53 +02:00
Viktor Szakats
e29f11f2d6
tests/server: drop memdebug.h
It's no longer used in any build configuration.

Follow-up to fffec3d7e9 #17629

Closes #17700
2025-06-22 09:00:53 +02:00
Daniel Stenberg
bbadbd7795
docs: mention that the netrc file works without port numbers
Closes #17698
2025-06-21 23:46:14 +02:00
Daniel Stenberg
64fe36aaa0
tests/server/util.c: include netinet/in6.h
for sockaddr_in6

Reported-by: Randall S. Becker
Bug: https://curl.se/mail/lib-2025-06/0016.html
Closes #17695
2025-06-21 20:04:14 +02:00
Stefan Eissing
70779199f3
cf: replace the method get_host with query
Connection filters had a method `get_host()` which had not really been
documented. Since then, the cf had the `query()` method added. Replace
the separate get_host with query.

Add `CF_QUERY_HOST_PORT` as query to connection filters to retrieve
which remote hostname and port the filter (or its sub-filter) is talking
to. The query is implemented by HTTP and SOCKS filters, all others pass
it through.

Add `Curl_conn_get_current_host()` to retrieve the remote host and port
for a connection. During connect, this will return the host the
connection is talking to right now. Before/After connect, this will
return `conn->host.name`.

This is used by SASL authentication.

Closes #17419
2025-06-21 17:20:44 +02:00
Stefan Eissing
779937f840
multi: add dirty bitset
Add a bitset `dirty` to the multi handle. The presence of a transfer int
he "dirty" set means: this transfer has something to do ASAP.

"dirty" is set by multiplexing protocols like HTTP/2 and 3 when
encountering response data for another transfer than the current one.
"dirty" is set by protocols that want to be called.

Implementation:

* just an additional `uint_bset` in the multi handle
* `Curl_multi_mark_dirty()` to add a transfer to the dirty set.
* `multi_runsingle()` clears the dirty bit of the transfer at
   start. Without new dirty marks, this empties the set after
   al dirty transfers have been run.
* `multi_timeout()` immediately gives the current time and
   timeout_ms == 0 when dirty transfers are present.
* multi_event: marks all transfers tracked for a socket as dirty.
  Then marks all expired transfers as dirty. Then it runs
  all dirty transfers.

With this mechanism:

* Most uses of `EXPIRE_RUN_NOW` are replaced by `Curl_multi_mark_dirty()`
* `Curl_multi_mark_dirty()` is cheaper than querying if a transfer is
  already dirty or set for timeout. There is no need to check, just do it.
* `data->state.select_bits` is eliminated. We need no longer to
  simulate a poll event to make a transfer run.

Closes #17662
2025-06-21 17:19:11 +02:00
Viktor Szakats
7aa8d1eea1
build: tidy up Makefile.inc use in lib and src
- cmake: use `CURL_RCFILES` instead of literal.
- cmake: use `LIB_RCFILES` instead of literal.
- cmake: fix comments.
- autotools: use `CURL_RCFILES` in `EXTRA_DIST`.
- autotools: use `LIB_RCFILES` in `EXTRA_DIST`.
- autotools: fix comments.
- autotools: fix indentation.

Closes #17694
2025-06-21 11:51:01 +02:00
Daniel Stenberg
97a0ce8f89
RELEASE-NOTES: synced 2025-06-21 11:10:05 +02:00
DoI
9a2663322c
curl: implement non-blocking STDIN read on Windows
Implements a seperate read thread for STDIN on Windows when curl is run
with -T/--upload-file .

This uses a similar technique to the nmap/ncat project, spawning a
seperate thread which creates a loop-back bound socket, sending STDIN
into this socket, and reading from the other end of said TCP socket in a
non-blocking way in the rest of curl.

Fixes #17451
Closes #17572
2025-06-21 11:04:29 +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
Joel Depooter
e3d9675924
libssh: fix incorrect return value in myssh_in_AUTH_PKEY_INIT
In the unlikely case that no SSH auth methods are supported, the
previous code would return 0 from myssh_in_AUTH_PKEY_INIT. However,
following the code path, it seems like it should be returning SSH_ERROR,
as set in myssh_to_ERROR (through myssh_to_GSSAPI_AUTH,
myssh_to_KEY_AUTH and myssh_to_PASSWD_AUTH).

In actuality, this is unlikely to occur, as the similar code in
myssh_in_AUTHLIST would have already returned an error in this scenario.
However setting a return value and then ignoring it is a bit fishy and
should be documented if this is intended.

I believe this used to return an error, but was changed in the recent
re-factoring of this code.

Closes #17691
2025-06-21 10:51:11 +02:00
Viktor Szakats
7d8fa8276d
tests: drop BUNDLE_SRC variable
Derive it from `$BUNDLE` instead. autotools seems to be already relying
on `$BUNDLE_SRC` being equal to `$BUNDLE.c`. (I haven't realized this
before aaebb45f58b3f62876a68c17c71ac37d98f1b3bb.)

Also drop redundant `nodist_<target>_SOURCE` lines in tunits and units.

Follow-up to aaebb45f58 #17688
Follow-up to 2c27a67daa #17590

Closes #17692
2025-06-21 10:49:05 +02:00
Viktor Szakats
ccb65643b6
cmake: omit clang-tidy on internal libs curlu and curltool
Skip clang-tidy while compiling curlu and curltool internal libraries.
To save about 1 minute per run. These libraries compile the lib and src
sources a second time, with the `UNITTESTS` macro enabled, which makes
tiny difference, for internal use. I figure it's not worth the extra CI
(and local) time because finding extra issues in these passes is
unlikely, and if found, not critical.

autotools also doesn't check curlu and curltool with clang-tidy.

Ref: https://github.com/curl/curl/pull/17680#issuecomment-2991730158
Ref: https://stackoverflow.com/questions/61867616/ignore-certain-files-when-using-clang-tidy
Ref: https://cmake.org/cmake/help/latest/prop_tgt/LANG_CLANG_TIDY.html

Follow-up to fabfa8e402 #15825

Closes #17693
2025-06-21 10:43:32 +02:00
Stefan Eissing
b7c676d13f
vtls: change send/recv signatures of tls backends
Similar to connection filter changes, return a CURLcode and the
read/written amount as size_t *.

Closes #17593
2025-06-21 10:34:02 +02:00
Fabrício Canedo
17f8b1db5c
docs: fix broken link in CODE_REVIEW.md
In CODE_REVIEW.md file, the link that points to CONTRIBUTE was broken,
so I fixed this issue changing the link from only "CONTRIBUTE.md" to
"https://curl.se/dev/contribute.html".

Closes #17656
2025-06-21 10:32:06 +02:00
Fabrício Canedo
612c5a8a2e
docs: fix broken link in INSTALL.md
In INSTALL.md file, the link that points to CURL-DISABLE was broken,
so I fixed this issue changing the link from only "CURL-DISABLE.md" to
"https://github.com/curl/curl/blob/master/docs/CURL-DISABLE.md".

Fixes https://github.com/curl/curl-www/issues/427
Closes #17654
2025-06-21 10:29:49 +02:00