Commit Graph

34209 Commits

Author SHA1 Message Date
Daniel Stenberg
4e16f8aa6a
RELEASE-NOTES: synced 2024-09-03 16:43:45 +02:00
Stefan Eissing
a07ba37b5e
cf-socket: fix pollset for listening
When FTP does an active data connection, the socket connection
filter is instantiated with a listening socket. When the filter
adjusts its pollset, it needs to POLLIN, not OUT.

Bug: https://curl.se/mail/lib-2024-08/0023.html
Reported-by: Yoshimasa Ohno
Closes #14766
2024-09-03 16:29:08 +02:00
Stefan Eissing
81a3342877
connect: always prefer ipv6 in IP eyeballing
Always try ipv6 addresses first, ipv4 second after a delay.

If neither ipv4/6 are amongst the supplied addresses, start a happy
eyeballer for the first address family present. This is for AF_UNIX
connects.

Fixes #14761
Reported-by: janedenone on hackerone
Closes #14768
2024-09-03 16:24:42 +02:00
Daniel Stenberg
933e202eb5
KNOWN_BUGS: CURLOPT_CONNECT_TO does not work for HTTPS proxy
Closes #14481
Closes #14769
2024-09-03 15:15:27 +02:00
Daniel Stenberg
4ff04615a0
lib: use FMT_ as prefix instead of CURL_FORMAT_
For printf format defines used internally. Makes the code slighly
easier to read.

Closes #14764
2024-09-03 08:45:45 +02:00
Aki
a2bcec0ee0
openssl: fix the data race when sharing an SSL session between threads
The SSL_Session object is mutated during connection inside openssl,
and it might not be thread-safe. Besides, according to documentation
of openssl:

```
SSL_SESSION objects keep internal link information about the session
cache list, when being inserted into one SSL_CTX object's session
cache. One SSL_SESSION object, regardless of its reference count,
must therefore only be used with one SSL_CTX object (and the SSL
objects created from this SSL_CTX object).
```
If I understand correctly, it is not safe to share it even in a
single thread.

Instead, serialize the SSL_SESSION before adding it to the cache,
and deserialize it after retrieving it from the cache, so that no
concurrent write to the same object is infeasible.

Also
 - add a ci test for thread sanitizer
 - add a test for sharing ssl sessions concurrently
 - avoid redefining memory functions when not building libcurl, but
   including the soruce in libtest
 - increase the concurrent connections limit in sws

Notice that there are fix for a global data race for openssl which
is not yet release. The fix is cherry pick for the ci test with
thread sanitizer.
d8def79838

Closes #14751
2024-09-02 23:35:44 +02:00
Stefan Eissing
2c2292ecaf
haproxy: send though next filter
Small but, instead of sending the initial data though the connection
method, send it to the next filter in the chain. While the connection
methods accomodates for such use, by ignoring unconnected filters, it is
better to follow the filter chain explicitly.

Closes #14756
2024-09-02 23:34:26 +02:00
Viktor Szakats
e512fbfa67
printf: fix mingw-w64 format checks
Change mingw-w64 printf format checks in public curl headers to use
`__MINGW_PRINTF_FORMAT` instead of `gnu_printf`. This syncs the format
checker with format string macros published via `curl/system.h`. (Also
disable format checks for mingw-w64 older than 3.0.0 (2013-09-20) and
classic-mingw, which do not support this macro.)

This fixes bogus format checker `-Wformat` warnings in 3rd party code
using curl format strings with the curl printf functions, when using
mingw-w64 7.0.0 (2019-11-10) and older (with GCC, MSVCRT).

It also allows to delete two workaounds for this within curl itself:
- setting `-D__USE_MINGW_ANSI_STDIO=1` for mingw-w64 via cmake and
  configure for `docs/examples` and `tests/http/clients`.
  Ref: c730c8549b #14640

The format check macro is incompatible (depending on mingw-w64 version
and configuration) with the C99 `%z` (`size_t`) format string used
internally by curl.

To work around this problem, override the format check style in curl
public headers to use `gnu_printf`. This is compatible with `%z` in all
mingw-w64 versions and allows keeping the C99 format strings internally.

Also:
- lib/ws.c: add missing space to an error message.
- docs/examples/ftpgetinfo.c: fix to use standard printf.

Ref: #14643 (take 1)
Follow-up to 3829759bd0 #12489

Closes #14703
2024-09-02 21:03:01 +02:00
Viktor Szakats
6004f96734
cmake: default CURL_DISABLE_LDAPS to the value of CURL_DISABLE_LDAP
After this patch LDAPS is disabled by default when LDAP is manually
disabled.

This makes it unnecessary to disable them in sync manually just to avoid
a `CMakeLists.txt` warning.

Syncs behavior with `./configure`.

