Commit Graph

34384 Commits

Author SHA1 Message Date
Viktor Szakats
3e552ef833
cmake/Find: add iphlpapi for c-ares, omit syslibs if dep not found
- add `iphlpapi` library for c-ares.
  Ref: 082d98ba6b

- fix to not add system libs if the dependency was not found.
  librtmp, Rustls, wolfSSL
  Follow-up to 421e592db2 #15832
  Follow-up to 7bab201abe #15193

Closes #16089
2025-01-26 01:52:47 +01:00
Daniel Stenberg
7f4f192f04
docs/HTTPSRR.md: initial HTTPS RR documentation
Closes #16052
2025-01-25 23:51:01 +01:00
Daniel Stenberg
0d4fdbf15d
asyn-thread: use c-ares to resolve HTTPS RR
Allow building with c-ares and yet use threaded resolver for the main
host A/AAAA resolving:

  `--with-ares` provides the c-ares install path and defaults to use
  c-ares for name resolving

  `--with-threaded-resolver` still uses c-ares in the build (for HTTPS)
  but uses the threaded resolver for "normal" resolves.

It works similarly for cmake: ENABLE_ARES enables ares, and if
ENABLE_THREADED_RESOLVER also is set, c-ares is used for HTTPS RR and
the threaded resolver for "normal" resolves.

HTTPSRR and c-ares-rr are new features return by curl_version_info() and
thus shown by curl -V.

The c-ares-rr feature bit is there to make it possible to distinguish
between builds using c-ares for all name resolves and builds that use
the threaded resolves for the regular name resolves and c-ares for
HTTPSRR only. "c-ares-rr" means it does not use c-ares for "plain" name
resolves.

HTTPSRR support is EXPERIMENTAL only.

Closes #16054
2025-01-25 23:46:14 +01:00
Viktor Szakats
520e67dd39
GHA/non-native: bump to NetBSD 10.1
Closes #16088
2025-01-25 23:03:24 +01:00
renovate[bot]
604cb65fbd
GHA/non-native: update cross-platform-actions/action action to v0.27.0
Closes #16071
2025-01-25 22:50:52 +01:00
Viktor Szakats
1bc83abfb7
cmake: drop CURL_USE_PKGCONFIG from curl-config.cmake.in
This variable was meant to be used by curl Find modules, but it turns
out it makes no sense to use those from `curl-config.cmake.in`. It means
this variable was not used before and will not be used in the future,
and therefore safe to delete.

Also add missing macros passed to `curl-config.cmake` to comment.

Ref: https://github.com/curl/curl/pull/14930#discussion_r1929537797

Closes #16087
2025-01-25 15:21:17 +01:00
renovate[bot]
49ece646c0
ci: update dependency cloudflare/quiche to v0.23.2
Closes #16082
2025-01-25 12:06:01 +01:00
Viktor Szakats
d8f1aa4b11
GHA/curl-for-win: fix DOCKER_CONTENT_TRUST for a job [ci skip]
Follow-up to 28230bec1f #15141
2025-01-25 00:42:54 +01:00
Daniel Stenberg
5426cd5948
content_encoding: put the decomp buffers into the writer structs
- no more malloc/free per chunk
- removes the extra malloc entirely
- make the buffer (much) smaller (10MB => 16KB!)
- rename 'decomp' to 'buffer' to clarify purpose

Closes #16079
2025-01-24 14:04:23 +01:00
Daniel Stenberg
76f83f0db2
content_encoding: drop support for zlib before 1.2.0.4
zlib 1.2.0.4 was released on 10 August 2003

Closes #16079
2025-01-24 14:04:23 +01:00
Stefan Eissing
1213c31272
lib: redirect handling by protocol handler
Adds a `follow()` callback to protocol handlers, so they may decide how
to act on a `newurl` after a request has been done. This is optional.

This moves the HTTP code for handling redirects from multi.c to http.c
where it should be. If we ever add a protocol with its own logic, it
would install its own follow function.

