Commit Graph

31442 Commits

Author SHA1 Message Date
Viktor Szakats
5839b8ae98
Makefile.mk: restore _mingw.h for default _WIN32_WINNT
In 8.4.0 we deleted `_mingw.h` as part of purging old-mingw support.
Turns out `_mingw.h` had the side-effect of setting a default
`_WIN32_WINNT` value expected by `lib/config-win32.h` to enable
`getaddrinfo` support in `Makefile.mk` mingw-w64 builds. This caused
disabling support for this unless specifying the value manually.

Restore this header and update its comment to tell why we continue
to need it.

This triggered a regression in official Windows curl builds starting
with 8.4.0_1. Fixed in 8.4.0_6. (8.5.0 will be using CMake.)

Regression from 38029101e2 #11625

Reported-by: zhengqwe on github
Helped-by: Nico Rieck
Fixes #12134
Fixes #12136
Closes #12217
2023-10-28 00:10:12 +00:00
Viktor Szakats
d14e11d248
hostip: silence compiler warning -Wparentheses-equality
Seen with LLVM 17.

```
hostip.c:1336:22: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
 1336 |        (a->ai_family == PF_INET)) {
      |         ~~~~~~~~~~~~~^~~~~~~~~~
hostip.c:1336:22: note: remove extraneous parentheses around the comparison to silence this warning
 1336 |        (a->ai_family == PF_INET)) {
      |        ~             ^         ~
hostip.c:1336:22: note: use '=' to turn this equality comparison into an assignment
 1336 |        (a->ai_family == PF_INET)) {
      |                      ^~
      |                      =
1 warning generated.
```

Follow-up to b651aba096 #12145

Reviewed-by: Daniel Stenberg
Closes #12215
2023-10-27 22:30:26 +00:00
Stefan Eissing
277486b6b4
doh: use PIPEWAIT when HTTP/2 is attempted
Closes #12214
2023-10-27 17:13:24 +02:00
Daniel Stenberg
2478cbbff2
setopt: remove outdated cookie comment
Closes #12206
2023-10-27 16:59:40 +02:00
Stefan Eissing
37b5cf4fa0
cfilter: provide call to tell connection to forget a socket
- fixed libssh.c workaround for a socket being closed by
  the library
- eliminate the terrible hack in cf-socket.c to guess when
  this happened and try not closing the socket again.
- fixes race in eyeballing when socket could have failed to
  be closed for a discarded connect attempt

Closes #12207
2023-10-27 16:59:13 +02:00
Stefan Eissing
39547ae64d
url: protocol handler lookup tidy-up
- rename lookup to what it does
- use ARRAYSIZE instead of NULL check for end
- offer alternate lookup for 0-terminated strings

Closes #12216
2023-10-27 16:55:54 +02:00
Viktor Szakats
a426b5050f
build: variadic macro tidy-ups
- delete unused `HAVE_VARIADIC_MACROS_C99/GCC` feature checks.
  (both autotools and CMake.)
- delete duplicate `NULL` check in `Curl_trc_cf_infof()`.
- fix compiler warning in `CURL_DISABLE_VERBOSE_STRINGS` builds.
  ```
  ./lib/cf-socket.c:122:41: warning: unused parameter 'data' [-Wunused-parameter]
  static void nosigpipe(struct Curl_easy *data,
                                          ^
  ```
- fix `#ifdef` comments in `lib/curl_trc.{c,h}`.
- fix indentation in some `infof()` calls.

Follow-up to dac293cfb7 #12167

Cherry-picked from #12105
Closes #12210
2023-10-27 00:37:34 +00:00
Viktor Szakats
191e695fe4
cmake: speed up threads setup for Windows
Win32 threads are always available. We enabled them unconditionally
(with `ENABLE_THREADED_RESOLVER`). CMake built-in thread detection
logic has this condition hard-coded for Windows as well (since at least
2007).

Instead of doing all the work of detecting pthread combinations on
Windows, then discarding those results, skip these efforts and assume
built-in thread support when building for Windows.

This saves 1-3 slow CMake configuration steps.

Reviewed-by: Daniel Stenberg
Closes #12202
2023-10-27 00:37:34 +00:00
Viktor Szakats
c5d506e9bb
cmake: speed up zstd detection
Before this patch we detected the presence of a specific zstd API to
see if we can use the library. zstd published that API in its first
stable release: v1.0.0 (2016-08-31).