Closes #14758
2024-09-02 21:03:01 +02:00
Daniel Stenberg
d76b648584
rand: only provide weak random when needed
builds without TLS and builds using rustls

Closes #14749
2024-09-02 18:42:32 +02:00
Daniel Stenberg
269fdd4c6e
lib: remove use of RANDOM_FILE
It could previously be set with configure/cmake and used in rare cases
for reading randomness: with ancient mbedTLS or rustls without
arc4random.

We now get randomness in this order:

1. The TLS library's way to provide random
2. On Windows: Curl_win32_random
3. if arc4random exists, use that
4. weak non-crytographically strong pseudo-random

Closes #14749
2024-09-02 18:42:32 +02:00
Stefan Eissing
00ef607326
url: fix connection reuse for HTTP/2 upgrades
Normally, when a connection's filters have all connected, the
multiplex status is determined. However, HTTP/2 Upgrade:
requests will only do this when the first server response
has been received.

The current connection reuse mechanism does not accomodate
that and when the time between connect and response is large
enough, connection reuse may not happen as desired.

See test case 2405 failures, such as in
https://github.com/curl/curl/actions/runs/10629497461/job/29467166451

Add 'conn->bits.asks_multiplex' as indicator that a connection is
still being evaluated for mulitplexing, so that new transfers
may wait on this to be cleared.

Closes #14739
2024-09-02 12:39:03 +02:00
наб
76212cbf3e
curl_easy_handler.md: fix language
Applications need to [...] if it needs -> The application needs to

Closes #14752
2024-09-02 10:45:12 +02:00
Daniel Stenberg
8bb71d5fd3
curl.h: make CURLOPT_WRITEINFO and CURLOPT_CLOSEPOLICY compile
The symbols have not been in use for 17+ years and they did not do
anything for several years before that, but apparently there are still
code using them.

Follow-up to 3b057d4b7a
Fixes #14747
Reported-by: Kai Pastor
Closes #14748
2024-09-02 10:43:34 +02:00
Viktor Szakats
3362994948
build: add options to disable SHA-512/256 hash algo
Existing C macro lacked build-level counterparts.
Add them in this patch.

- cmake: `-DCURL_DISABLE_SHA512_256=ON`
- autotools: `--disable-sha512-256`

Also drop the checker exception from `test1165.pl`.

Follow-up to cbe41d151d #12897
Closes #14753
2024-09-01 22:13:49 +02:00
Viktor Szakats
83bcd335cd
test1165: check if curl_config.h.cmake lists all DISABLED options
Also fix issues:
- cmake: fix `CURL_DISABLE_HTTP_AUTH` option
- cmake: fix `CURL_DISABLE_SHUFFLE_DNS` option

Fixes:
```
Present in CMakeLists.txt, not propagated via curl_config.h.cmake: CURL_DISABLE_HTTP_AUTH
Present in CMakeLists.txt, not propagated via curl_config.h.cmake: CURL_DISABLE_SHUFFLE_DNS
```
Ref: https://github.com/curl/curl/actions/runs/10655027540/job/29532054141?pr=14754#step:11:2090

Closes #14754
2024-09-01 18:44:02 +02:00
Viktor Szakats
ad32fb42fb
autotools: settle with option name: --enable-windows-unicode
Bring the option name style in sync with cmake and with other configure
options aiming to enable something unrelated to an optional package.

(I initially named this new option `--with-windows-unicode` within this
release cycle.)

Follow-up to 9e4a2187e7 #14478

Closes #14746
2024-09-01 18:43:28 +02:00
Viktor Szakats
1e58665c2b
configure: break indentation to fix --help output
For recently added/updated options:
windows-unicode, winidn, apple-idn

It looks like the second `AS_HELP_STRING()` must start in the first
column, otherwise its indentation will appear in the `--help` output,
and break unalignment with the rest.

(There must be a better way to tackle this.)
2024-08-31 15:41:49 +02:00
Viktor Szakats
3fc81be44e
cmake: sync CURL_DISABLE_* behaviour with autotools
- disable RTSP, ALTSVC, HSTS when HTTP is disabled.
  (`./configure` warning deemed unnecessary and not replicated with
  cmake.)

- disable HSTS when there is no TLS backend.

Tested via #14744
Closes #14745
2024-08-31 12:00:49 +02:00
Viktor Szakats
d4240b9bf2
cmake: allow disabling RANDOM_FILE
`./configure` allows `--random-file=no`. Allow this with CMake too,
using `-DRANDOM_FILE=OFF` (other boolean values work too: no, false, 0,
case insensitive.)

Also disable `RANDOM_FILE` detection for Windows.

