Commit Graph

34793 Commits

Author SHA1 Message Date
Daniel Stenberg
af6ec8e430
RELEASE-NOTES: synced 2025-03-14 09:37:26 +01:00
Daniel Stenberg
116f490c81
rustls: cap maximum allowed CRL file size to 8MB
Allowing 4GB on a 32-bit system is just asking for problems and could in
theory cause integer overflow in the dynbuf code.

The dynbuf now has an assert to catch code trying to set a max larger
than half SIZE_T_MAX.

Reported-by: Rinku Das
Closes #16716
2025-03-14 09:11:36 +01:00
Daniel Stenberg
27e07b2943
doh: remove wrong but unreachable exit path from doh_decode_rdata_name
The condition could not happen, as the function is only called from a
single place where the caller already made sure it can't happen. This
change still removes the flawed logic.

Reported-by: Ronald Crane

Closes #16710
2025-03-14 09:09:25 +01:00
Daniel Stenberg
acdb48272a
tool_setopt: reduce use of "code hiding" macros
CODEx, DATAx, CLEANx, DECLx, REM3, CHKRET are all removed now.

Closes #16709
2025-03-13 17:25:33 +01:00
Daniel Stenberg
212f9a9742
tool_setopt: simplify tool_setopt
Since this is only used for object and function pointers now.

Closes #16709
2025-03-13 17:25:33 +01:00
Viktor Szakats
67a7775d12
GHA/windows: replace OpenSSH-Windows-Prelease job with standard openssh
After restricting OpenSSH-Windows to a single job, and bumping it to
the pre-release version, that job started hanging then timing out with
reasonable consistency.

Since we saw similar hangs before with OpenSSH-Windows stable, in all
jobs, drop OpenSSH-Windows from CI, and replace it with MSYS openssh.

After this patch, all Windows jobs use MSYS2 or Cygwin openssh.

Follow-up to 0ec72c1ef8 #16672
Closes #16704
2025-03-13 16:47:02 +01:00
Viktor Szakats
d4f9788593
GHA: fix configure disable options
Linux AM openssl https-only:
```
configure: WARNING: unrecognized options: --disable-rtmp, --disable-scp, --disable-sftp
```
Ref: https://github.com/curl/curl/actions/runs/13823209634/job/38673119106#step:31:34

macOS AM clang !ssl HTTP-only:
```
configure: WARNING: unrecognized options: --disable-rtmp, --disable-scp, --disable-sftp, --without-ntlm-auth
```
Ref: https://github.com/curl/curl/actions/runs/13823209638/job/38673115560#step:7:54

Closes #16701
2025-03-13 11:37:30 +01:00
Viktor Szakats
b70357c5f3
resolve: fix building without Unix sockets and CURLDEBUG
```
In file included from server_bundle.c:7:
../../../tests/server/resolve.c:110:5: error: unknown type name 'curl_socket_t'; did you mean 'curl_socklen_t'?
    curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
    ^~~~~~~~~~~~~
    curl_socklen_t
../../../include/curl/system.h:392:38: note: 'curl_socklen_t' declared here
  typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
                                     ^
In file included from server_bundle.c:7:
../../../tests/server/resolve.c:111:13: error: use of undeclared identifier 'CURL_SOCKET_BAD'
    if(s == CURL_SOCKET_BAD)
            ^
```
Ref: https://github.com/curl/curl/actions/runs/13825438937/job/38679418428?pr=15000#step:14:47

Cherry-picked from #15000
Closes #16700
2025-03-13 11:36:54 +01:00
Viktor Szakats
533ba0089b
tests/server: sync memory callbacks with lib/easy.c
Cherry-picked from #15000
Closes #16699
2025-03-13 11:36:53 +01:00
Viktor Szakats
2283e40fc3
tests/server: do not redefine standard functions in sockfilt
Use a namespaced macro instead. To avoid confusion when other headers
also redefine these functions. And to improve readability by making it
apparent that the code sometimes overrides these functions.

Cherry-picked from #15000
Closes #16698
2025-03-13 11:36:53 +01:00
Viktor Szakats
91d061725e
tests/server: drop unused headers
Cherry-picked from #15000
Closes #16697
2025-03-13 11:36:53 +01:00
Viktor Szakats
44d4957a6f
memdebug.h: avoid -Wredundant-decls with an extra guard
Add an extra guard for the function and variable declarations to avoid
redundant redeclaration warnings when including this header multiple
times. This can happen in unity builds when including it again after
`curl_memory.h`.