Replace that method by detecting the zstd library version instead and
accepting if it's v1.0.0 or newer. Also display this detected version
and display a warning if the zstd found is unfit for curl.

We use the same version detection method as zstd itself, via its public
C header.

This deviates from autotools which keeps using the slow method of
looking for the API by building a test program. The outcome is the same
as long as zstd keeps offering this API.

Ref: 5a0c8e2439 (2016-08-12, committed)
Ref: https://github.com/facebook/zstd/releases/tag/v0.8.1 (2016-08-18, first released)
Ref: https://github.com/facebook/zstd/releases/tag/v1.0.0

Reviewed-by: Daniel Stenberg
Closes #12200
2023-10-27 00:37:34 +00:00
Daniel Stenberg
9ee6da65d8
openssl: fix infof() to avoid compiler warning for %s with null
vtls/openssl.c: In function ‘ossl_connect_step2’:
../lib/curl_trc.h:120:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  120 |          Curl_infof(data, __VA_ARGS__); } while(0)
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/openssl.c:4008:5: note: in expansion of macro ‘infof’
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |     ^~~~~
vtls/openssl.c:4008:49: note: format string is defined here
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |                                                 ^~

Follow-up to b6e6d4ff8f
Closes #12196
2023-10-26 17:43:38 +02:00
Stefan Eissing
dac293cfb7
lib: apache style infof and trace macros/functions
- test for a simplified C99 variadic check
- args to infof() in --disable-verbose are no longer disregarded but
  must compile.

Closes #12167
Fixes #12083
Fixes #11880
Fixes #11891
2023-10-26 17:42:54 +02:00
Daniel Stenberg
d1a7da6531
RELEASE-NOTES: synced 2023-10-26 17:33:25 +02:00
Stefan Eissing
56a4db2e4e
urldata: move async resolver state from easy handle to connectdata
- resolving is done for a connection, not for every transfer
- save create/dup/free of a cares channel for each transfer
- check values of setopt calls against a local channel if no
  connection has been attached yet, when needed.

Closes #12198
2023-10-26 17:29:17 +02:00
Daniel Stenberg
910f740ce2
CURLOPT_WRITEFUNCTION.3: clarify what libcurl returns for CURL_WRITEFUNC_ERROR
It returns CURLE_WRITE_ERROR. It was not previously stated clearly.

Reported-by: enWILLYado on github
Fixes #12201
Closes #12203
2023-10-26 17:08:25 +02:00
Viktor Szakats
6ec70a9dd3
autotools: update references to deleted crypt-auth option
Delete leftovers of the `crypt-auth` `./configure` option and
add the new ones that replaced them.

Follow-up to e92edfbef6 #11490

Reviewed-by: Daniel Stenberg
Closes #12194
2023-10-25 12:45:43 +00:00
Stefan Eissing
47f5b1a37f
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.

Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.

This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.

Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.

After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.

Example:

 * transfer wants to send, adds POLLOUT
 * http/2 filter has a flow control block, removes POLLOUT and adds
   POLLIN (it is waiting on a WINDOW_UPDATE from the server)
 * TLS filter is connected and changes nothing
 * h2-proxy filter also has a flow control block on its tunnel stream,
   removes POLLOUT and adds POLLIN also.
 * socket filter is connected and changes nothing
 * The resulting pollset is then mixed together with all other transfers
   and their pollsets, just as before.

Use of `SEND_HOLD` is no longer necessary in the filters.

All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.

The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.

No noticeable difference in performance was detected in local scorecard
runs.

Closes #11833
2023-10-25 09:34:32 +02:00
Daniel Stenberg
29e198bc71
tests/README: SOCKS tests are not using OpenSSH, it has its own server
Follow-up to 04fd67555c

Closes #12195
2023-10-25 09:30:30 +02:00
Jacob Hoffman-Andrews
5ecbe4df22
tets: make test documentation more user-friendly
Put the instructions to run tests right at the top of tests/README.md.

Give instructions to read the runtests.1 man page for information
about flags. Delete redundant copy of the flags documentation in the
README.

Add a mention in README.md of the important parallelism flag, to make
test runs go much faster.

Move documentation of output line format into the runtests.1 man page,
and update it with missing flags.

Fix the order of two flags in the man page.