Closes #14743
2024-08-31 00:20:51 +02:00
Viktor Szakats
04e3621dce
build: add poll() detection for cross-builds
For cross-builds rely on `_POSIX_C_SOURCE` to decide if `poll()` is
supported, rather than just assuming it isn't.

This may still miss to detect `poll()` support, as seen for example with
Linux MUSL cross-builds.

Also:

- GHA/curl-for-win: enable RISC-V 64 cross-target for Linux MUSL.
  (to test this case with cmake, with a false-negative.)
  The first RISC-V 64 build in curl's CI.

- GHA/curl-for-win: add arm64/intel64 job for Linux glibc.
  (to test this case with cmake, and succeed.)

- cmake: delete unnecessary `#include <sys/time.h>` from non-cross-build
  `poll()` detection snippet.
  Follow-up tp cc8b813765 #14718

Fixes #14714
Closes #14734
2024-08-30 17:14:33 +02:00
Daniel Stenberg
415573a768
RELEASE-NOTES: synced 2024-08-30 16:16:51 +02:00
Stefan Eissing
4cd10ee28b
POP3: fix multi-line responses
Some POP3 commands are multi-line, e.g. have responses terminated by a
last line with '.', but some are not. Define the known command
properties and fix response handling.

Add test case for STAT.

Fixes #14677
Reported-by: ralfjunker on github
Closes #14707
2024-08-30 15:38:25 +02:00
Stefan Eissing
bc81292ea6
llist: clear the list pointer when a node is removed
Closes #14738
2024-08-30 13:17:42 +02:00
Daniel Stenberg
7143833f14
cmdline-opts: language fix for expect100-timeout.md and max-time.md
needs to **be** provided

Also a http3.md spellfix

Follow-up from 22a6a0bc6b

Closes #14737
2024-08-30 11:19:30 +02:00
Daniel Stenberg
22a6a0bc6b
http3.md: mention how the fallback can be h1 or h2
Closes #14736
2024-08-30 10:32:20 +02:00
Daniel Stenberg
98395155d7
mailmap: Aki Sakurai 2024-08-30 10:28:34 +02:00
Daniel Stenberg
23e6391c1d
managen: in man output, remove the leading space from examples
Leave that rendering decision to the display tool.

Closes #14735
2024-08-30 10:09:48 +02:00
Viktor Szakats
e5f9050b26
cmake: use host OS to decide about libcurl manpage batch size
Before this patch the targe OS was used, which prevented building
libcurl manpages in larger batches in cross-builds targeting e.g.
Windows.

Update the condition to use `CMAKE_HOST_UNIX` instead of `UNIX`.

This variable has been available since CMake 2.6.0:
176fe63d15

Follow-up to bb84f82476 #13207

Closes #14733
2024-08-30 10:09:01 +02:00
Daniel Stenberg
c280010d8b
managen: fix superfluous leading blank line in quoted sections
When a markdown quoted section using 4-space indentation was converted
to nroff, managen previously caused a newline to appear after the
leading .nf. This fix makes sure that newline is inserted *before* .nf
as intended.

This is perhaps most notable in the HTML version of rendered manpages if
the quoted sections use different colors or similar.

Closes #14732
2024-08-30 00:21:22 +02:00
Daniel Stenberg
430af3fb59
dump-ca-embed.md: set as "boolean", not "single"
Because it is. And it makes the template manpage explanation for it make
sense.

Follow-up to 8a3740bc8e

Closes #14731
2024-08-30 00:12:36 +02:00
Daniel Stenberg
946c96aa0a
docs/cmdline-opts/_VARIABLES: language polish
Closes #14730
2024-08-29 21:20:35 +02:00
Daniel Stenberg
3cf45fedc4
runtests: remove "has_textaware"
All sections defined with the mode="text" attribute now get line endings
normalized so that comparisons become line ending agnostic. Removes the
previous problem of figuring out how exactly different Windows
environments should be treated in this regard.

Closes #14717
2024-08-29 20:24:40 +02:00
Daniel Stenberg
eeb7c12807
ftp: always offer line end conversions
Previously this functionality was limited to platforms that not already
use CRLF as native line endings.

TODO: 4.5 ASCII support now considered fixed

Closes #14717
2024-08-29 20:24:37 +02:00
Daniel Stenberg
4becbb4af7
test1050: mark as FTP 2024-08-29 20:24:37 +02:00
Daniel Stenberg
55672d0aa3
test476: test ASCII FTP upload where file already uses CRLF
Closes #14717
2024-08-29 20:24:34 +02:00
Daniel Stenberg
ee17f35d43
test475: verify a 72K ASCII FTP upload
Extended the test format and runtest.pl so that the verify/upload part
can be marked using crlf newlines even when the client/file does not
have it.

