Commit Graph

33543 Commits

Author SHA1 Message Date
Daniel Stenberg
9bee39bfed
url: use same credentials on redirect
Previously it could lose the username and only use the password.

Added test 998 and 999 to verify.

Reported-by: Tobias Bora
Fixes #15262
Closes #15282
2024-10-13 23:18:42 +02:00
Daniel Stenberg
eb77297ccc
lib: move curl_path.[ch] into vssh/
As this contains code only used by SSH backends.

Closes #15284
2024-10-13 23:16:18 +02:00
Stefan Eissing
a7ccd02614
ftp: move listen handling to socket filter
Move the listen/accept handling of the FTP active data connection
into the socket filter and monitor 'connected' status of that as
with passive connections - more or less.

The advantage is that the socket filter now reports being connected
only when the server has actually called and accept() has been done.
This enables to bootstrap the filter chain on the data connection
just like any other. A require SSL filter can then be added right
at the start and does not need to be patched in later.

Still, the active connection keeps on needing special handling in
ftp.c as the control connection needs to be monitored while waiting
as the server might send error responses this way. So, things did
not turn out quite as squeaky clean as hoped for, but still seems
better to do that way.

Closes #14798
2024-10-13 23:15:28 +02:00
Stefan Eissing
3455d360ce
mbedTLS: fix handling of TLSv1.3 sessions
For TLSv1.3, if supported, observer special return code to retrieve
newly arrived session from mbedTLS.

Adjust test expectations now that TLSv1.3 session resumption works in
mbedTLS >= 3.6.0.

Based on #14135 by @ad-chaos
Closes #15245
2024-10-13 23:13:04 +02:00
Stefan Eissing
513904c264
wolfSSL: fix handling of TLSv1.3 sessions
Register a callback to get notified of new SSL sessions by wolfSSL.
Remove the explicit session retrieval after handshake, since this does
not work for TLSv1.3.

Adjust test expectations now that TLSv1.3 session resumption works
in wolfSSL.

Closes #15243
2024-10-13 23:11:39 +02:00
Stefan Eissing
aa43b42461
curl-rustls.m4: set linker flags to allow rustls build on macos
Assisted-by: Viktor Szakats
Closes #15175
2024-10-13 23:10:45 +02:00
Viktor Szakats
960521d210
smb: do not redefine getpid on Windows
Replace with namespaced local macro `Curl_getpid()`.

Redefining symbols can backfire if that symbol is used in system
headers, especially with unity build. We haven't seen a fallout in CI
or supported envs, but do it anyway for good measure.

Bug report: https://datagirl.xyz/posts/wolfssl_curl_w2k.html
Closes #15263
2024-10-13 18:01:51 +02:00
Viktor Szakats
e8a007de0d
GHA: optimize test prereq steps
- Linux: move test and pytest prereqs right before test run.
  - returns build phase results faster.
  - allows skipping steps for jobs that don't need them.
  - makes dependencies more transparent.
- sync prereq install step names.
- use `tests/requirements.txt` more.

Closes #15275
2024-10-13 11:34:59 +02:00
Viktor Szakats
75dfb7b649
pytest: include buildinfo.txt in the output
If present.

It aims to provide TextClutch the same build information that
`runtests.pl` already is providing.

Ref: https://testclutch.curl.se/static/reports/feature-matrix.html
Ref: #15256
Follow-up to 1fdea16846 #14802
Closes #15279
2024-10-13 11:34:26 +02:00
Tal Regev
66cc015756
GHA/windows: drop vcpkg workaround
Reverts 841f42150a #15133
Closes #15217
2024-10-12 22:47:31 +02:00
Viktor Szakats
01a8157997
cmake: tidy-ups and rebase fixups
- limit `SIZEOF_SA_FAMILY_T` detection to non-Windows.
- make sure `sys/socket.h` exists before detecting `SIZEOF_SA_FAMILY_T`.
- limit `mach_absolute_time()` detection to `APPLE`. Drop from Windows
  pre-cache.
- skip `HAVE_LIBSOCKET` detection for Windows, drop pre-cached value.
- drop redundant pre-cached `HAVE_LIBZ` for Windows.
- `curl_required_libpaths()`: stop accepting multiple arguments.
  To prepare for `CMAKE_REQUIRED_LINK_DIRECTORIES` support.
  Follow-up to 7bab201abe #15193
- GSS: fix recent rebase mistakes:
  - fix variable name.
  - do not add a header twice.
  Follow-up to 91d451b488 #15157