Closes #12193
2023-10-25 07:54:54 +02:00
Viktor Szakats
2100d9fde2
cmake: pre-fill rest of detection values for Windows
The goal of this patch is to avoid unnecessary feature detection work
when doing Windows builds with CMake. Do this by pre-filling well-known
detection results for Windows and specifically for mingw-w64 and MSVC
compilers. Also limit feature checks to platforms where the results are
actually used. Drop a few redundant ones. And some tidying up.

- pre-fill remaining detection values in Windows CMake builds.

  Based on actual detection results observed in CI runs, preceding
  similar work over libssh2 and matching up values with
  `lib/config-win32.h`.

  This brings down CMake configuration time from 58 to 14 seconds on the
  same local machine.

  On AppVeyor CI this translates to:
  - 128 seconds -> 50 seconds VS2022 MSVC with OpenSSL (per CMake job):
    https://ci.appveyor.com/project/curlorg/curl/builds/48208419/job/4gw66ecrjpy7necb#L296
    https://ci.appveyor.com/project/curlorg/curl/builds/48217440/job/8m4fwrr2fe249uo8#L186
  - 62 seconds -> 16 seconds VS2017 MINGW (per CMake job):
    https://ci.appveyor.com/project/curlorg/curl/builds/48208419/job/s1y8q5ivlcs7ub29?fullLog=true#L290
    https://ci.appveyor.com/project/curlorg/curl/builds/48217440/job/pchpxyjsyc9kl13a?fullLog=true#L194

  The formula is about 1-3 seconds delay for each detection. Almost all
  of these trigger a full compile-link cycle behind the scenes, slow
  even today, both cross and native, mingw-w64 and apparently MSVC too.
  Enabling .map files or other custom build features slows it down
  further. (Similar is expected for autotools configure.)

- stop detecting `idn2.h` if idn2 was deselected.
  autotools does this.

- stop detecting `idn2.h` if idn2 was not found.
  This deviates from autotools. Source code requires both header and
  lib, so this is still correct, but faster.

- limit `ADDRESS_FAMILY` detection to Windows.

- normalize `HAVE_WIN32_WINNT` value to lowercase `0x0a12` format.

- pre-fill `HAVE_WIN32_WINNT`-dependent detection results.
  Saving 4 (slow) feature-detections in most builds: `getaddrinfo`,
  `freeaddrinfo`, `inet_ntop`, `inet_pton`

- fix pre-filled `HAVE_SYS_TIME_H`, `HAVE_SYS_PARAM_H`,
  `HAVE_GETTIMEOFDAY` for mingw-w64.
  Luckily this do not change build results, as `WIN32` took
  priority over `HAVE_GETTIMEOFDAY` with the current source
  code.

- limit `HAVE_CLOCK_GETTIME_MONOTONIC_RAW` and
  `HAVE_CLOCK_GETTIME_MONOTONIC` detections to non-Windows.
  We're not using these in the source code for Windows.

- reduce compiler warning noise in CMake internal logs:
  - fix to include `winsock2.h` before `windows.h`.
    Apply it to autotools test snippets too.
  - delete previous `-D_WINSOCKAPI_=` hack that aimed to fix the above.
  - cleanup `CMake/CurlTests.c` to emit less warnings.

- delete redundant `HAVE_MACRO_SIGSETJMP` feature check.
  It was the same check as `HAVE_SIGSETJMP`.

- delete 'experimental' marking from `CURL_USE_OPENSSL`.

- show CMake version via `CMakeLists.txt`.
  Credit to the `zlib-ng` project for the idea:
  61e181c8ae/CMakeLists.txt (L7)

- make `CMake/CurlTests.c` pass `checksrc`.

- `CMake/WindowsCache.cmake` tidy-ups.

- replace `WIN32` guard with `_WIN32` in `CMake/CurlTests.c`.

Closes #12044
2023-10-24 21:06:36 +00:00
Jay Satiro
7fdf30f256 page-footer: clarify exit code 25
- Clarify that curl tool exit code 25 means an upload failed to start.

Exit code 25 is equivalent to CURLE_UPLOAD_FAILED (25). Prior to this
change the documentation only mentioned the case of FTP STOR failing.

Reported-by: Emanuele Torre

Ref: https://github.com/curl/curl/blob/curl-8_4_0/docs/libcurl/libcurl-errors.3#L113-L115