Closes #16075
2025-01-24 11:00:34 +01:00
Stefan Eissing
e83818cae1
lib: clarify 'conn->httpversion'
The variable `conn->httpversion` was used for several purposes and it
was unclear at which time the value represents what.

- rename `conn->httpversion` to `conn->httpversion_seen`
  This makes clear that the variable only records the last
  HTTP version seen on the connection - if any. And that it
  no longer is an indication of what version to use.
- Change Alt-Svc handling to no longer modify `conn->httpversion`
  but set `data->state.httpwant` for influencing the HTTP version
  to use on a transfer.
- Add `data->req.httpversion_sent` to have a record of what
  HTTP version was sent in a request
- Add connection filter type CF_TYPE_HTTP
- Add filter query `CF_QUERY_HTTP_VERSION` to ask what HTTP
  filter version is in place
- Lookup filters HTTP version instead of using `conn->httpversion`

Test test_12_05 now switches to HTTP/1.1 correctly and the
expectations have been fixed.

Removed the connection fitler "is_httpN()" checks and using
the version query instead.

Closes #16073
2025-01-24 10:59:02 +01:00
Viktor Szakats
7e814c8717
build: fix compiling with GCC 4.x versions
- silence false positive picky warnings.
- avoid "possible noreturn" warnings for standalone tests and examples.
- fix to compile without `#pragma GCC diagnostic push` support.
- fix "#pragma GCC diagnostic not allowed inside functions".

Prerequisite for #15975 that needs GCC 4.4 for the latest pre-built
CeGCC/mingw32ce toolchain for Windows CE.

Cherry-picked from #15975
Closes #16062
2025-01-22 11:26:15 +01:00
Viktor Szakats
96843f4ef7
src: omit hugehelp and ca-embed from libcurltool
CMake builds using the Xcode generator broke with an error saying it
doesn't support multiple targets depending on the same custom commands.
These custom commands are generating `tool_hugehelp.c` and
`tool_c_embed.c` for the curl tool and libcurltool.

`unit1394` and `unit1604` tests use libcurltool to test tool-specific
functions. They don't need hugehelp and ca-embed. It's thus safe to
disable and exclude them when compiling the sources for libcurltool.
Use the `UNITTESTS` macro to detect a libcurltool build within C.

After this patch these sources are solely used for building the curl
tool. Making the build compatible with the CMake Xcode generator.

Apply the change to autotools too to keep build systems synchronized.

Follow-up to 12a6de2f66 #16043
Closes #16068
2025-01-22 11:21:43 +01:00
Viktor Szakats
8dfd271c35
cmake: prefer dash-style MSVC options
They play better with Unixy shells. The compiler has been supporting
dash options since its early versions.

Also fix to detect warnings options passed in dash-style.

Closes #16063
2025-01-22 11:21:42 +01:00
Stefan Eissing
cd9107e012
cfilters: kill connection filter events attach+detach
Make transfer attach/detach to/from connections chepaer.

- the "attach" event was no longer implemented by any filter
- the "detach" did the same as the "done" event for the filters
  who still implemented it. It should be superfluous as the "done"
  must always happen.

Closes #16067
2025-01-22 08:28:38 +01:00
Daniel Stenberg
f5f8f2c892
RELEASE-NOTES: synced 2025-01-22 08:09:51 +01:00
Daniel Stenberg
7c2b325004
curl_multi_fdset: include the shutdown connections in the set
They were previously missing.

Follow-up from c9b95c0bb3

Fixes #15156
Reported-by: Christopher Dannemiller
Closes #16049
2025-01-22 07:55:31 +01:00
Neil Johari
c80715169c
content_encoding: support use of custom libzstd memory functions
If ZSTD_STATIC_LINKING_ONLY is defined.

This functionality was introduced in zstd v0.8.1 in 2016 here:
facebook/zstd@be6180c

