Commit Graph

35949 Commits

Author SHA1 Message Date
Viktor Szakats
d36f164e61
autotools: use CURLDEBUG to exclude TrackMemory code from unity
Before this patch, autotools builds excluded TrackMemory sources
(`lib/memdebug.c` and `lib/curl_multibyte.c`) based on the `DEBUGBUILD`
setting. This works in most cases because its value is the same as
`CURLDEBUG` by default, but the correct condition is `CURLDEBUG`.

It should fix `--disable-debug --enable-curldebug --enable-unity`
builds. (not tested in CI)

It also syncs behavior with cmake builds.

Ref: #16705
Closes #16723
2025-03-14 13:27:46 +01:00
Viktor Szakats
a16485a42e
build: do not apply curl debug macros to tests/server by default
It seems unnecessary and possibly unexpected to build test servers with
debug-enabled features and memory tracking whenever the tested curl is
built like that (which is a requirement for some tests, so curl is
mostly built like that when running tests.) It also makes building
servers a little bit faster with cmake for the most common cases.

You can apply debug options to `tests/server` with these new options:
- `./configure`: `--enable-server-debug`.
- cmake: `-DENABLE_SERVER_DEBUG`.

Also sync the way we pass these macros in autotools, with CMake builds.
Before this patch, autotools passed them via `curl_config.h`. After this
patch it passes them on the command-line, like cmake builds do.

This patch also make these option no longer passed to examples and
`http/client` in cmake builds, where they were no-ops anyway.

Ref: #15000
Closes #16705
2025-03-14 12:59:32 +01:00
Viktor Szakats
43b2884655
tests/server: give global path variable a more descriptive name
Use a more descriptive global variable name in server code, also
to avoid colliding with this name used elsewhere in libcurl.

This isn't causing an issue at this time, but makes the code prone
to `-Wshadow` warnings in unity mode, if the global variable is
compiled first. This specific variable could collide with the `path`
argument of the `curlx_win32_stat()` function.

Closes #16719
2025-03-14 12:04:39 +01:00
Calvin Ruocco
3588df9478
ws: fix and extend CURLWS_CONT handling
Follow-up to fa3d1e7d43

Add test 2311 to verify

Closes #16687
2025-03-14 11:46:36 +01:00
Viktor Szakats
c799f608f2
autotools: fix dllmain.c in unity builds
Sync it with cmake to:
- exclude it from all builds except Windows and Cygwin.
- exclude it from unity builds for Cygwin to avoid the included
  `windows.h` header interfere with the rest of the code.

Also:
- fix to trim ending spaces from `CSOURCES` for the `tidy` target.
  The solution requires a non-POSIX `-E` `sed` option. Supported by BSD
  and GNU implementations.
  Follow-up to 37523c91bc #16480

Follow-up to 60c3d04465 #14815
Follow-up to 7860f575fe #12408

Closes #16712
2025-03-14 10:38:28 +01:00
Viktor Szakats
63cf464793
tests/server: drop unused base64.pl
When committed in 2004, it served as a developer helper tool while
`coreutils` was yet missing a `base64` command.

Assisted-by: Dan Fandrich
Closes #16713
2025-03-14 10:00:06 +01:00
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