Commit graph

36137 commits

Author SHA1 Message Date
Daniel Stenberg
5ab120bc4e
krb5: drop support for Kerberos FTP
It was accidentally broken in commit 0f4c439fc7, shipped since
8.8.0 (May 2024) and yet not a single person has noticed or reported,
indicating that we might as well drop support for FTP Kerberos.

Krb5 support was added in 54967d2a3a (July 2007), and we have
been carrying the extra license information around since then for this
code. This commit removes the last traces of that code and thus we can
remove the extra copyright notices along with it.

Reported-by: Joshua Rogers
Closes #18577
2025-09-20 23:58:28 +02:00
Daniel Stenberg
bb46d42407
openssl: make the asn1_object_dump name null terminated
In case the buffer is too small.

Reported in Joshua's sarif data

Closes #18647
2025-09-20 23:12:15 +02:00
Daniel Stenberg
cf3b9657bc
libssh2: up the minimum requirement to 1.9.0
Released on June 20 2019
2025-09-20 22:39:07 +02:00
Daniel Stenberg
50968d0378
httpsrr: free old pointers when storing new
In case we get "funny" input and the same field is provided several
times, free the old pointer before stored a new memdup.

Reported in Joshua's sarif data

Closes #18631
2025-09-20 22:38:15 +02:00
Daniel Stenberg
979366a625
openldap: improve check for receiving blank data
It can't access the first byte either unless it has length.

Followup to 232d5a2ed9

Closes #18632
2025-09-20 22:37:10 +02:00
Daniel Stenberg
66d6075af9
tftp: return error when sendto() fails
The code just called failf() and then continued without returning error.

Reported in Joshua's sarif data

Closes #18643
2025-09-20 22:35:12 +02:00
Daniel Stenberg
e2d3b83244
libssh: return out of memory correctly if aprintf fails
The code called set sshc->nextstate and returned SSH_OK without setting
sshc->actualcode to an error code.

Reported in Joshua's sarif data

Closes #18637
2025-09-20 17:49:07 +02:00
Daniel Stenberg
d27d9c7ef1
cf-socket: use the right byte order for ports in bindlocal
Reported in Joshua's sarif data

Closes #18641
2025-09-20 17:34:18 +02:00
Daniel Stenberg
94eec0a788
schannel: assign result before using it
curl_easy_strerror(result) was called *before* result was assigned.

Reported in Joshua's sarif data

Closes #18642
2025-09-20 17:30:59 +02:00
Daniel Stenberg
82eeda1041
CURLOPT_HEADER/WRITEFUNCTION.md: drop '* size' since size is always 1
Closes #18640
2025-09-20 17:27:17 +02:00
Daniel Stenberg
df8244c30f
libssh: error on bad chown number and store the value
To avoid continuing with an unintended zero uid. Also actually use the
value, which was omitted before!

Reported in Joshua's sarif data

Closes #18639
2025-09-20 17:26:38 +02:00
Daniel Stenberg
ca8ec6e033
tftp: handle tftp_multi_statemach() return code
Previously just ignored.

Reported in Joshua's sarif data

Closes #18638
2025-09-20 17:25:35 +02:00
Daniel Stenberg
277ebca610
ftp: fix port number range loop for PORT commands
If the last port to test is 65535, the loop would previously wrongly
wrap the counter and start over at 0, which was not intended.

Reported in Joshua's sarif data

Closes #18636
2025-09-20 17:24:44 +02:00
Daniel Stenberg
2a5da01e42
socks: make Curl_blockread_all return CURLcode
Reported in Joshua's sarif data

Closes #18635
2025-09-20 15:15:13 +02:00
Viktor Szakats
ca75476a5c
GHA/codeql: drop winbuild references [ci skip]
Follow-up to 8d004781a5 #18040
2025-09-20 15:07:29 +02:00
Viktor Szakats
bf7375ecc5
build: avoid overriding system symbols for socket functions
Before this patch `accept4()`, `socket()`, `socketpair()`, `send()` and
`recv()` system symbols were remapped via macros, using the same name,
to local curl debug wrappers. This patch replaces these overrides by
introducing curl-namespaced macros that map either to the system symbols
or to their curl debug wrappers in `CURLDEBUG` (TrackMemory) builds.

This follows a patch that implemented the same for `accept()`.

The old method required tricks to make these redefines work in unity
builds, and avoid them interfering with system headers. These tricks
did not work for system symbols implemented as macros.

The new method allows to setup these mappings once, without interfering
with system headers, upstream macros, or unity builds. It makes builds
more robust.