- GSS: quote a variable.

Closes #15271
2024-10-12 22:33:29 +02:00
Dan Fandrich
a3601cf571 tests: allow pytests to run in out-of-tree builds
Some of the files it needs are in the build directory but the code did
not make a distinction.

Closes #15257
2024-10-12 10:47:57 -07:00
Viktor Szakats
79809ffe1e
GHA/linux: mbedTLS 3.6.1
Closes #15274
2024-10-12 08:58:19 +02:00
renovate[bot]
ba68eb02fa
CI: update rojopolis/spellcheck, actions/checkout, actions/upload-artifact
- update rojopolis/spellcheck-github-actions digest to 7ff888c
- update actions/checkout digest to eef6144
- update actions/upload-artifact digest to b4b15b8

Closes #15207
Closes #15184
Closes #15187
2024-10-11 23:53:42 +02:00
dependabot[bot]
7d53a59292
CI: bump github/codeql-action, vmactions/omnios-vm and actions/cache
- bump github/codeql-action from 3.26.10 to 3.26.11
- bump vmactions/omnios-vm from 1.0.7 to 1.0.8
- bump actions/cache from 4.0.2 to 4.1.1

Closes #15178
Closes #15179
Closes #15244
2024-10-11 23:44:19 +02:00
Stefan Eissing
fe8399f066
gnutls: use session cache for QUIC
Add session reuse for QUIC transfers using GnuTLS. This does not include
support for TLS early data, yet.

Fix check of early data support in common GnuTLS init code to not access
the filter context, as the struct varies between TCP and QUIC
connections.

Closes #15265
2024-10-11 23:37:47 +02:00
Dan Fandrich
954177b9da tool_xattr: create the user.creator xattr attribute
This indicates that the file was created by curl which can help a user
determine the origin of a file. Like the other attributes, this is only
enabled with the --xattr option.

Closes #15237
2024-10-11 10:13:37 -07:00
Viktor Szakats
dfd36d3ee0
cmake: apply WIN32_LEAN_AND_MEAN to all feature checks
Enable `WIN32_LEAN_AND_MEAN` for all feature detections on Windows.

(Also drop it from individual detections.)

Cherry-picked from #15164
2024-10-11 17:57:03 +02:00
Viktor Szakats
8e34505776
cmake: untangle feature detection interdependencies
- reduce `check_include_file_concat()` use to those headers that either
  depend on a previously detected header, or another header or symbol
  detection depend on it.

- replace `check_symbol_exists()` with `check_function_exists()` for
  functions that are detected with `AC_CHECK_FUNCS()` in `./configure`.
  This makes `setmode()` no longer be detected with MSYS, syncing
  this with `./configure`. Instead `_setmode()` is used now also in
  CMake MSYS builds. This is consistent with Cygwin builds also.

- add comment about which header/symbol detection depends on what
  header. Based on `./configure` mainly.

- form `CURL_TEST_DEFINES` manually, and include only those macros which
  are actually used in `CMake/CurlTests.c`.

- change `curl_internal_test()` to use `CMAKE_REQUIRED_DEFINITIONS`,
  instead of `CMAKE_REQUIRED_FLAGS` to simplify the logic, and to allow
  dropping the latter macro completely.

- drop `windows.h` from header and symbol checks.

- `./configure`: add comment about whether `netinet/in6.h`, `sys/un.h`
  are indeed meant to be included for all detections. There is a chance
  they were added there by accident.

Detection resuls were cross-checked between
436bbbe7ab (master) and
48ff4694e608ccfdedf7ce5bab2b96d6b2c23cda (this PR), for CI GHA Linux,
Linux HTTP/3, non-native, macOS and Windows jobs.

Closes #15164
2024-10-11 17:44:45 +02:00
Viktor Szakats
7bff686476
ci: dump curl_config.h to log in all jobs
Also:
- GHA/windows: merge full and brief dump into a single job step.
- fix shellcheck warning 'useless cat'.

Closes #15266
2024-10-11 15:01:29 +02:00
Daniel Stenberg
617feb7c93
RELEASE-NOTES: synced 2024-10-11 14:52:41 +02:00
Daniel Stenberg
0095f98464
libssh2: split the statemachine function into smaller sub functions
A giant function is hard to read.

Closes #15250
2024-10-11 14:43:16 +02:00
Daniel Stenberg
3b43a05e00
netrc: cache the netrc file in memory
So that on redirects etc it does not reread the file but just parses it
again.

