Commit Graph

36243 Commits

Author SHA1 Message Date
Viktor Szakats
c478c7efdf
examples: fix two more cases of stat() TOCTOU
Also:
- ftpupload: bump an intermediate variable size.

Follow-up to f13250edf1 #18605

Closes #18778
2025-09-30 12:28:43 +02:00
renovate[bot]
5b086ba188
Dockerfile: update debian:bookworm-slim digest to 7e49091
Closes #18777
2025-09-30 11:32:12 +02:00
Viktor Szakats
dd37d6970c
checksrc: fix possible endless loop when detecting BANNEDFUNC
If the source line had square brackets before the match, the stripping
of the banned function left the original line intact, and repeated the
check on it forever. E.g. with banned function `open` in `lib518.c`:
```c
t518_testfd[0] = open(DEV_NULL, O_RDONLY);
```

Closes #18775
2025-09-30 11:32:12 +02:00
Viktor Szakats
20142f5d06
build: avoid overriding system symbols for fopen functions
By introducing wrappers for them in the curlx namespace:
`curlx_fopen()`, `curlx_fdopen()`, `curlx_fclose()`.

The undefine/redefine/`(function)()` methods broke on systems
implementing these functions as macros. E.g. AIX 32-bit's `fopen()`.

Also:
- rename `lib/fopen.*` to `lib/curl_fopen.*` (for `Curl_fopen()`)
  to make room for the newly added `curlx/fopen.h`.
- curlx: move file-related functions from `multibyte.c` to `fopen.c`.
- tests/server: stop using the curl-specific `fopen()` implementation
  on Windows. Unicode isn't used by runtests, and it isn't critical to
  run tests on longs path. It can be re-enabled if this becomes
  necessary, or if the wrapper receives a feature that's critical for
  test servers.

Reported-by: Andrew Kirillov
Bug: https://github.com/curl/curl/issues/18510#issuecomment-3274393640

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

Closes #18634
2025-09-30 01:10:36 +02:00
Viktor Szakats
10bac43b87
tests/server: drop unsafe open() override in signal handler (Windows)
Turns out the signal handler on Windows still wasn't signal safe after
the previous round of fix. There is an `open()` call made from there,
and `open` happens to be unconditionally overridden via `curl_setup.h`
on Windows, to its local implementation (`curlx_win32_open()`), which
does memory allocations and potentially other things that are not signal
safe.

This is a temporary fix, till avoiding the override of system symbols
`open` and `stat` on Windows.