Also:
- checksrc: ban all mapped functions.
- docs/examples: tidy up checksrc rules.

Follow-up to 9863599d69 #18502
Follow-up to 3bb5e58c10 #17827

Closes #18503
2025-09-20 13:44:59 +02:00
Daniel Stenberg
2fe95cb0e3
rustls: typecast variable for safer trace output
This is a variadic function call with a mismatched argument type; on
platforms where uintptr_t and size_t differ, this invokes undefined
behavior.

Reported in Joshua's sarif data

Closes #18628
2025-09-20 12:07:10 +02:00
Daniel Stenberg
0209e087c6
tool_cb_hdr: size is always 1
- add comment in the header that the argument 'size' is always 1,
  as guaranteed by the libcurl API

- then fix the call to fwrite() to avoid using "size, etag_length" which
  would be wrong if size was something else than 1, and use a fixed
  number there instead.

Reported in Joshua's sarif data

Closes #18630
2025-09-20 12:06:27 +02:00
Daniel Stenberg
335d16e944
libssh: error on bad chgrp number
To avoid it continuing with a zero gid.

Reported in Joshua's sarif data

Closes #18629
2025-09-20 12:05:31 +02:00
Daniel Stenberg
7a26304a95
curl_slist_append.md: clarify that a NULL pointer is not acceptable
Closes #18627
2025-09-20 12:04:47 +02:00
Viktor Szakats
1429858bce
tidy-up: update MS links, allow long URLs via checksrc
- update Microsoft documentation links.
  (also drop language designator where present.)

- checksrc: allow longer than 78 character lines if they
  contain a https URL. To make these links easier to use and parse.

- merge links that were split into two lines.

Closes #18626
2025-09-20 11:49:23 +02:00
Viktor Szakats
92f215fea1
build: address some -Weverything warnings, update picky warnings
`-Weverything` is not enabled by curl, and not recommended by LLVM,
because it may enable experimental options, and will result in new
fallouts after toolchain upgrades. This patch aims to fix/silence as much
as possible as found with llvm/clang 21.1.0. It also permanently enables
warnings that were fixed in source and deemed manageable in the future.
`-Wformat` warnings are addressed separately via #18343.

Fix/silence warnings in the source:
- typecheck-gcc.h: fix `-Wreserved-identifier`.
- lib: silence `-Wcast-function-type-strict`.
  For llvm 16+ or Apple clang 16+.
- asyn-ares: limit `HAPPY_EYEBALLS_DNS_TIMEOUT` to old c-ares versions.
- curl_trc: fix `-Wc++-hidden-decl`.
- doh: fix `-Wc++-keyword`.
- ftp: fix `-Wreserved-identifier`.
- ldap: fix `-Wreserved-identifier`.
- mqtt: comment unused macro to avoid warning.
- multi_ev: drop unused macros to avoid warnings.
- setopt: fix useless `break;` after `return;`.
- gtls, mbedtls, rustls: silence `-Wconditional-uninitialized`.
- socks_sspi, schannel, x509asn1: fix `-Wimplicit-int-enum-cast`.
- x509asn1: fix `-Wc++-keyword`.
- openssl: scope `OSSL_UI_METHOD_CAST` to avoid unused macro warning.
- libssh2, wolfssl: drop unused macros.
- curl_ngtcp2, curl_quiche, httpsrr, urlapi: drop/limit unused macros.
- tool_getparam: fix useless `break;` after `return;` or `break;`.
  Not normally enabled because it doesn't work with unity.
  https://github.com/llvm/llvm-project/issues/71046
- tool_operate: fix `-Wc++-keyword`.
- curlinfo: fix a `-Wunsafe-buffer-usage`.
- tests: silence `-Wformat-non-iso`.
- lib557: fix `-Wreserved-identifier`.
- lib1565: silence `-Wconditional-uninitialized`.

Enable the above clang warnings permanently in picky mode:
- `-Wc++-hidden-decl`
- `-Wc++-keyword` (except for Windows, where it collides with `wchar_t`)
- `-Wcast-function-type-strict`
- `-Wcast-function-type`
- `-Wconditional-uninitialized`
- `-Wformat-non-iso` (except for clang-cl)
- `-Wreserved-identifier`
- `-Wtentative-definition-compat`