Closes #16028
2025-01-21 23:37:03 +01:00
Viktor Szakats
5fd7bd4379
appveyor: bump to OpenSSL 3.4
Closes #16064
2025-01-21 12:42:33 +01:00
Yedaya Katsman
38ad3902bf
docs/TLS-SESSIONS: fix typo, the->they
Closes #16057
2025-01-21 09:23:26 +01:00
Jay Satiro
789c7f1b6c easy_lock: use Sleep(1) for thread yield on old Windows
- Prefer Sleep(1) over sched_yield() for pre-Vista thread yield.

On Windows sched_yield is often implemented as Sleep(0) which only
yields to threads of highest priority to current priority. However,
during libcurl initialization if there is thread contention then it's
possible that there is a wait for a different library or OS thread of
a lesser priority and then the yield is not effective during that time.
On the other hand Sleep(1) will wait the minimum time slice which is
usually like 15ms or more.

Prior to this change 2c4bfef removed sched_yield detection on Windows,
which effectively removed the yield in the spin lock, and therefore this
change restores the yield but in a different way.

For Windows Vista and later we use SRW locks and do not have this issue.

Ref: https://github.com/curl/curl/pull/16037#issuecomment-2600161764
Ref: https://devblogs.microsoft.com/oldnewthing/20051004-09/?p=33923

Closes https://github.com/curl/curl/pull/16048
2025-01-21 01:45:21 -05:00
Viktor Szakats
7c039292ad
GHA/non-native: fix TLS backend in Android job names
Also drop whitespaces/alignment.

Reported-by: Tal Regev

Follow-up to 12a6de2f66 #16043
2025-01-21 01:10:16 +01:00
Viktor Szakats
12a6de2f66
GHA: add iOS jobs with LibreSSL, enable dependencies for Android via vcpkg
iOS:

- add jobs with autotools, CMake, CMake Xcode generator.
  The Xcode generator is >10x slower than Unix Makefiles. Keep it
  because it's the one recommended by CMake and for having its own
  quirks we may want to know about.
- build, cache and use LibreSSL for these jobs.
  With workaround for an iOS build issue fixed in master.
- make Xcode generator work by explicitly disabling code signing.
- make tests and examples build with the Xcode generator by setting
  `-DMACOSX_BUNDLE_GUI_IDENTIFIER=se.curl`, to avoid
  "Bundle identifier is missing" errors.
- cmake: disable `CURL_USE_PKGCONFIG` by default for Apple device.
- cmake: add `stdc++` library for BoringSSL and AWS-LC, with
  `OPENSSL_USE_STATIC_LIBS=ON` set.
- cmake: add workaround for Xcode generator issue, where it cannot
  handle two targets depending on one custom command. A better fix may
  be dropping `tool_hugehelp.c` and `tool_ca_embed.c` from curltool
  library. For a future PR.

Android:

- add vcpkg to Android jobs, enable dependencies.
  Assisted-by: Tal Regev via #16045
- make vcpkg work with autotools.
- pass `--with-brotli` to autotools to detect the vcpkg-supplied brotli.
- enable BoringSSL for Android and add a job with it.
- silence 457 CMake configure warnings about the Android NDK CMake
  scripts targeting freshly deprecated CMake versions.

These were much more involved than imagined. Basically nothing works out
of the box, and when combined, everything becomes a unique edge case.
autotools builds were a much easier to make work than CMake ones.

Also:

- GHA/non-native: re-sync names to be shorter and more aligned with
  other workflows.
- GHA: add `persist-credentials: false` where missing.

Unresolved issues:

- `OPENSSL_ROOT_DIR` ignored/mis-used when pointing it to LibreSSL.
  CMake seems to prepend the sysroot to the passed absolute directory.
  Found no workaround.