FTR this did not fix the CI 2304 errors, diskspace fail or job hangs due
to 0xC0000142 fork failure (it's rare all three occurs in the same run):
https://github.com/curl/curl/actions/runs/18110523584?pr=18774

Ref: #18634
Follow-up e95f509c66 #16852
Closes #18774
2025-09-30 01:10:35 +02:00
Viktor Szakats
e17aa98bfe
cmake: use more COMPILER_OPTIONS, LINK_OPTIONS / LINK_FLAGS
- replace `COMPILE_FLAGS` with `COMPILE_OPTIONS` that superceded it.

  Follow-up to 6140dfcf3e
  https://cmake.org/cmake/help/v4.1/prop_sf/COMPILE_FLAGS.html

- replace `target_link_libraries()` with `LINK_FLAGS` property for
  CMake <=3.12, because we are passing linker options (not libs).

  Follow-up to 91720b620e #18468
  Follow-up to 548873921c #17670
  Follow-up to 95aea798db #5843
  https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html
  https://cmake.org/cmake/help/v3.7/prop_tgt/LINK_FLAGS.html

- replace `target_link_options()` with `LINK_OPTIONS` propery for
  CMake 3.13+, to use the modern style.

  Follow-up to 91720b620e #18468
  Follow-up to 548873921c #17670
  https://cmake.org/cmake/help/v3.13/command/target_link_options.html
  https://cmake.org/cmake/help/v3.13/prop_tgt/LINK_OPTIONS.html

Also:

- fix to append to, not override, previously set linker options when
  using `CURL_LIBCURL_VERSIONED_SYMBOLS=ON`. Before this patch, it was
  overwriting linker options when using `CURL_CODE_COVERAGE=ON`.

  Follow-up to 91720b620e #18468

Closes #18762
2025-09-29 13:07:14 +02:00
Viktor Szakats
81a9197102
GHA/linux-old: make one cmake v3.7.2 job verbose
To show the details in cmake builds using the oldest supported version.
Use a legacy method. `--verbose` became supported later, in 3.14.

Closes #18764
2025-09-28 12:33:06 +02:00
Viktor Szakats
a6182865d0
CI: make pip use tests/requirements.txt in Circle CI
Also sync `pip` options with those used in GHA.

Closes #18760
2025-09-28 00:43:24 +02:00
Viktor Szakats
660d915ebd
ci: use --enable-option-checking=fatal in autotools jobs
To avoid typos and non-existing options passed to `./configure` in CI
builds.

Also delete obsolete option `--enable-test-bundles` from Circle CI jobs.

Closes #18759
2025-09-28 00:20:12 +02:00
Viktor Szakats
75d5424979
GHA/windows: tidy up Cygwin jobs
- drop unnecessary installed packages.
- sync built type name with other jobs.

Closes #18758
2025-09-27 19:03:25 +02:00
renovate[bot]
b5c9c858d5
GHA: update dependency awslabs/aws-lc to v1.61.4
Closes #18752
2025-09-27 16:31:13 +02:00
Viktor Szakats
16f721443a
GHA/linux: tidy up AWS-LC local build
To sync with other builds and to use `-B` to avoid a cmake warning and
future breakage.

Closes #18757
2025-09-27 16:29:24 +02:00
Viktor Szakats
95e50ad694
tidy-up: miscellaneous
- GHA/checkdocs: rename `spellcheck` job to `pyspelling` to say
  the exact tool used.
- GHA/checkdocs: restore a comment.
- GHA/linux: add `-B .` to a cmake configure to avoid warning, and
  future breakage.
- autotools: use correct casing for `Schannel`.
- doh: update RFC URL.
- drop redundant parenthesis.
- fix indentation, whitespace.

Closes #18756
2025-09-27 12:59:07 +02:00
Viktor Szakats
8538856662
perlcheck: parallelize
Follow-up to 34b1e146e4 #18745

Closes #18750
2025-09-26 23:50:53 +02:00
Daniel Stenberg
b5ffe30e5b
cf-ip-happy: mention unix domain path, not port number
In the connect error message if a unix domain socket was used.

Reported-by: kuchara on github
Ref: #18748
Closes #18749
2025-09-26 17:29:12 +02:00
Viktor Szakats
34b1e146e4
perlcheck: add script, run in CI, fix fallouts
Add script to run all Perl sources through `perl -c` to ensure no
issues, and run this script via GHA/checksrc in CI.

Fallouts:
- fix two repeated declarations.
- move `shell_quote()` from `testutil.pm` to `pathhelp.pm`, to
  avoid circular dependency in `globalconfig.pm`.

Closes #18745
2025-09-26 14:47:33 +02:00
Daniel Stenberg
72f72f678d
openldap: check ber_sockbuf_add_io() return code
The man page says nothing about what the return code means but Howard
Chu tells me it is 0 on success, -1 on fail.

Help-by: Howard Chu

Closes #18747
2025-09-26 14:29:49 +02:00
Daniel Stenberg
84d9627531
tool_progress: handle possible integer overflows
The progress meters max out at 2^63 bytes.

Reported-by: BobodevMm on github
Fixes #18744
Closes #18746
2025-09-26 10:53:28 +02:00
Stefan Eissing
061e265502
http: handle user-defined connection headers
When there is more than one user-supplied 'Connection: ' header, add
values that curl needs internally to the first one and emit all
subsequent ones thereafter.

Fixes #18662
Reported-by: Evgeny Grin (Karlson2k)
Closes #18686
2025-09-26 09:27:50 +02:00
Daniel Stenberg
500ea90829
RELEASE-NOTES: synced 2025-09-25 23:35:31 +02:00
Daniel Stenberg
16e0a2098d
openssl: fail the transfer if ossl_certchain() fails
Since it would indicate errors to the degree that continuing would just
risk hiding the earlier errors or make things weird.

Inspired by a report in Joshua's sarif data

Closes #18646
2025-09-25 22:25:20 +02:00
renovate[bot]
e27853d36b
GHA: update dependency ruff and github/codeql-action
- update github/codeql-action digest to 303c0ae
- update dependency ruff to v0.13.2

Closes #18716
Closes #18734
2025-09-25 21:53:53 +02:00
Daniel Stenberg
b8f10be4f2
libssh: acknowledge SSH_AGAIN in the SFTP state machine
Reported in Joshua's sarif data

Closes #18740
2025-09-25 17:26:47 +02:00
Daniel Stenberg
9595921b06
libssh: clarify myssh_block2waitfor
Fixed misleading comment. Simplified the bit setup.

Reported in Joshua's sarif data

Closes #18739
2025-09-25 17:26:01 +02:00
Viktor Szakats
e48c1ea415
GHA: use pyspelling directly
To avoid depending on Docker Hub, an Docker image and a GitHub Action.
Also to simplify running this check on a local machine.

Pending question if Dependabot and Mend/Renovate will automatically pick
up `requirements-docs.txt`.

Also:
- enable parallel spellchecking. (also to win back the time lost with
  installing components directly from Debian and pip.)
- pin `pyspelling`.
- link to official `pyspelling` docs.

Closes #18736
2025-09-25 16:59:27 +02:00
Stefan Eissing
f5bae285f3
socks: handle error in verbose trace gracefully
Adjust the flow to always succeed in verbose trace of connect.

Reported in Joshua's sarif data

Closes #18722
2025-09-25 16:55:22 +02:00
Daniel Stenberg
9f75603d4f
tftp: only check address if it was stored
If recvfrom() fails, it might not have stored an address.

Follow-up to c4f9977c66

Pointed out by CodeSonar

Closes #18738
2025-09-25 16:54:19 +02:00
Daniel Stenberg
bebc8df0f7
schannel_verify: use more human friendly error messages
Closes #18737
2025-09-25 16:53:29 +02:00
Viktor Szakats
edbf610c6a
GHA: set HOMEBREW_NO_AUTO_UPDATE=1 for Linuxbrew
In an attempt to make `brew install` commands initialize faster.

Often this command started with 20-50 seconds of delay before this
patch. This is an attempt to make it launch faster.

Cherry-picked from #18736
2025-09-25 15:37:13 +02:00
Viktor Szakats
5b8c80684b
GHA/checksrc: drop no longer used DEBIAN_FRONTEND env
Follow-up to 7d5f8be532 #18708
Cherry-picked from #18736
2025-09-25 15:37:13 +02:00
Daniel Stenberg
882293cc81
KNOWN_BUGS: telnet code does not handle partial writes properly
Reported in Joshua's sarif data

Closes #18735
2025-09-25 14:42:04 +02:00
Viktor Szakats
e08211b1ca
GHA: bump pip cryptography, relax impacket version requirement
Bump `cryptography` to a newer version that fixes two known OpenSSL
vulnerabilities reported by Dependabot.

To make it work, also allow `impacket` 0.11.0, because it allows any
pyOpenSSL version, while 0.12.0 pinned it to a single version that
happens to be incompatible with the bugfixed `cryptography` version.

Also: drop spaces from `requirements.txt` files. Bots don't add them,
though they seem to be preferred in the official documentation:
https://pip.pypa.io/en/stable/reference/requirements-file-format/

https://github.com/fortra/impacket/blob/impacket_0_11_0/requirements.txt
https://github.com/fortra/impacket/blob/impacket_0_12_0/requirements.txt

Follow-up to 7d5f8be532 #18708

Closes #18731
2025-09-25 14:22:40 +02:00
Stefan Eissing
442943fb8e
openssl: set io_need always
When OpenSSL reports SSL_ERROR_WANT_READ, set the io_need explicitly.
It should have already been set by the BIO, but be safe.

Reported in Joshua's sarif data

Closes #18733
2025-09-25 14:19:50 +02:00
Stefan Eissing
221b7dda38
transfer: avoid busy loop with tiny speed limit
When a transfer has a speed limit less than 4, the receive loop early
exits without receiving anything, causing a busy loop for that transfer.

Perform that check only after the first receive has been done.

Reported in Joshua's sarif data

Closes #18732
2025-09-25 14:18:35 +02:00
Stefan Eissing
771dd9d9e7
quiche: when ingress processing fails, return that error code
Instead of a general CURLE_RECV_ERROR.

Reported in Joshua's sarif data

Closes #18730
2025-09-25 14:17:39 +02:00
Stefan Eissing
dec661c81c
wolfssl: fix error check in shutdown
When trying to send the TLS shutdown, use the return code
to check for the cause.

Reported in Joshua's sarif data

Closes #18729
2025-09-25 14:16:56 +02:00
Stefan Eissing
15b4b96188
rustls: fix comment describing cr_recv()
The comments on `cf_recv()` function were outdated and described
calling conventions that no longer are true.

Reported in Joshua's sarif data

Closes #18728
2025-09-25 14:14:02 +02:00
Stefan Eissing
e02cbe94ff
mbedtls: check result of setting ALPN
The result of setting the negotiated ALPN was not checked, leading
to reporting success when it should not have.

Reported in Joshua's sarif data

Closes #18727
2025-09-25 14:13:09 +02:00
Stefan Eissing
36eb26381c
quiche: fix verbose message when ip quadruple cannot be obtained.
Reported in Joshua's sarif data

Closes #18726
2025-09-25 14:12:11 +02:00
Stefan Eissing
ee2dd2d6cb
openssl-quic: handle error in SSL_get_stream_read_error_code
The return code of SSL_get_stream_read_error_code() was not checked
in one location, but others. Make that consistent.

Reported in Joshua's sarif data

Closes #18725
2025-09-25 14:11:25 +02:00
Stefan Eissing
887b863b00
openssl: clear retry flag on x509 error
When loading the trust anchors and encountering an error, clear
a possibly set retry flag.

Reported in Joshua's sarif data

Closes #18724
2025-09-25 14:10:00 +02:00
Stefan Eissing
5f4f70e06d
ngtcp2: fix early return
On a failed tls handshake, the receive function returned without
restoring the current data.

Reported in Joshua's sarif data

Closes #18723
2025-09-25 14:09:15 +02:00
Stefan Eissing
b0f6593219
openssl-quic: check results better
Fail on errors from SSL_handle_events().
Force quit Caddy test instance that is left hanging longer with
openssl-quic tests for unknown reasons.

Reported in Joshua's sarif data

Closes #18720
2025-09-25 14:07:56 +02:00
Stefan Eissing
9e8b05fb99
wolfssl: check BIO read parameters
Check parameters passed more thoroughly and assure that current 'data'
also exists.

Reported in Joshua's sarif data

Closes #18718
2025-09-25 14:05:50 +02:00
Stefan Eissing
cbc30d4ed2
vtls: alpn setting, check proto parameter
When setting the negotiated alpn protocol, either then length
must be 0 or a pointer must be passed.

Reported in Joshua's sarif data

Closes #18717
2025-09-25 14:04:14 +02:00
Stefan Eissing
ccd2b03b0d
socks: rewwork, cleaning up socks state handling
Restructured the code in the following ways:

* add terminal states SUCCESS and FAILED
* split SOCK4 and SOCK5 states to be more clear
* use `bufq` for send/recv of SOCK messages
* reduce SOCKS4 states, more speaking names
* for most states, move code into static function
* reduce SOCKS5 states, more speaking names
* add helpers for traversing to FAILED state
* add helper to flush bufq
* add hepler to read minimum amount into bufq

Closes #18401
2025-09-25 14:03:10 +02:00
Stefan Eissing
b3fc692568
lib: upgrade/multiplex handling
Improvements around HTTP Upgrade: and multiplex hanndling:

* add `Curl_conn_set_multiplex()` to set connection's multiplex
  bit and trigger "connchanged" events
* call `Curl_conn_set_multiplex()` in filters' `CF_CTRL_CONN_INFO_UPDATE`
  implementation where other connection properties are updated.
  This prevents connection updates before the final filter chain
  is chosen.
* rename enum `UPGR101_INIT` to `UPGR101_NONE`
* rename connection bit `asks_multiplex` to `upgrade_in_progress`
* trigger "connchanged" when `upgrade_in_progress` clears
* rename `WebSockets` to `WebSocket` as it is the common term
  used in documentation

Closes #18227
2025-09-25 14:00:37 +02:00
Daniel Stenberg
943166fed3
socks_sspi: bail out on too long fields
A probably unnecessary precaution but since the field sizes are 16 bit in the
protocol this makes sure to fail if they would ever be larger as that would go
wrong.

Reported in Joshua's sarif data

Closes #18719
2025-09-25 13:35:25 +02:00
Viktor Szakats
6796147910
GHA/checksrc: run reuse directly, merge into the linters workflow
To eliminate dependencies on an Action, Docker Hub and to simplify.

Closes #18721
2025-09-25 12:06:44 +02:00
renovate[bot]
8e13e42583
GHA: update dependency ruff to v0.13.1 2025-09-25 11:42:43 +02:00