Silence problematic `-Weverything` warnings globally (in picky mode):
- `-Wused-but-marked-unused` (88000+ hits) and
  `-Wdisabled-macro-expansion` (2600+ hits).
  Triggered by `typecheck-gcc.h` when building with clang 14+.
  Maybe there exists a way to fix within that header?
  Ref: https://discourse.llvm.org/t/removing-wused-but-marked-unused/55310
- `-Wunsafe-buffer-usage`. clang 16+. 7000+ hits.
  May be useful in theory, but such high volume of hits makes it
  impractical to review and possibly address. Meant for C++.
  Ref: https://clang.llvm.org/docs/SafeBuffers.html
  Ref: https://stackoverflow.com/questions/77017567/how-to-fix-code-to-avoid-warning-wunsafe-buffer-usage
  Ref: https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734
  Ref: https://github.com/llvm/llvm-project/pull/111624
- `-Wimplicit-void-ptr-cast`. clang 21+. 1700+ hits.
  C++ warning, deemed pure noise.
  Ref: https://github.com/curl/curl/issues/18470#issuecomment-3253506266
- `-Wswitch-default` (180+ hits), `-Wswitch-enum` (190+ hits),
  `-Wcovered-switch-default` (20+ hits).
  Next to impossible to fix cleanly, esp. when the covered `case`
  branches depend on compile-time options.
- `-Wdocumentation-unknown-command` (8+ hits).
  Triggered in a few sources. Seems arbitrary and bogus.
- `-Wpadded` (550+ hits).
- `-Wc++-keyword` on Windows, where it collides with `wchar_t`.
  (100+ hits)
  Ref: https://github.com/llvm/llvm-project/issues/155988
- `-Wreserved-macro-identifier`. clang 13+. 5+ hits.
  Sometimes it's necessary to set external macros that use
  the reserved namespace. E.g. `_CRT_NONSTDC_NO_DEPRECATE`,
  `__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__`, `__NO_NET_API`,
  possibly `_REENTRANT`, and more.
  It's not worth trying to silence them individually.
- `-Wnonportable-system-include-path` with `clang-cl`.
  It'd be broken by doing what the warning suggests.
- `-Wformat-non-iso` for clang-cl.

CMake `PICKY_COMPILER=ON` (the default) or `./configure`
`--enable-warnings` (not the default) is required to enable these
silencing rules.

Also:
- autotools, cmake: fix Apple clang and mainline llvm version translations.
  Ref: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
- autotools, cmake: enable `-Warray-compare` for clang 20+.
  Follow-up to 4b7accda5a #17196
- cmake: fix to enable `-Wmissing-variable-declarations` at an earlier
  clang version.
- cmake: update internal logic to handle warning options with `+` in
  them.
- cmake: fix internal logic to match the whole option when looking
  into `CMAKE_C_FLAGS` for custom-disabled warnings.

Follow-up to b85cb8cb4e #18485

Closes #18477
2025-09-20 10:16:15 +02:00
Viktor Szakats
87cbeecee4
windows: stop passing unused, optional argument for Win9x compatibility
Expiry timestamp in `AcquireCredentialsHandle()` (SSPI) and
`InitializeSecurityContext()` (Schannel) calls. The argument is optional
in both. The returned value was never used in curl. The reason for
passing it was Windows 95 compatibility, according to comments in
the SSPI code. curl no longer supports Windows 95.

Ref: https://learn.microsoft.com/windows/win32/api/sspi/nf-sspi-acquirecredentialshandlea
Ref: https://learn.microsoft.com/windows/win32/secauthn/initializesecuritycontext--schannel

Ref: 3fe5311967
Ref: aaa42aa0d5

Closes #18490
2025-09-20 02:27:07 +02:00
Viktor Szakats
ad26a6cb99
tidy-up: avoid using the reserved macro namespace
To avoid hitting `-Wreserved-macro-identifier` where possible.

- amigaos: introduce local macro instead of reusing `__request()`.
- easy_lock: avoid redefining `__has_builtin()`.
  Follow-up to 33fd57b8ff #9062
- rand: drop interim macro `_random()`.
- windows: rename local macro `_tcsdup()` to `Curl_tcsdup()`.
  To avoid using the reserved macro namespace and to avoid
  colliding with `_tcsdup()` as defined by Windows headers.
- checksrc: ban `_tcsdup()` in favor of `Curl_tcsdup()`.
- tool_doswin: avoid redefining `_use_lfn()` (MS-DOS).
- tool_findfile: limit `__NO_NET_API` hack to AmigaOS.
  Syncing this pattern with `lib/netrc.c`.
  Follow-up to 784a8ec2c1 #16279