Fixes https://github.com/curl/curl/issues/12189
Closes https://github.com/curl/curl/pull/12190
2023-10-24 03:51:28 -04:00
Daniel Stenberg
e8f9df6c2d
scripts/cijobs.pl: adjust for appveyor
Follow-up to a1d73a6bb
2023-10-24 09:25:19 +02:00
Alex Bozarth
b6e6d4ff8f
OpenSSL: Include SIG and KEM algorithms in verbose
Currently the verbose output does not include which algorithms are used
for the signature and key exchange when using OpenSSL. Including the
algorithms used will enable better debugging when working on using new
algorithm implementations. Know what algorithms are used has become more
important with the fast growing research into new quantum-safe
algorithms.

This implementation includes a build time check for the OpenSSL version
to use a new function that will be included in OpenSSL 3.2 that was
introduced in openssl/openssl@6866824

Based-on-patch-by: Martin Schmatz <mrt@zurich.ibm.com>
Closes #12030
2023-10-24 00:11:12 +02:00
Daniel Stenberg
19a82c12c0
http2: provide an error callback and failf the message
Getting nghttp2's error message helps users understand what's going
on. For example when the connection is brought down due a forbidden
header is used - as that header is then not displayed by curl itself.

Example:

  curl: (92) Invalid HTTP header field was received: frame type: 1,
  stream: 1, name: [upgrade], value: [h2,h2c]

Ref: #12172
Closes #12179
2023-10-23 12:34:12 +02:00
Turiiya
e17d8af21d
BINDINGS: add V binding
Closes #12182
2023-10-23 07:57:31 +02:00
Daniel Stenberg
f4ff410807
configure: check for the fseeko declaration too
... and make the code require both symbol and declaration.

This is because for Android, the symbol is always present in the lib at
build-time even when not actually available in run-time.

Assisted-by: Viktor Szakats
Reported-by: 12932 on github
Fixes #12086
Closes #12158
2023-10-22 20:20:49 +02:00
Viktor Szakats
514969db04
cmake: fix OpenSSL quic detection in quiche builds
An orphan call to `CheckQuicSupportInOpenSSL()` remained after a recent
update when checking QUIC for quiche. Move back QUIC detection to
a function and fixup callers to use that. Also make sure that quiche
gets QUIC from BoringSSL, because it doesn't support other forks at this
time.

Regression from dee310d542 #11555

Reported-by: Casey Bodley <cbodley@redhat.com>
Fixes #12160
Closes #12162
2023-10-22 10:54:45 +00:00
Daniel Stenberg
0bd9164b85
RELEASE-NOTES: synced
bump to 8.5.0 for pending release
2023-10-22 10:58:08 +02:00
Dan Fandrich
85be173cf0 test3103: add missing quotes around a test tag attribute 2023-10-21 11:26:40 -07:00
Loïc Yhuel
014ce7c0d0
tool: fix --capath when proxy support is disabled
After 95e8515ca0, --capath always sets CURLOPT_PROXY_CAPATH, which fails
with CURLE_UNKNOWN_OPTION when proxy support is disabled.

Closes #12089
2023-10-21 14:52:47 +02:00
Daniel Stenberg
526779a7ee
openldap: move the alloc of ldapconninfo to *connect()
Fixes a minor memory leak on LDAP connection reuse.

Doing the allocation already in *setup_connection() is wrong since that
connect struct might get discarded early when an existing connection is
reused instead.

Closes #12166
2023-10-21 14:42:30 +02:00
Daniel Stenberg
3afbe0603d
openldap: set the callback argument in oldap_do
... to make sure it has the current 'data' pointer and not a stale old
one.

Reported-by: Dan Fandrich
Closes #12166
2023-10-21 14:42:25 +02:00
Daniel Stenberg
9cf4759354
gnutls: support CURLSSLOPT_NATIVE_CA
Remove the CURL_CA_FALLBACK logic. That build option was added to allow
primarily OpenSSL to use the default paths for loading the CA certs. For
GnuTLS it was instead made to load the "system certs", which is
different and not desirable.

The native CA store loading is now asked for with this option.

Follow-up to 7b55279d1d

Co-authored-by: Jay Satiro

Closes #12137
2023-10-21 14:41:06 +02:00
Stefan Eissing
7eb31c852d
RTSP: improved RTP parser
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with #12035 and various small receive
  sizes where current master fails

Closes #12052
2023-10-21 14:38:21 +02:00
Stefan Eissing
117c9bd978
http2: header conversion tightening
- fold the code to convert dynhds to the nghttp2 structs
  into a dynhds internal method
- saves code duplication
- pacifies compiler analyzers