- CMake when combined with Android, both the Google-recommended method
  and the built-in CMake method fail to provide a way to avoid
  `pkg-config` packages at system directories. Failed to find a knob
  that can remove `/usr/include` from the search path. The workaround is
  to disable zstd. (I enabled it by default in this release, maybe
  premature?: f2adb3b6d7 #15431)
  Disabling `pkg-config` doesn't work because vcpkg dependencies do not
  link without it.
- CMake's Xcode generator is slow because each `try_compile()` feature
  check springs a new CMake + Xcode project taking a long time to run,
  just to compile single-liner C files. A known issue, with no solution.
  `-DCMAKE_MACOSX_BUNDLE=OFF` did not help, limiting build types to
  a single one (e.g. `Debug`) also had no effect.
   make | Xcode | GHA run
  :---- | :---- | :--------------------------------------------------------------------
    16s | 2m57s | https://github.com/curl/curl/actions/runs/12866334102/job/35868712426
    23s | 4m13s | https://github.com/curl/curl/actions/runs/12868128013/job/35874212461
    16s | 3m39s | https://github.com/curl/curl/actions/runs/12859073531/job/35849041880
    14s | 2m23s | https://github.com/curl/curl/actions/runs/12858298423/job/35847201313
    15s | 2m36s | https://github.com/curl/curl/actions/runs/12858058492/job/35846669761
    19s | 3m19s | https://github.com/curl/curl/actions/runs/12868919430/job/35876601168

Closes #16043
2025-01-20 22:32:06 +01:00
Viktor Szakats
292d81ca54
windows: merge config-win32ce.h into config-win32.h
They were more or less the same, but each missed some things the other
had. Windows CE is a subset of Win32, make the headers reflect that and
avoid duplications.

Ref: #15975
Closes #16038
2025-01-20 22:32:06 +01:00
Viktor Szakats
2ff914432c
GHA: replace hard-coded home dir in cache path: with ~
Closes #16056
2025-01-20 18:28:55 +01:00
9cel
c5a736f2c9
docs: document the behavior of -- in the curl command line
Closes #16053
2025-01-20 14:27:05 +01:00
Daniel Stenberg
0f54bfd803
libcurl/opts: do not save files in dirs where attackers have access
libcurl cannot fully protect against attacks where an attacker has write
access to the same directory where it is directed to save files. This is
particularly sensitive if you save files using elevated privileges.

Previously only mentioned in VULN-DISCLOSURE-POLICY.md.

Highlighted-by: Donguk Kim

Closes #16051
2025-01-20 10:34:37 +01:00
Viktor Szakats
f1dbe68172
GHA: tidy up quotes, checkout order, silence Android/CMake warnings
- move checkout step right before use.
- quotes in yaml and bash.
- unfold single-line run commands.
- set `CMAKE_WARN_DEPRECATED=OFF` for CMake with Android NDK to avoid
  a wall of useless deprecation warnings hiding useful output.
  These warnings happen in 3rd-party scripts, and unfixable in curl.

Closes #16042
2025-01-19 15:03:16 +01:00
Viktor Szakats
08e2cceaf1
cmake: drop fseeko() pre-fill and check for Windows
To sync detection code with autotools.

Closes #16041
2025-01-19 15:03:16 +01:00
Daniel Stenberg
0ed36150b6
RELEASE-NOTES: synced 2025-01-19 11:55:02 +01:00
Daniel Stenberg
9ce0bed1ff
curl_multi_waitfds.md: tidy up the example
- remove typecast
- shorten comment

Closes #16050
2025-01-19 11:45:25 +01:00
Daniel Stenberg
8368249907
asyn-ares: initial HTTPS resolve support
Gets the ALPN list the same way DoH does. Needs c-ares 1.28.0 or later.

Thanks-to: Brad House

Closes #16039
2025-01-19 11:25:09 +01:00
Daniel Stenberg
ea76380299
mbedtls: prefix our feature defines with HAS_
Consistent naming helps.

Closes #16046
2025-01-19 11:23:22 +01:00
Jay Satiro
56998277f0 checksrc.bat: remove explicit SNPRINTF bypass
- Remove the command line argument passed to checksrc.pl that accepts
  SNPRINTF violations in docs/examples.

This is a follow-up to c445b742 which introduced a different management
of banned functions and removed the SNPRINTF rule in favor of banning
snprintf in lib. There's no longer a SNPRINTF warning to suppress.

Closes https://github.com/curl/curl/pull/16032
2025-01-19 03:24:31 -05:00
Viktor Szakats
38e7302ae4
cmake: do not store MINGW64_VERSION in cache
Follow-up to e49797abc2 #16022
Closes #16040
2025-01-18 00:18:12 +01:00
Viktor Szakats
2c4bfefe91
build: stop detecting sched_yield() on Windows
On Windows a successful `sched_yield()` detection requires mingw-w64
built with POSIX threads (not Win32 threads) and GCC (not llvm/clang).
(linking to `winpthread` via custom options may also work.)

In CMake builds, it was pre-cached as unavailable before this patch.

When detected (via autotools), it got only used for Windows XP or older
targets combined with a non-GCC, non-clang compiler that doesn't support
`__builtin_ia32_pause()`, or with the Intel C compiler. According to
`lib/easy_lock.h`.

mingw-w64 only supports GCC and clang, leaving a very narrow chance when
`shed_yield()` gets called on Windows. Even then, `sched_yield()` is
implemented in `winpthread` as `Sleep(0)`, which may or not be a useful.
It's also trivial to implement locally if it is, and such rare build
combination is also deemed useful.

Thus, this patch marks `sched_yields()` permanently unavailable on the
Windows platform also with autotools, and instead of pre-caching, skip
this feature check with CMake.

This syncs `HAVE_SCHED_YIELDS` between builds methods on Windows.

Follow-up to 9b517c8b69 #11973
Follow-up to 23af112f55 #8680

Closes #16037
2025-01-17 23:31:58 +01:00
Viktor Szakats
e49797abc2
cmake: detect mingw-w64 version, pre-fill HAVE_STRTOK_R
Replace `strtok_r()` detection with detection mingw-w64 version.
The use this version to pre-fill `HAVE_STRTOK_R`.

This gives use mingw-w64 version information for free.

Closes #16022
2025-01-17 23:31:57 +01:00
Viktor Szakats
d5fb2b29d5
cmake: pre-fill HAVE_STDATOMIC_H, HAVE_ATOMIC for mingw-w64
`stdatomic.h` and `_Atomic` were first available in gcc 4.9.0 and
llvm/clang 3.6. Set detection values accordingly and save these two
detections on configure runs.

Closes #16036
2025-01-17 15:11:22 +01:00
Stefan Eissing
25b445e479
TLS: check connection for SSL use, not handler
Protocol handler option PROTOPT_SSL is used to setup a connection
filters. Once that is done, used `Curl_conn_is_ssl()` to check if
a connection uses SSL.

There may be other reasons to add SSL to a connection, e.g. starttls.

Closes #16034
2025-01-17 14:04:20 +01:00
Stefan Eissing
ef3d7877d5
pytest: remove 'repeat' parameter
With the use of the pytest-repeat plugin, this parameter is no
longer necessary.

Closes #16033
2025-01-17 14:03:30 +01:00
Viktor Szakats
2e2c6b0b4e
windows: drop dupe macros, detect CURL_OS for WinCE ARM, indentation
- setup-win32: drop duplicate `WIN32_LEAN_AND_MEAN` and `NOGDI` macros
  (set earlier in `curl_setup.h`)

- config-win32ce: detect ARM for `CURL_OS` macro.
  Based on: https://cegcc.sourceforge.net/docs/details.html
  It should also apply to MSVC. (untested)

- indentation.

Closes #16029
2025-01-17 12:56:43 +01:00
Viktor Szakats
587ce6586c
GHA: update ubuntu-24.04 to ubuntu-latest
`ubuntu-latest` is an alias for `ubuntu-24.04` now.
2025-01-17 04:34:05 +01:00
Viktor Szakats
1f789c5be1
configure: do not inline 'dnl' comments [ci skip]
(Did not cause issues in this particular case.)

Follow-up to a1184525a6 #15971
2025-01-17 02:38:10 +01:00
Viktor Szakats
140790d74d
configure: UWP and Android follow-up fixes
- limit UWP detection to native Windows.
- add missing double-quotes to variable.
- drop interlock and sync order in buildinfo flags.

Follow-up to 56a74fac47 #16014
Follow-up to f7bb6c1f64 #16020

Closes #16027
2025-01-17 01:50:27 +01:00
Viktor Szakats
56a74fac47
android: add CI jobs, buildinfo, cmake docs, disable CURL_USE_PKGCONFIG by default
- GHA/non-native: add Android builds, both cmake and autotools,
  both NDK 21 (oldest available) and 35 (newest available)
  https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
  It comes with a maintenance burden to bump the oldest/latest values
  with CI runner updates.

- cmake: disable `CURL_USE_PKGCONFIG` by default for Android.
  To avoid picking up system package by default.

- build: add `ANDROID-<NDK-LEVEL>` flag to `buildinfo.txt`.
  Also detect NDK level with the CMake built-in build method:
  https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android

- INSTALL.md: add CMake build instructions for Android.

- INSTALL.md: make NDK levels consistent in `./configure` example.

Closes #16014
2025-01-17 00:44:11 +01:00
Viktor Szakats
911f003db8
GHA: start using ARM Linux runners
- GHA/linux: allow per-job runner image override.
- GHA/linux: add an arm version of an existing job.
  Add workaround for broken `PATH` in the arm runner image.
- GHA/non-native: add CPU arch to job name where missing.
- GHA/checkdocs: switch a linter job to arm.

Performance looks a little bit better than Intel
(presumably with lower power consumption).

Test jobs, with openssl, tests, pytests, examples:
- arm:
  - https://github.com/curl/curl/actions/runs/12816430794/job/35737374521 4m7s
  - https://github.com/curl/curl/actions/runs/12816201136/job/35736615144 4m5s
- Intel:
  - https://github.com/curl/curl/actions/runs/12816430794/job/35737374118 4m32s
  - https://github.com/curl/curl/actions/runs/12816201136/job/35736614764 4m13s

Ref: https://github.blog/changelog/2025-01-16-linux-arm64-hosted-runners-now-available-for-free-in-public-repositories-public-preview/

Closes #16023
2025-01-17 00:28:12 +01:00
Viktor Szakats
c89bc11267
GHA/linux: enable wolfSSH in a wolfSSL job
With tests. (Most SFTP tests fail with wolfSSH.)

Also:
- disable pseudo-terminal in wolfSSH builds (also in CircleCI).
  Not needed for curl.
- test642: add "compressed" to the description.
  To avoid being the same as test600.
  Follow-up to b7b4dc0d49 #1735

Closes #16025
2025-01-17 00:20:54 +01:00
Stefan Eissing
02edae54e8 websocket: fix message send corruption
- Fix a bug in EAGAIN handling when sending frames that led to a
  corrupted last byte of the frame sent.

- Restore sanity to curl_ws_send() behaviour:

  - Partial writes are reported as OK with the actual number of
    payload bytes sent.

  - CURLE_AGAIN is only returned when none of the payload bytes
    (or for 0-length frames, not all of the frame header bytes)
    could be sent.

  - curl_ws_send() now behaves like a common send() call.

- Change 'ws-data' test client to allow concurrent send/recv
  operations and vary frame sizes and repeat count.

- Add DEBUG env var CURL_WS_CHUNK_EAGAIN to simulate blocking
  after a chunk of an encoded websocket frame has been sent.

- Add tests.


Prior to this change data corruption may occur when sending websocket
messages due to two bugs:

1) 3e64569a (precedes 8.10.0) caused a data corruption bug in the last
   byte of frame of large messages.

2) curl_ws_send had non-traditional send behavior and could return
   CURLE_AGAIN with bytes sent and expect the caller to adjust buffer
   and buflen in a subsequent call. That behavior was not documented.


Reported-by: na-trium-144@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/15865
Fixes https://github.com/curl/curl/issues/15865#issuecomment-2569870144
Closes https://github.com/curl/curl/pull/15901
2025-01-16 16:19:07 -05:00
Daniel Stenberg
86f5653721
TODO: write an SMB test server to replace impacket
Closes #15697
Closes #16024
2025-01-16 20:51:00 +01:00