- examples/http2-upload: avoid reserved namespace for local macro.

More cases will be removed when dropping WinCE support via #17927.

Cases remain when defining external macros out of curl's control.

Ref: #18477
Closes #18482
2025-09-20 02:27:06 +02:00
Viktor Szakats
096fc4325b
digest_sspi: fix two memory leaks in error branches
Closes #18488
2025-09-20 01:28:35 +02:00
Viktor Szakats
91720b620e
cmake: add CURL_CODE_COVERAGE option
To sync up with the `--enable-code-coverage` `./configure` option.

Ref: https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html
Ref: https://gcc.gnu.org/onlinedocs/gcc/Cross-profiling.html
Ref: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html

Closes #18468
2025-09-20 01:28:35 +02:00
Viktor Szakats
dc3f4fd89b
autotools: make --enable-code-coverage support llvm/clang
Cherry-picked from #18468

Closes #18473
2025-09-20 01:28:35 +02:00
Viktor Szakats
1c49f2f26d
windows: replace _beginthreadex() with CreateThread()
Replace `_beginthreadex()` C runtime calls with native win32 API
`CreateThread()`. The latter was already used in `src/tool_doswin.c`
and in UWP and Windows CE builds before this patch. After this patch
all Windows flavors use it. To drop PP logic and simplify code.

While working on this it turned out that `src/tool_doswin.c` calls
`TerminateThread()`, which isn't recommended by the documentation,
except for "the most extreme cases". This patch makes no attempt
to change that code.
Ref: 9a2663322c #17572
Ref: https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread

Also:
- use `WaitForSingleObjectEx()` on all desktop Windows.
  Ref: 4be80d5109
  Ref: https://sourceforge.net/p/curl/feature-requests/82/
  Ref: https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-waitforsingleobjectex
- tests: drop redundant casts.
- lib3207: fix to not rely on thread macros when building without thread
  support.

Assisted-by: Jay Satiro
Assisted-by: Marcel Raad
Assisted-by: Michał Petryka
Follow-up to 38029101e2 #11625

Closes #18451
2025-09-20 01:28:35 +02:00
Viktor Szakats
8d004781a5
build: drop the winbuild build system
In favor of CMake.

Closes #18040
2025-09-20 01:20:25 +02:00
Daniel Stenberg
5e2d4d7905
base64: accept zero length argument to base64_encode
We used to treat 0 as "call strlen() to get the length" for
curlx_base64_encode, but it turns out this is rather fragile as we
easily do the mistake of passing in zero when the data is actually not
there and then calling strlen() is wrong.

Force the caller to pass in the correct size. A zero length input string
now returns a zero length output and a NULL pointer.

Closes #18617
2025-09-19 22:57:20 +02:00
Daniel Stenberg
a0369e1705
gtls: avoid potential use of uninitialized variable in trace output
Reported in Joshua's sarif data

Closes #18620
2025-09-19 22:55:52 +02:00
Daniel Stenberg
58f071dbe4
tool_getparam/set_rate: skip the multiplication on overflow
The code detected the problem but didn't avoid the calculation
correctly.

Fixes #18624
Reported-by: BobodevMm on github
Closes #18625
2025-09-19 22:54:57 +02:00
Daniel Stenberg
b0c823b86f
RELEASE-NOTES: synced
and bump to 8.17.0
2025-09-19 16:47:01 +02:00
Daniel Stenberg
fd6eb8d6e7
cookie: avoid saving a cookie file if no transfer was done
Because parts of the cookie loading happens on transfer start the
in-memory cookie jar risks being incomplete and then a save might
wrongly truncate the target file.

Added test 1902 to verify.

Reported-by: divinity76 on github
Fixes #18621
Closes #18622
2025-09-19 16:40:20 +02:00
Daniel Stenberg
1055864b03
telnet: make printsub require another byte input
Reported in Joshua's sarif data

Closes #18618
2025-09-19 14:40:09 +02:00
Daniel Stenberg
df60e8fe70
cf_socket_recv: don't count reading zero bytes as first byte
Reported in Joshua's sarif data

Closes #18615
2025-09-19 14:39:15 +02:00
Daniel Stenberg
4f5528675a
libssh: react on errors from ssh_scp_read
Reported in Joshua's sarif data

Closes #18616
2025-09-19 14:38:20 +02:00
Viktor Szakats
b2356a3197
GHA: tidy up actions/checkout version in comments [ci skip] 2025-09-19 14:20:14 +02:00
Viktor Szakats
9618c337d1
GHA/codeql: try disabling the TRAP cache
The `cpp` CodeQL job is adding a cache entry for each run on the master
branch. One for Linux, another for Windows. Size: 68MB + 180MB = 248MB.
In one week we got 50+ such entries, almost filling the available cache
space.