Fixes:
```
bld/tests/server/CMakeFiles/servers.dir/Unity/unity_0_c.c
In file included from lib/mprintf.c:32,
                 from bld/tests/server/CMakeFiles/servers.dir/Unity/unity_0_c.c:7:
lib/memdebug.h:52:14: error: redundant redeclaration of ‘curl_dbg_logfile’ [-Werror=redundant-decls]
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
In file included from tests/server/resolve.c:50,
                 from bld/tests/server/server_bundle.c:7,
                 from bld/tests/server/CMakeFiles/servers.dir/Unity/unity_0_c.c:4:
lib/memdebug.h:52:14: note: previous declaration of ‘curl_dbg_logfile’ with type ‘FILE *’
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
[...]
lib/memdebug.h:110:17: error: redundant redeclaration of ‘curl_dbg_fclose’ [-Werror=redundant-decls]
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
lib/memdebug.h:110:17: note: previous declaration of ‘curl_dbg_fclose’ with type ‘int(FILE *, int,  const char *)’
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/13822010778/job/38669360980#step:39:55

Cherry-picked from #15000
Closes #16696
2025-03-13 11:36:53 +01:00
Viktor Szakats
77401af485
cmake: unity mode optimization for non-CURLDEBUG testdeps targets
Include more sources in unity mode to optimize libtest and tests/server
builds for non-debug-enabled builds, syncing this pattern with `lib` and
`src`.

It reduces build steps from 62 to 47 (-14, -24%) with test bundles.
Without test bundles, from 680 to 642 (-38, -6%).

Follow-up to de0693f249 #16274
Follow-up to 3efba94f77 #14765
Cherry-picked from #15000
Closes #16695
2025-03-13 11:36:53 +01:00
Daniel Stenberg
5a26b901d4
cookie: accept "high byte" cookie content
Regression from 597ee915c4 (not shipped in a release)
Reported-by: Carlos Henrique Lima Melara
Assisted-by: Scott Talbert

Added such a cookie to test 31.

Fixes #16692
Closes #16703
2025-03-13 08:46:58 +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 abf80aae38 #16612
Follow-up to d69425ed7d #16615
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377

Closes #16621
2025-03-13 00:03:25 +01:00
Viktor Szakats
c0a70c564d
base64: drop BUILDING_CURL macro, always include in tests/server
Before this patch, building tests/server (or curl with winbuild) was
broken in rare builds when many features were explicitly disabled.

Fix it by enabling base64 functions unconditionally when building
for anything other than libcurl.

Closes #16691
2025-03-13 00:03:15 +01:00
Viktor Szakats
07f984a776
ntlm: merge ntlm.h into ntlm.c
It's the only user since dropping NTLM_WB support.

Follow-up to 50def7c881 #13249

Closes #16690
2025-03-13 00:03:15 +01:00
Viktor Szakats
ee73d553ed
build: replace Curl_ prefix with curlx_ for functions used in servers
Closes #16689
2025-03-13 00:03:15 +01:00
Daniel Stenberg
45ce0847f3
runtests: enable the --libcurl feature by default
Follow-up to a14eb26a58
Reported-by: Viktor Szakats
Fixes #16693
Closes #16694
2025-03-12 23:41:40 +01:00
Daniel Stenberg
0bb8465b1e
multi: call protocol handler done() if PROTOCONNECT or later
The protocol handlers' done() function would previous get called
unconditionally in multi_done(), no matter how far the easy handle's
state machine has transitioned.

This caused problems in IMAP which in imap_connect() initializes things
that the imap_done() function assumes has occured. I think that seems
like a correct assumption and we should rather make sure that the done()
function is only called if we have reached the PROTOCONNECT state.

This problem was found using OSS-Fuzz.

Assisted-by: Catena cyber

Closes #16681
2025-03-12 23:16:46 +01:00
Stefan Eissing
886569e2db
curl: fix --cert parameter clearing
Blank the argument *after* it has been copied.

Reported-by: Jan Macku
Fixes #16686
Closes #16688
2025-03-12 23:15:14 +01:00
Daniel Stenberg
5273ab4e6d
GHA: do a build-only without the --libcurl option enabled
Closes #16682
2025-03-12 15:23:25 +01:00
Daniel Stenberg
a14eb26a58
tests: make --libcurl tests require the --libcurl feature
Closes #16682
2025-03-12 15:23:20 +01:00
Daniel Stenberg
af3fe375b3
src: remove final uses of Curl_ symbol prefixes in tool code
Closes #16678
2025-03-12 14:37:08 +01:00
Daniel Stenberg
67a1cfa5ef
managen: accept more markdown-quote-markers
Lines starting with ``` or ~~~ indicate start and end of a quoted
section.

Closes #16685
2025-03-12 14:36:11 +01:00
Stefan Eissing
3c9a1d3fcf
sendf: client reader line conversion: do not change data->state.infilesize
The line conversion reader, added in crfl and prefer_ascii mode was
incrementing data->state.infilesize for every line end converted. This
results in the wrong size to start a retry of an upload.