Reported-by: Pierre-Etienne Meunier
Fixes #15248
Closes #15259
2024-10-11 14:40:12 +02:00
Stefan Eissing
962097b8dd
TLS: TLSv1.3 earlydata support for curl
Based on #14135, implement TLSv1.3 earlydata support for the curl
command line, libcurl and its implementation in GnuTLS.

If a known TLS session announces early data support, and the feature is
enabled *and* it is not a "connect-only" transfer, delay the TLS
handshake until the first request is being sent.

- Add --tls-earldata as new boolean command line option for curl.
- Add CURLSSLOPT_EARLYDATA to libcurl to enable use of the feature.
- Add CURLINFO_EARLYDATA_SENT_T to libcurl, reporting the amount of
  bytes sent and accepted/rejected by the server.

Implementation details:
- store the ALPN protocol selected at the SSL session.
- When reusing the session and enabling earlydata, use exactly
  that ALPN protocol for negoptiation with the server. When the
  sessions ALPN does not match the connections ALPN, earlydata
  will not be enabled.
- Check that the server selected the correct ALPN protocol for
  an earlydata connect. If the server does not confirm or reports
  something different, the connect fails.
- HTTP/2: delay sending the initial SETTINGS frames during connect,
  if not connect-only.

Verification:
- add test_02_32 to verify earlydata GET with nghttpx.
- add test_07_70 to verify earlydata PUT with nghttpx.
- add support in 'hx-download', 'hx-upload' clients for the feature

Assisted-by: ad-chaos on github
Closes #15211
2024-10-11 12:28:22 +02:00
Daniel Stenberg
d0377f5a86
multi: convert Curl_follow to static multi_follow
Moved over from transfer.c because it is only used in multi.c

Closes #15260
2024-10-11 12:26:36 +02:00
Daniel Stenberg
be39ed19a5
cookie: overhaul and cleanup
- split the huge Curl_cookie_add() into several smaller static functions

- switch to using the common llist instead of custom linked list

- use less memory for *getlist()

- use bitfields for flags in the Cookie struct

- avoid the copy for date parsing

- more consistent variable naming

Closes #15247
2024-10-11 09:01:03 +02:00
Viktor Szakats
91d451b488
cmake: replace check_include_file_concat() for LDAP and GSS detection
Replace `check_include_file_concat()` with `check_include_file()` in
GSS/LDAP detection to avoid these headers spilling into subsequent
feature checks.

- For LDAP, reverse detection order to match with `./configure`.
  Though, in current LDAP packages `ldap.h` does include `lber.h`.

- For GSS, align header detection logic with `./configure`, where
  `gssapi/gssapi_generic.h` might require `gssapi/gssapi.h`, and
  `gssapi/gssapi_krb5.h` might require both.

Ref: #436
Closes #15157
2024-10-10 22:50:44 +02:00
Viktor Szakats
2c90f7f69e
cmake: allow manual configuration for LDAP
Via these configuration values:
- `LDAP_LIBRARY`
- `LDAP_LBER_LIBRARY`
- `LDAP_INCLUDE_DIR`

Following the naming scheme used in `Find` modules.

Cherry-picked from #15157
Closes #15255
2024-10-10 22:48:20 +02:00
Viktor Szakats
6074e33509
cmake: add comments to feature check options applied globally
Add comments saying when we want values set in feature check option
variables to apply to all feature checks, globally. These are currently:
`ws2_32` and `socket` libraries, and `-D_WIN32_WINNT=` macro.

Also use `list(APPEND ...)` for the libraries to avoid overwriting
potentially existing values.

Cherry-picked from #15157
Closes #15253
2024-10-10 19:36:04 +02:00
Viktor Szakats
447bcea5a4
cmake: stop adding dependency headers to global CMAKE_REQUIRED_INCLUDES
It was done for `zlib`, `brotli`, `libpsl`, `libssh2`, `wolfssh`
(a copy-paste case for `wolfssh`).

Feature detections should not rely by default on dependency headers.
There is no evidence they do now. If it becomes necessary, headers
should added for the duration of the feature check.