Following the recommendation in an open issue thread, this patch tries
to disable this cache. Since it only affects master, the effect can only
be verified after merging.

The latest cache is picked up in PRs. The performance impact is also to
be seen after merge.

Bug: https://github.com/curl/curl/pull/18528#issuecomment-3288950880
Ref: https://github.com/github/codeql-action/pull/1172
Ref: https://github.com/github/codeql-action/issues/2030
Ref: https://github.com/github/codeql-action/issues/2885#issuecomment-2879069087

Follow-up to cc50f05370 #18528

Closes #18613
2025-09-19 11:30:39 +02:00
Viktor Szakats
0d9a07abb7
libssh2: drop two redundant null-terminations
The null-termination was first added in the initial SFTP commit in 2006:
a634f64400

At that time this was a reasonable concern because libssh2 started
null-terminating this string just one year prior, in 2005:
efc3841fd2

This fix was released in libssh2 v0.13 (2006-03-02).

curl requires libssh2 v1.2.8, making this workaround no longer necessary.

Follow-up to 9f18cb6544 #18598

Closes #18606
2025-09-19 09:46:45 +02:00
Daniel Stenberg
9fb8d567ca
tool_operate: keep the progress meter for --out-null
Fixes #18607
Closes #18609
2025-09-19 09:13:12 +02:00
Viktor Szakats
9f18cb6544
libssh2: error check and null-terminate in ssh_state_sftp_readdir_link()
- null-terminate the result to match the other getter
  `libssh2_sftp_symlink_ex()` call.

- check negative result and bail out early.

Reported-by: Joshua Rogers

Closes #18598
2025-09-18 22:01:27 +02:00
Viktor Szakats
cec6c1cd9c
GHA/codeql: make it run on docs updates, to verify examples
Follow-up to b4922b1295 #18564
2025-09-18 20:26:27 +02:00
Viktor Szakats
f13250edf1
examples: fix two issues found by CodeQL
- http2-upload: use `fstat()` to query file length to fix TOCTOU.

- ftpuploadresume: fix checking `sscanf()` return value.

Follow-up to b4922b1295 #18564
Closes #18605
2025-09-18 20:14:21 +02:00
Jay Satiro
ce354d0f4d tool_operate: Improve wording in retry message
- Use the plural 'seconds' for anything other than exactly 1 second.

Before: Will retry in 1.250 second.
After: Will retry in 1.250 seconds.

Follow-up to ca034e83.

Closes https://github.com/curl/curl/pull/18604
2025-09-18 12:09:02 -04:00
Daniel Stenberg
54aff4db3c
tftp: check and act on tftp_set_timeouts() returning error
Reported-by: Joshua Rogers
Ref: https://github.com/curl/curl/pull/18574#issuecomment-3300183302
Closes #18603
2025-09-18 17:54:13 +02:00
Joshua Rogers
ad147ec53d
tftp: propagate expired timer from tftp_state_timeout()
When Curl_timeleft() < 0 we used to return 0, masking the expiry and
skipping the caller’s (timeout_ms < 0) path. Now we set FIN and return
the negative value so tftp_multi_statemach() aborts with
CURLE_OPERATION_TIMEDOUT as intended.

Closes #18574
2025-09-18 17:34:31 +02:00
Jay Satiro
f8175b1536 socks_sspi: Fix some memory cleanup calls
- Ensure memory allocated by malloc() is freed by free().

Prior to this change SSPI's FreeContextBuffer() was sometimes used to
free malloc'd memory. I can only assume the reason we have no crash
reports about this is because the underlying heap free is probably the
same for both.

Reported-by: Joshua Rogers

Fixes https://github.com/curl/curl/issues/18587
Closes https://github.com/curl/curl/pull/18594
2025-09-18 11:29:15 -04:00
Joshua Rogers
a80abc45a5
sasl: clear canceled mechanism instead of toggling it
Use &= ~authused in SASL_CANCEL (was ^=) to actually remove the offending
mechanism and avoid re-enabling a disabled mech on retry.

Closes #18573
2025-09-18 17:27:29 +02:00
Daniel Stenberg
44a586472b
ldap: do not base64 encode zero length string
Reported-by: Joshua Rogers
Closes #18602
2025-09-18 17:15:30 +02:00