Closes #12097
2023-10-21 14:36:51 +02:00
Daniel Stenberg
f76fcd6f4d
curl_ntlm_wb: fix elif typo
Reported-by: Manfred Schwarb
Follow-up to d4314cdf65
Bug: d4314cdf65 (r130551295)
2023-10-21 10:29:02 +02:00
Dan Fandrich
31d96af8b5 test1683: remove commented-out check alternatives
Python precheck/postcheck alternatives were included but commented out.
Since these are not used and perl is guaranteed to be available to run
the perl versions anyway, the Python ones are removed.
2023-10-20 15:32:21 -07:00
Daniel Stenberg
b651aba096
hostip: show the list of IPs when resolving is done
Getting 'curl.se' today then gets this verbose output which might help
debugging connectivity related matters.

* Host curl.se:80 was resolved.
* IPv6: 2a04:4e42::347, 2a04:4e42:200::347, 2a04:4e42:400::347,
  2a04:4e42:600::347, 2a04:4e42:800::347, 2a04:4e42:a00::347,
  2a04:4e42:c00::347, 2a04:4e42:e00::347
* IPv4: 151.101.193.91, 151.101.1.91, 151.101.65.91, 151.101.129.91

Co-authored-by: Jay Satiro
Closes #12145
2023-10-20 23:00:10 +02:00
rilysh
276ffedec2
docs: fix function typo in curl_easy_option_next.3
Closes #12170
2023-10-20 22:57:47 +02:00
Daniel Stenberg
8d3ce930f8
vssh: remove the #ifdef for Curl_ssh_init, use empty macro
In the same style as other init calls
2023-10-20 22:56:01 +02:00
Daniel Stenberg
347cf02e9d
easy: remove duplicate wolfSSH init call
It is already done in Curl_ssh_init() where it belongs.

Closes #12168
2023-10-20 22:55:54 +02:00
Daniel Stenberg
24c495a52f
socks: make SOCKS5 use the CURLOPT_IPRESOLVE choice
Fixes #11949
Reported-by: Ammar Faizi
Closes #12163
2023-10-20 17:14:51 +02:00
Daniel Stenberg
fc077bc786
urldata: move the 'internal' boolean to the state struct
... where all the other state bits for the easy handles live.

Closes #12165
2023-10-20 16:59:52 +02:00
Daniel Stenberg
b0bee93dfe
url: don't touch the multi handle when closing internal handles
Reported-by: Maksymilian Arciemowicz
Closes #12165
2023-10-20 16:59:43 +02:00
Faraz Fallahi
d31a8424e8
getenv: PlayStation doesn't have getenv()
Closes #12140
2023-10-19 17:00:35 +02:00
Daniel Stenberg
df9aea22c2
transfer: only reset the FTP wildcard engine in CLEAR state
To avoid the state machine to start over and redownload all the files
*again*.

Reported-by: lkordos on github
Regression from 843b3baa3e (shipped in 8.1.0)
Bisect-by: Dan Fandrich
Fixes #11775
Closes #12156
2023-10-19 16:58:31 +02:00
Stefan Eissing
8cb95850c0
GHA: move mod_h2 version in CI to v2.0.25
Closes #12157
2023-10-19 16:51:59 +02:00
Daniel Stenberg
d4314cdf65
ntlm_wb: use pipe instead of socketpair when possible
Closes #12149
2023-10-19 10:20:12 +02:00
Daniel Stenberg
913eacf773
RELEASE-NOTES: synced 2023-10-18 09:22:07 +02:00
Daniel Stenberg
43eb798da0
asyn-thread: use pipe instead of socketpair for IPC when available
If pipe() is present. Less overhead.

Helped-by: Viktor Szakats
Closes #12146
2023-10-18 08:23:53 +02:00
Dan Fandrich
64936919b9 tests: Fix Windows test helper tool search & use it for handle64
The checkcmd() and checktestcmd() functions would not have worked on
Windows due to hard-coding the UNIX PATH separator character and not
adding .exe file extension. This meant that tools like stunnel, valgrind
and nghttpx would not have been found and used on Windows, and
inspection of previous test runs show none of those being found in pure
Windows CI builds.

With this fixed, they can be used to detect the handle64.exe program
before attempting to use it. When handle64.exe was called
unconditionally without it existing, it caused perl to abort the test
run with the error

    The running command stopped because the preference variable
    "ErrorActionPreference" or common parameter is set to Stop:
    sh: handle64.exe: command not found

Closes #12115
2023-10-17 12:27:21 -07:00