Eliminate the increment and check upload size in FTP less precise when
conversions are done.

Bug: https://issues.oss-fuzz.com/issues/402476456

Closes #16683
2025-03-12 14:33:28 +01:00
Daniel Stenberg
fdd97148e8
tool_operate: fix build with --libcurl support disabled
A compiler warning for unused argument.

Reported-by: Marcel Raad

Closes #16684
2025-03-12 13:12:23 +01:00
Viktor Szakats
0ec72c1ef8
GHA/windows: change openssh server, non-debug-enabled MSVC job, other improvements
MSVC:

- switch jobs to standard openssh server. Reduce exceptions.
- make the SCP/SFTP ignore list more specific and comment with details.
- keep using OpenSSH-Windows for the OpenSSL job, and bump to the
  prerelease version.
- disable `ENABLE_DEBUG` for BoringSSL to have such build tested. (This
  is the first Windows non-ENABLE_DEBUG build with test runs.)

Takeaways:

- test 612 broken on Windows.
- test 613 broken on Windows with the standard openssh server.
- test 614 broken with libssh and OpenSSH-Windows.
- test 3022 broken with libssh2 and OpenSSH-Windows.
- tests broken with OpenSSH-Windows:
  601 603 617 619 621 641 665 2004.
- vcpkg `libssh2[core,zlib]` broken due to:
  curl: (67) Authentication failure

MSVC prep steps:

- install base msys2 package to simplify configuration, align with other
  jobs and allow to use msys2 packages for tests.
- add support for msys2 openssh server. Keep OpenSSH-Windows as per-job
  option. Add support for OpenSSH prerelease versions.
  Prerelease does not make a difference in test results, but, stable was
  last updated in 2019 (v8.0.0.1) and it seems better to use maintained
  release track, with its latest from April 2024 (v9.5.0).
  https://community.chocolatey.org/packages/openssh/8.0.0.1
  https://community.chocolatey.org/packages/openssh
  https://github.com/PowerShell/Win32-OpenSSH
  https://github.com/PowerShell/openssh-portable
- add 'libssh' to its job name.
- make `ENABLE_DEBUG` a per-job option.

msys/mingw:

- install `openssh` later and only when necessary.
- downgrade msys2 runtime later. (to follow other jobs)
- disable `CheckSpace` earlier. Also to untie it from the runtime
  downgrade step, which we would hopefully drop.

Closes #16672
2025-03-12 12:44:42 +01:00
Viktor Szakats
436d4a360a
curltime: use libcurl time functions in src and tests/server
The curl tool and tests/server used 2 parallel implementations
of libcurl's `Curl_now()` and `Curl_timediff()` functions.

Make them use the libcurl one.

Closes #16653
2025-03-12 11:33:26 +01:00
Daniel Stenberg
b1faac8039
multi: kill off remaining internal handles in curl_multi_cleanup
- if there are pending internal handles left in the list, they are
  leftovers (from for example Doh) and must be freed.

- unlink_all_msgsent_handles() did not properly move all msgsent
  handles over to the process list as intended

Fixes a DoH memory leak found by oss-fuzz.

Add test 2101 that can reproduce and verify.

Closes #16674
2025-03-12 09:22:32 +01:00
Viktor Szakats
41a15c8e74
curl_setup: drop ERANGE (for WinCE), no longer used
Follow-up to 29ed1f9834 #16671

Closes #16673
2025-03-11 18:31:00 +01:00
Viktor Szakats
29ed1f9834
tests/server: use curlx_str_numblanks() to avoid errno
Replacing `strtoul()` calls and glue code.

Closes #16671
2025-03-11 16:06:33 +01:00
Daniel Stenberg
60b52c0c8b
RELEASE-NOTES: synced 2025-03-11 16:02:18 +01:00
Daniel Stenberg
dc12ecd5db
curl: add my_setopt_long() and _offt()
Two new dedicated functions for setting long and curl_off_t options with
curl_easy_setopt(). These make it easier to make sure we pass on the
right option (types) so that the --libcurl code also gets right.

Corrected a few errors.

Closes #16669
2025-03-11 14:58:13 +01:00
Stefan Eissing
763fa529df
wolfssh: fix freeing of resources in disconnect
ssh's disconnect assumed that the session to the server could be
shut down successfully during disconnect. When this failed, e.g.
timed out, memory was leaked.

Closes #16668
2025-03-11 14:56:38 +01:00
Stefan Eissing
9710aec8f8
test489: set output dir
Set output dir to %LOGIDR so that generated files are ignored by git.

Closes #16670
2025-03-11 14:52:40 +01:00
Viktor Szakats
ab2cf88dad
tftpd: prefix TFTP protocol error E* constants with TFTP_
To avoid mistaking them for `errno` error codes.

