Commit Graph

35528 Commits

Author SHA1 Message Date
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
Viktor Szakats
bad5e71331
tidy-up: whitespace, tests/server Makefile.inc, timeval in VS project
- VS projects: drop unused `timediff`.
  (used by curltool library, but this build method doesn't build that.)
- tests/server/sws: reflow an `if` for greppability.
- tests/server/Makefile.inc: indent, format
- tests/server/Makefile.inc: merge `USEFUL` and `UTIL` lists.

Closes #16651
2025-03-10 14:19:49 +01:00
Daniel Stenberg
75acda70aa
hostip: don't use alarm() for DoH resolves
When built to use the synch resolver and DoH is used for a transfer, do
not use alarm() for timeout since DoH resolving is not blocking.

Closes #16649
2025-03-10 13:17:18 +01:00
Daniel Stenberg
3c2948e0a6
lib: clear up CURLRES_ASYNCH vs USE_CURL_ASYNC use
CURLRES_ASYNCH - is for when built to use an async name resolver; threaded or
c-ares

USE_CURL_ASYNC - is for when built to use either an async name resolver OR DoH

Reported-by: Lars Karlitski
Fixes #16645
Closes #16648
2025-03-10 13:15:20 +01:00
Daniel Stenberg
aa8d1d648e
socks: remove bad assert from do_SOCKS5()
It verified the auth bits wrongly. We don't need this assert anymore
since the input is verified in *setopt().

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

Closes #16650
2025-03-10 13:13:59 +01:00
Daniel Stenberg
06ae0eceb9
STRPARSE: amend with recently added functions
Closes #16647
2025-03-10 12:18:48 +01:00
Daniel Stenberg
09a5b2f2de
lib: rename curlx_strtoofft to Curl_str_numblanks()
The function is no longer used via the curlx shortcut.

Remove the strtoofft.[ch] files.

Closes #16642
2025-03-10 10:39:20 +01:00
Christian Schmitz
fc04eca8f8
easy: fix warning about possible comma misuse
Closes #16644
2025-03-10 10:38:04 +01:00
Daniel Stenberg
5fdf30b4dd
configure: call the blocking resolver "blocking", not "default"
On most systems the default is actually the threaded resolver.

Closes #16646
2025-03-10 10:34:28 +01:00
Daniel Stenberg
f8e7a4df94
mprintf: switch three number parsers to use strparse
Also add more const char pointers and reduced the scope for some
variables.

Closes #16628
2025-03-10 09:01:04 +01:00
Daniel Stenberg
8dca3b0656
src: replace strto[u][ld] with curlx_str_ parsers
- Better error handling (no errno mess), better limit checks.

- Also removed all uses of curlx_strtoofft()

Closes #16634
2025-03-10 08:09:41 +01:00
Viktor Szakats
f3b599a7e2
GHA/windows: enable H3 in GnuTLS MinGW job
Closes #16635
2025-03-10 01:13:17 +01:00
Viktor Szakats
30739b4d36
libssh2: fix memory leak in SSH_SFTP_REALPATH state
Seen in MSVC libssh2 CI job:
```
test 0615...[SFTP put remote failure]
test 0616...[SFTP retrieval of empty file]
test 0618...[SFTP retrieval of two files]
test 0620...[SFTP retrieval of missing file followed by good file]
test 0622...[SFTP put failure]
test 0637...[SFTP retrieval with invalid X- range]
test 0640...[SFTP --head retrieval]
  ** MEMORY FAILURE
  Leak detected: memory still allocated: 22 bytes
  At 2ae5b8a7ab8, there's 22 bytes.
   allocated by D:/a/curl/curl/lib/vssh/libssh2.c:2006
```
https://github.com/curl/curl/actions/runs/13752652590/job/38455575042?pr=16636#step:14:3907
https://github.com/curl/curl/actions/runs/13752879003/job/38456075461
https://github.com/curl/curl/actions/runs/13753706458/job/38457888479

Bug: https://github.com/curl/curl/pull/16636#issuecomment-2709086838
Co-authored-by: Daniel Stenberg

Closes #16639
2025-03-10 01:13:05 +01:00
Viktor Szakats
61d30615e4
runtests: fix SSH server not starting in cases, re-ignore failing vcpkg CI jobs
Replace `Cwd::abs_path()` with `File::Spec->rel2abs()`. The former
requires the file to exist, but in some cases, it's missing.

Seen in MSVC vcpkg jobs using Chocolatey OpenSSH v8.0.0.1 ending up with
`$path=/d/a/curl/curl/bld/tests/log/3/server/ssh_server.pid`, which does
not exist while converting to an absolute path (the path is already
absolute, but the conversion is done unconditionally):
```
Use of uninitialized value in subroutine entry at D:/a/curl/curl/tests/pathhelp.pm line 128.
can't convert empty path at D:/a/curl/curl/tests/pathhelp.pm line 128.
```
Ref: https://github.com/curl/curl/actions/runs/13747741797/job/38444844173#step:14:1233 (master)
Ref: https://github.com/curl/curl/actions/runs/13751862952/job/38453816737#step:14:3185 (trace)

Also ignore 3 new libssh2 jobs failing due to memleak.

Partial revert of 1bd5ac998b #16570

Closes #16636
2025-03-09 23:28:07 +01:00
Viktor Szakats
5681628e2d
tests/server: sync wait_ms() with the libcurl implementation
It contains a series of bugfixes and updates applied to libcurl's
`Curl_wait_ms()` over the years, but missed from the copy in
`tests/server/util.c`:
- d65321f939,
  52e822173a,
  5912da253b
- 4a8f459837
- 1ad49feb71

It fixes `wait_ms()` to check for, and return `SOCKERRNO`. Fixing error
handling on Windows.

Also:
- tests/server: change callers to check `SOCKERRNO`.
- `wait_ms()`: fix to check for the correct error code on Windows.
  Pending for `Curl_wait_ms()`: #16621.
- `Curl_wait_ms()`: tidy-up `Sleep()` argument cast (nit).
- lib/curl_trc: drop an unused header.

Closes #16627
2025-03-09 12:04:30 +01:00
Samuel Henrique
454762d5ca
tests/servers.pm: remove unused variable 'portrange'
Its usage was dropped at 4efa0b5749
(https://github.com/curl/curl/pull/11220)

Grepping the tests folder for "portrange" returns only this as a result.

Closes #16632
2025-03-09 11:56:00 +01:00