Ref: 118977f19d
Cherry-picked from #15157
Closes #15252
2024-10-10 19:36:02 +02:00
Viktor Szakats
91519bfb74
cmake: use cmake_push_check_state() around feature checks
Enclose
`CMAKE_EXTRA_INCLUDE_FILES`,
`CMAKE_REQUIRED_DEFINITIONS`,
`CMAKE_REQUIRED_FLAGS`,
`CMAKE_REQUIRED_INCLUDES`,
`CMAKE_REQUIRED_LIBRARIES`,
`CMAKE_REQUIRED_LINK_OPTIONS`,
settings within `cmake_push_check_state()`/`cmake_pop_check_state()`
calls. It prevents spilling them into other feature checks. It also
replaces manual resets found in some places (which can have
the undesired side-effect of destroying values meant for global use.)

Cherry-picked from #15157
Closes #15251
2024-10-10 19:35:58 +02:00
Viktor Szakats
ae5e538e57
GHA: drop --parallel option for CMake + Ninja jobs
It's managed by Ninja automatically.

Closes #15249
2024-10-10 19:35:57 +02:00
Viktor Szakats
7bab201abe
cmake: add native pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL
Also:
- detect and add required system libraries for Rustls on macOS and
  non-Windows.
- add Linux CMake jobs for the touched dependencies.
  Caveats:
  - MSH3 generates a broken `libmsh3.pc`, so needs manual config.
    Upstream PR: https://github.com/nibanks/msh3/pull/225
  - Rustls `.pc` file missing, so needs manual config.

An internal change worthy of mention is that we are using the lib path
and name information returned by `pkg-config` as-is. Meaning the libname
doesn't include the full path, like it's usual with native cmake
detection. The path comes separately and needs to be rolled separately.
For this we add it to targets via `link_directories()`. We also keep tab
of them in `CURL_LIBDIRS` and use that in `libcurl.pc`. Feature checks
also need to receive these paths. CMake doesn't offer
a `CMAKE_REQUIRED_*` variable for this purpose, only
a `CMAKE_REQUIRED_LINK_OPTIONS` accepting raw linker flags. Add a macro
to convert a list of paths to linker options to solve it. wolfSSL
requires this for now.

Closes #15193
2024-10-10 14:45:09 +02:00
Viktor Szakats
ae5351696f
cmake: tidy up detection C code
Closes #15195
2024-10-10 14:29:35 +02:00
Viktor Szakats
436bbbe7ab
GHA/linux: skip installing rust if rustls is in cache
Rust remains installed for the Hyper job, because the rustls cache flag
is always false in that case.

Closes #15246
2024-10-10 13:15:26 +02:00
Viktor Szakats
36bd807475
GHA/linux, http3-linux: add CMake support, sync steps, other improvements
- use shallow clone for submodules.
- reduce total job timeout from 90/60 -> 45 minutes.
- use `$HOME` instead of literal.
- http3-linux: sync step yaml order with linux.yml.
- http3-linux: add cmake + ninja support like in linux.yml.
- http3-linux: dump confgure log, test config, curl -V like in linux.yml.
- http3-linux: skip restoring gnutls and wolfssl when not used.
- dump `curl_config.h`.
- fold a long line.

Closes #15242
2024-10-10 12:16:42 +02:00
Viktor Szakats
5b2d6448bb
GHA/mac: simplify detecting SDK version bound to GCC
Previous method extracted this information from the "hack layer"
headers' copyright comments.

It turns out that the same information can be obtained by querying
the default SDK root via a GCC option.

According to this test run, they do match:
https://github.com/curl/curl/actions/runs/11264283159/job/31323963221?pr=15193

Closes #15241
2024-10-10 11:18:07 +02:00
Viktor Szakats
d3725f2bc4
GHA/linux: fix mbedTLS cmake build
CMake builds mbedTLS in Debug mode by default, which was the reason
for these consistent test failures:
```
FAIL 1631: 'FTP through HTTPS-proxy' FTP, HTTPS-proxy
FAIL 1632: 'FTP through HTTPS-proxy, with connection reuse' FTP, HTTPS-proxy
```
Sometimes also:
```
FAIL 303: 'HTTPS with 8 secs timeout' HTTPS, HTTP GET, timeout, FAILURE
```
https://github.com/curl/curl/actions/runs/11260616621/job/31313234198

Fix it by building in `RelWithDebInfo` mode, matching the bare
`Makefile` builds used earlier. (`Release` mode also works.)

Cache sizes:
- Makefile: 10MB
- CMake Release: 1MB
- CMake RelWithDebInfo: 2.5MB

Ref: #15215
Follow-up to e377c91766 #15208