Closes #16666
2025-03-11 08:50:09 +01:00
Viktor Szakats
51c9238c76
GHA: enable OpenSSL QUIC in a macOS and MinGW job
Closes #16665
2025-03-11 08:50:08 +01:00
Daniel Stenberg
64a79fdd7a
tool_operate: fix a stray Curl_ symbol use 2025-03-11 07:25:12 +01:00
Daniel Stenberg
438dd08b54
src: s/Curl_safefree/curlx_safefree
Towards using curlx_ prefix for all libcurl code that is used in the
tool outside of the "real" API.

Closes #16664
2025-03-11 07:25:01 +01:00
Daniel Stenberg
794e9109d7
curl_memrchr: enable in all builds
It is used in the URL parser since bc24c60512

Reported-by: Justin Steventon
Fixes #16661
Closes #16663
2025-03-10 23:10:31 +01:00
Daniel Stenberg
284ef8a3dc
src: use curlx_dyn_ prefix, not Curl_dyn_
Closes #16658
2025-03-10 22:55:41 +01:00
Daniel Stenberg
8df315d5b3
src: remove Curl_ prefix from tool-specific function
Since that's a prefix we use for library-private functions

Curl_execpath is now tool_execpath

Closes #16657
2025-03-10 22:54:28 +01:00
Stefan Eissing
571e92f730
libssh: fix freeing of resources in disconnect
ssh's disconnect assumed that the session to the server could be shut
down successfully during disconnect. When this failed, e.g. timed out,
memory was leaked.

Closes #16659
2025-03-10 22:53:51 +01:00
Stefan Eissing
0b40db0489
libssh2: fix freeing of resources in disconnect
ssh's disconnect assumed that the session to the server could be shut
down successfully during disconnect. When this failed, e.g. timed out,
memory was leaked.

Closes #16656
2025-03-10 22:52:42 +01:00
Viktor Szakats
f4e23950c7
build: enable -Wcast-qual, fix or silence compiler warnings
The issues found fell into these categories, with the applied fixes:

- const was accidentally stripped.
  Adjust code to not cast or cast with const.

- const/volatile missing from arguments, local variables.
  Constify arguments or variables, adjust/delete casts. Small code
  changes in a few places.

- const must be stripped because an API dependency requires it.
  Strip `const` with `CURL_UNCONST()` macro to silence the warning out
  of our control. These happen at API boundaries. Sometimes they depend
  on dependency version, which this patch handles as necessary. Also
  enable const support for the zlib API, using `ZLIB_CONST`. Supported
  by zlib 1.2.5.2 and newer.

- const must be stripped because a curl API requires it.
  Strip `const` with `CURL_UNCONST()` macro to silence the warning out
  of our immediate control. For example we promise to send a non-const
  argument to a callback, though the data is const internally.

- other cases where we may avoid const stripping by code changes.
  Also silenced with `CURL_UNCONST()`.

- there are 3 places where `CURL_UNCONST()` is cast again to const.
  To silence this type of warning:
  ```
  lib/vquic/curl_osslq.c:1015:29: error: to be safe all intermediate
    pointers in cast from 'unsigned char **' to 'const unsigned char **'
    must be 'const' qualified [-Werror=cast-qual]
  lib/cf-socket.c:734:32: error: to be safe all intermediate pointers in
    cast from 'char **' to 'const char **' must be 'const' qualified
    [-Werror=cast-qual]
  ```
  There may be a better solution, but I couldn't find it.

These cases are handled in separate subcommits, but without further
markup.

If you see a `-Wcast-qual` warning in curl, we appreciate your report
about it.

Closes #16142
2025-03-10 22:30:15 +01:00
Viktor Szakats
8b1b5cd4d2
DISABLED: add 313 for sectransp (move from GHA/macos)
Closes #16660
2025-03-10 20:58:06 +01:00
Viktor Szakats
57218d5327
tidy-up: replace Curl_safefree with free before re-assignment
Also drop `NULL` assignments after `Curl_safefree()`.

Closes #16640
2025-03-10 20:58:05 +01:00
Jay Satiro
9b523773b8 libssh: fix scp large file upload for 32-bit size_t systems
- Use ssh_scp_push_file64 instead of ssh_scp_push_file.

The former uses uint64_t for file size and the latter uses size_t which
may be 32-bit.

Ref: https://github.com/curl/curl/pull/16194

Closes https://github.com/curl/curl/pull/16641
2025-03-10 13:20:19 -04:00
Daniel Stenberg
19d6415273
urlapi: treat 0 alone as decimal number in IPv4 address
Not as a broken octcal. Regression from b4538ec522

Extended test 1560 to verify this behavior.

Reported-by: Carlos Henrique Lima Melara

Closes #16652
2025-03-10 17:10:23 +01:00