Closes #14717
2024-08-29 20:24:23 +02:00
Viktor Szakats
cc8b813765
build: drop unused feature-detection code for Apple poll()
Drop Apple-specific detection logic for `poll()`. This detection snippet
has been disabled for Apple in both configure and cmake, for `poll()`
being broken on Apple since 10.12 Sierra (2016).

Also replace `exit(1);` with `return 1;` in configure, to make the
snippets match.

Added in 9297ca49f5 #1057 (2016-10-11).

Disabled for:
configure/darwin in a34c7ce754 (2016-10-18)
cmake/macOS in 825911be58 #7619
cmake/iOS in d14831233d #8244
cmake/all Apple in a86254b393 #12515

Closes #14718
2024-08-29 17:54:53 +02:00
renovate[bot]
7c49279aaa
GHA: update github/codeql-action digest to 4dd1613
Closes #14725
2024-08-29 16:53:23 +02:00
Stefan Eissing
4abf2b9699
openssl quic: fix memory leak
When a OpenSSL quic connection filter is aborted early, as the
server was not responding, the ssl instances where not closed
as they should.

Fixes #14720
Reported-by: ralfjunker on github
Closes #14724
2024-08-29 16:48:49 +02:00
Stefan Eissing
6354b35dfe
gnutls: send all data
Turns out `gnutls_record_send()` does really what the name says: it
sends exactly one TLS record. If more than 16k are there to send, it
needs to be called again with new buffer offset and length.

Continue sending record until the input is all sent or a EAGAIN (or
fatal error) is returned by gnutls.

Closes #14722
2024-08-29 16:46:56 +02:00
Stefan Eissing
44d1b6c271
pytest: add ftp upload ascii test
Add a test the uploads a text file in ascii mode and checks
that lengths match expectations.

Closes #14721
2024-08-29 16:45:59 +02:00
Stefan Eissing
64ab0ace27
urldata: remove crlf_conversions counter
Since the introduction of client writers, we check the body length in
the PROTOCOL phase and do FTP lineend conversions laster in the
CONTENT_DECODING phase. This means we no longer need to count the
conversions for length checks.

Closes #14709
2024-08-29 14:30:58 +02:00
Viktor Szakats
1b0568539d
cmake: fix internal variable names in Rustls detection
Follow-up to ed76a23fcc #14534

Closes #14719
2024-08-29 13:56:05 +02:00
Viktor Szakats
5b87b4edf9
test1013.pl: require case match for features, order match for protos, fix issue
Update the script for test 1013 and 1014 to require:

- case-sensitive match for the curl feature list.
  (Continue to allow case-difference for protocols. They've always been
  in uppercase within curl config.)

- matching order for the protocol list.
  (Continue to allow any order for features. autotools builds on
  platforms without `sort -f` need it. E.g. Old Linux CI)

Also:

- fix casing of the `gsasl` feature in `configure`, to match `curl -V`
  and cmake.

- delete obsolete comment.

Closes #14706
2024-08-29 13:56:05 +02:00
Viktor Szakats
a5682d9cb9
GHA/windows: vcpkg GnuTLS started breaking CI, temp drop it
Starting today vcpkg wants to rebuild GnuTLS but fails:
```
error: building shiftmedia-libgnutls:x64-windows failed with: BUILD_FAILED
```
Ref: https://github.com/curl/curl/actions/runs/10594890318/job/29359499149#step:5:144

Temporary solution:
- drop it from the MultiSSL job.
- replace with mbedTLS job. This job still tests libssh and I could
  not find a better place for it right away.

GnuTLS to be restored once it builds again. Possibly when this hash
reaches the GHA `windows-latest` runner:
f5ec6f30ff

Also:
- switch to Debug for the mbedTLS job. Should also work now with
  GnuTLS, once it's back:
  Ref: https://github.com/microsoft/vcpkg/pull/40473

Closes #14710
2024-08-28 17:51:25 +02:00
Daniel Stenberg
09cdcac8d8
RELEASE-NOTES: synced 2024-08-28 14:09:12 +02:00
Stefan Eissing
4c744c3ee2
tests/http: add HTTP/2 Upgrade and prior knowledge tests
Adds test cases to check that plain http: with HTTP/2 works
via 'Upgrade: h2c' or --http2-prior-knowledge'.

Also added tests to check connection reused in these situations.

Closes #14694
2024-08-28 14:04:11 +02:00
Stefan Eissing
9280bbea3f
urldata: remove proxy_connect_closed bit
The connections 'proxy_connect_closed' bit was not used any more. Remove
it.

Closes #14708
2024-08-28 14:00:42 +02:00
Stefan Eissing
80f9fce56d
cookie: add more debug tracing to set-cookie handling
Might help us see why test977 fails occasionally.

Closes #14705
2024-08-28 13:59:33 +02:00