Closes #15238
2024-10-10 10:54:15 +02:00
Daniel Stenberg
8c62479a77
packages/OS400/curlmain: remove the strncpy calls
Closes #15214
2024-10-10 07:47:41 +02:00
Daniel Stenberg
45b388fdc7
tests/server/util.c: remove use of strncpy
... and ban the function in code in this directory.

Closes #15213
2024-10-10 07:47:01 +02:00
Daniel Stenberg
08949637d5
tool_getparam: replace two uses of strncpy(), ban strncpy
strncpy() is rarely the right choice

Closes #15212
2024-10-09 23:43:24 +02:00
Daniel Stenberg
5ee43bb82e
tests: 780 - 783, new HSTS tests
test780: verify updated HSTS data in response header

test781: HSTS update expiry, with parent includeSubDomains domain
present

test782: HSTS update expiry, with two includeSubDomains domains present

test783: HSTS update expiry, removing includesubdomains in update
2024-10-09 13:48:14 +02:00
Daniel Stenberg
a94973805d
hsts: improve subdomain handling
- on load, only replace existing HSTS entries if there is a full host
  match

- on matching, prefer a full host match and secondary the longest tail
  subdomain match

Closes #15210
2024-10-09 13:48:08 +02:00
Emanuel Komínek
461ce6c616
multi: make curl_multi_cleanup invalidate magic latter
When a multi handle is being cleaned up, it can still cause user
callbacks to be fired. Notably Curl_cpool_destroy calls socket_callback
on all pooled connections. It's still possible for the callback to call
curl_multi_assign leading to an assert.

This commit moves clearing of a multi handle magic to a point where the
multi handle stops being a valid object.

Fixes #15201
Closes #15206
2024-10-09 07:55:21 +02:00
Colton Willey
0f7e72fbcc
wolfssl: use old version API without openssl extra
Closes #15205
2024-10-09 07:53:45 +02:00
Viktor Szakats
e377c91766
GHA: add Linux and macOS mbedTLS jobs, fix issue
- update mbedTLS repo URL.
- switch local mbedTLS build to use CMake, and Ninja.
  CMake build is required to create and install mbedTLS `pkg-config`
  files. (as of v3.6.1)
  `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` required to avoid this error
  when linking mbedtls to `libcurl.so`:
  ```
  /usr/bin/ld: /home/runner/mbedtls/lib/libmbedcrypto.a(cipher.c.o): warning: relocation against `mbedtls_cipher_base_lookup_table' in read-only section `.text'
  /usr/bin/ld: /home/runner/mbedtls/lib/libmbedtls.a(ssl_tls.c.o): relocation R_X86_64_PC32 against symbol `mbedtls_x509_crt_profile_suiteb' can not be used when making a shared object; recompile with -fPIC
  /usr/bin/ld: final link failed: bad value
  ```
  Ref: https://github.com/curl/curl/actions/runs/11245069259/job/31264386723#step:40:43
- make local mbedTLS build 10x smaller by omitting programs and tests.
- GHA/linux: fix cmake warning by adding `-B .` option.
- GHA/linux: add build-only cmake job for packaged mbedTLS (2.x).
- fix compiler warning when building with mbedTLS 2.x:
  ```
  /home/runner/work/curl/curl/lib/vtls/mbedtls.c:344:1: error: ‘mbed_cipher_suite_get_str’ defined but not used [-Werror=unused-function]
    344 | mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size,
        | ^~~~~~~~~~~~~~~~~~~~~~~~~
  ```
  Ref: https://github.com/curl/curl/actions/runs/11244999065/job/31264168295#step:40:50

Also in preparation for #15193
Closes #15208
2024-10-09 02:46:01 +02:00
Viktor Szakats
b941d16d52
GHA/windows: drop vcpkg shiftmedia-gnutls, replace with mbedtls
GnuTLS vcpkg package broken again with the latest runner image update:
https://github.com/curl/curl/actions/runs/11240011311/job/31248406051?pr=15203#step:5:137

Previous breakage: 09b21e4755 #14864
Closes #15204
2024-10-08 22:19:28 +02:00
Dan Fandrich
6268caee83 INSTALL.md: fix a typo that slipped in to RISC OS
Also, illumos is spelled with lower case.
2024-10-08 09:57:05 -07:00
Daniel Stenberg
ee68b8db83
RELEASE-NOTES: synced 2024-10-08 16:50:57 +02:00
Sebastian Walz
adca93b53c
json.md: cli-option --json is an alias of --data-binary
Closes #15197
2024-10-08 16:15:06 +02:00