]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
21 months agolib: apache style infof and trace macros/functions
Stefan Eissing [Fri, 20 Oct 2023 11:11:34 +0000 (13:11 +0200)] 
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

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Thu, 26 Oct 2023 15:33:25 +0000 (17:33 +0200)] 
RELEASE-NOTES: synced

21 months agourldata: move async resolver state from easy handle to connectdata
Stefan Eissing [Wed, 25 Oct 2023 10:31:34 +0000 (12:31 +0200)] 
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

21 months agoCURLOPT_WRITEFUNCTION.3: clarify what libcurl returns for CURL_WRITEFUNC_ERROR
Daniel Stenberg [Thu, 26 Oct 2023 12:03:47 +0000 (14:03 +0200)] 
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

21 months agoautotools: update references to deleted `crypt-auth` option
Viktor Szakats [Wed, 25 Oct 2023 03:33:16 +0000 (03:33 +0000)] 
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 e92edfbef64448ef461117769881f3ed776dec4e #11490

Reviewed-by: Daniel Stenberg
Closes #12194

21 months agolib: introduce struct easy_poll_set for poll information
Stefan Eissing [Mon, 4 Sep 2023 10:06:07 +0000 (12:06 +0200)] 
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

21 months agotests/README: SOCKS tests are not using OpenSSH, it has its own server
Daniel Stenberg [Wed, 25 Oct 2023 05:56:56 +0000 (07:56 +0200)] 
tests/README: SOCKS tests are not using OpenSSH, it has its own server

Follow-up to 04fd67555cc

Closes #12195

21 months agotets: make test documentation more user-friendly
Jacob Hoffman-Andrews [Tue, 24 Oct 2023 21:08:12 +0000 (14:08 -0700)] 
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

21 months agocmake: pre-fill rest of detection values for Windows
Viktor Szakats [Thu, 5 Oct 2023 23:38:59 +0000 (23:38 +0000)] 
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:
  https://github.com/zlib-ng/zlib-ng/blob/61e181c8ae93dbf56040336179c9954078bd1399/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

21 months agopage-footer: clarify exit code 25
Jay Satiro [Tue, 24 Oct 2023 06:01:12 +0000 (02:01 -0400)] 
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

21 months agoscripts/cijobs.pl: adjust for appveyor
Daniel Stenberg [Tue, 24 Oct 2023 07:19:58 +0000 (09:19 +0200)] 
scripts/cijobs.pl: adjust for appveyor

Follow-up to a1d73a6bb

21 months agoOpenSSL: Include SIG and KEM algorithms in verbose
Alex Bozarth [Tue, 3 Oct 2023 22:30:13 +0000 (17:30 -0500)] 
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

21 months agohttp2: provide an error callback and failf the message
Daniel Stenberg [Sun, 22 Oct 2023 09:22:08 +0000 (11:22 +0200)] 
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

21 months agoBINDINGS: add V binding
Turiiya [Mon, 23 Oct 2023 05:17:14 +0000 (07:17 +0200)] 
BINDINGS: add V binding

Closes #12182

21 months agoconfigure: check for the fseeko declaration too
Daniel Stenberg [Thu, 19 Oct 2023 12:55:37 +0000 (14:55 +0200)] 
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

21 months agocmake: fix OpenSSL quic detection in quiche builds
Viktor Szakats [Thu, 19 Oct 2023 21:12:48 +0000 (21:12 +0000)] 
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 dee310d54261f9a8416e87d50bccfe2cbe404949 #11555

Reported-by: Casey Bodley <cbodley@redhat.com>
Fixes #12160
Closes #12162

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Sun, 22 Oct 2023 08:58:08 +0000 (10:58 +0200)] 
RELEASE-NOTES: synced

bump to 8.5.0 for pending release

21 months agotest3103: add missing quotes around a test tag attribute
Dan Fandrich [Sat, 21 Oct 2023 18:09:12 +0000 (11:09 -0700)] 
test3103: add missing quotes around a test tag attribute

21 months agotool: fix --capath when proxy support is disabled
Loïc Yhuel [Wed, 11 Oct 2023 11:09:23 +0000 (13:09 +0200)] 
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

21 months agoopenldap: move the alloc of ldapconninfo to *connect()
Daniel Stenberg [Fri, 20 Oct 2023 09:15:40 +0000 (11:15 +0200)] 
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

21 months agoopenldap: set the callback argument in oldap_do
Daniel Stenberg [Thu, 19 Oct 2023 22:04:28 +0000 (00:04 +0200)] 
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

21 months agognutls: support CURLSSLOPT_NATIVE_CA
Daniel Stenberg [Mon, 16 Oct 2023 12:46:36 +0000 (14:46 +0200)] 
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 7b55279d1d856

Co-authored-by: Jay Satiro
Closes #12137

21 months agoRTSP: improved RTP parser
Stefan Eissing [Sat, 7 Oct 2023 13:13:09 +0000 (15:13 +0200)] 
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

21 months agohttp2: header conversion tightening
Stefan Eissing [Thu, 12 Oct 2023 08:15:05 +0000 (10:15 +0200)] 
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

21 months agocurl_ntlm_wb: fix elif typo
Daniel Stenberg [Sat, 21 Oct 2023 08:28:08 +0000 (10:28 +0200)] 
curl_ntlm_wb: fix elif typo

Reported-by: Manfred Schwarb
Follow-up to d4314cdf65ae
Bug: https://github.com/curl/curl/commit/d4314cdf65aee295db627016934bd9eb621ab077#r130551295

21 months agotest1683: remove commented-out check alternatives
Dan Fandrich [Fri, 20 Oct 2023 22:32:21 +0000 (15:32 -0700)] 
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.

21 months agohostip: show the list of IPs when resolving is done
Daniel Stenberg [Tue, 17 Oct 2023 15:01:52 +0000 (17:01 +0200)] 
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

21 months agodocs: fix function typo in curl_easy_option_next.3
rilysh [Fri, 20 Oct 2023 18:57:12 +0000 (14:57 -0400)] 
docs: fix function typo in curl_easy_option_next.3

Closes #12170

21 months agovssh: remove the #ifdef for Curl_ssh_init, use empty macro
Daniel Stenberg [Fri, 20 Oct 2023 16:19:55 +0000 (18:19 +0200)] 
vssh: remove the #ifdef for Curl_ssh_init, use empty macro

In the same style as other init calls

21 months agoeasy: remove duplicate wolfSSH init call
Daniel Stenberg [Fri, 20 Oct 2023 15:59:46 +0000 (17:59 +0200)] 
easy: remove duplicate wolfSSH init call

It is already done in Curl_ssh_init() where it belongs.

Closes #12168

21 months agosocks: make SOCKS5 use the CURLOPT_IPRESOLVE choice
Daniel Stenberg [Fri, 20 Oct 2023 08:20:12 +0000 (10:20 +0200)] 
socks: make SOCKS5 use the CURLOPT_IPRESOLVE choice

Fixes #11949
Reported-by: Ammar Faizi
Closes #12163

21 months agourldata: move the 'internal' boolean to the state struct
Daniel Stenberg [Fri, 20 Oct 2023 09:33:08 +0000 (11:33 +0200)] 
urldata: move the 'internal' boolean to the state struct

... where all the other state bits for the easy handles live.

Closes #12165

21 months agourl: don't touch the multi handle when closing internal handles
Daniel Stenberg [Thu, 19 Oct 2023 07:24:27 +0000 (09:24 +0200)] 
url: don't touch the multi handle when closing internal handles

Reported-by: Maksymilian Arciemowicz
Closes #12165

21 months agogetenv: PlayStation doesn't have getenv()
Faraz Fallahi [Tue, 17 Oct 2023 03:37:22 +0000 (20:37 -0700)] 
getenv: PlayStation doesn't have getenv()

Closes #12140

21 months agotransfer: only reset the FTP wildcard engine in CLEAR state
Daniel Stenberg [Thu, 19 Oct 2023 11:10:38 +0000 (13:10 +0200)] 
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 843b3baa3e3cb228 (shipped in 8.1.0)
Bisect-by: Dan Fandrich
Fixes #11775
Closes #12156

21 months agoGHA: move mod_h2 version in CI to v2.0.25
Stefan Eissing [Thu, 19 Oct 2023 11:29:35 +0000 (13:29 +0200)] 
GHA: move mod_h2 version in CI to v2.0.25

Closes #12157

21 months agontlm_wb: use pipe instead of socketpair when possible
Daniel Stenberg [Wed, 18 Oct 2023 07:10:30 +0000 (09:10 +0200)] 
ntlm_wb: use pipe instead of socketpair when possible

Closes #12149

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Wed, 18 Oct 2023 07:22:07 +0000 (09:22 +0200)] 
RELEASE-NOTES: synced

21 months agoasyn-thread: use pipe instead of socketpair for IPC when available
Daniel Stenberg [Tue, 17 Oct 2023 15:56:09 +0000 (17:56 +0200)] 
asyn-thread: use pipe instead of socketpair for IPC when available

If pipe() is present. Less overhead.

Helped-by: Viktor Szakats
Closes #12146

21 months agotests: Fix Windows test helper tool search & use it for handle64 origin/master
Dan Fandrich [Fri, 13 Oct 2023 18:46:39 +0000 (11:46 -0700)] 
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

21 months agomulti: use pipe instead of socketpair to *wakeup()
Daniel Stenberg [Tue, 17 Oct 2023 06:28:55 +0000 (08:28 +0200)] 
multi: use pipe instead of socketpair to *wakeup()

If pipe() is present. Less overhead.

Closes #12142

21 months agobuild: fix 'threadsafe' feature detection for older gcc
Jay Satiro [Sun, 15 Oct 2023 01:55:42 +0000 (21:55 -0400)] 
build: fix 'threadsafe' feature detection for older gcc

- Add 'threadsafe' to the feature list shown during build if POSIX
  threads are being used.

This is a follow-up to 5adb6000 which added support for building a
thread-safe libcurl with older versions of gcc where atomic is not
available but pthread is.

Reported-by: Dan Fandrich
Co-authored-by: Dan Fandrich
Fixes https://github.com/curl/curl/issues/12125
Closes https://github.com/curl/curl/pull/12127

21 months agotest729: verify socks4a with excessive proxy user name length
Daniel Stenberg [Fri, 13 Oct 2023 12:16:47 +0000 (14:16 +0200)] 
test729: verify socks4a with excessive proxy user name length

21 months agosocks: better buffer size checks for socks4a user and hostname
Daniel Stenberg [Thu, 12 Oct 2023 22:15:29 +0000 (00:15 +0200)] 
socks: better buffer size checks for socks4a user and hostname

Also limit the proxy user name to 255 bytes, which is the same limit as
in SOCKS5.

Reported-by: sd0 on hackerone
Closes #12139

21 months agocurl.h: on FreeBSD include sys/param.h instead of osreldate.h
Daniel Stenberg [Sat, 14 Oct 2023 20:47:49 +0000 (22:47 +0200)] 
curl.h: on FreeBSD include sys/param.h instead of osreldate.h

Should things build on Playstation as well

Fixes #12107
Reported-by: Faraz Fallahi
Closes #12123

21 months agotool_operate: fix links in ipfs errors
Marcin Rataj [Sun, 15 Oct 2023 23:34:54 +0000 (01:34 +0200)] 
tool_operate: fix links in ipfs errors

URL fragment links generated from headers in
https://curl.se/docs/ipfs.html are lowercase.

Closes #12133

21 months agocmake: replace `check_library_exists_concat()`
Viktor Szakats [Mon, 9 Oct 2023 08:31:04 +0000 (08:31 +0000)] 
cmake: replace `check_library_exists_concat()`

The idea of `check_library_exists_concat()` is that it detects an
optional component and adds it to the list of libs that we also use in
subsequent component checks. This caused problems when detecting
components with unnecessary dependencies that were not yet built.

CMake offers the `CMAKE_REQUIRED_LIBRARIES` variable to set libs used
for component checks, which we already use in most cases. That left 4
uses of `check_library_exists_concat()`. Only one of these actually
needed the 'concat' feature (ldap/lber).

Delete this function and replace it with standard
`check_library_exists()` and manual management of our `CURL_LIBS`
list we use when linking build targets. And special logic to handle the
ldap/lber case.

(We have a similar function for headers: `check_include_file_concat()`.
It works, but problematic for performance reasons and because it hides
the actual headers required in `check_symbol_exists()` calls.)

Ref: #11537 #11558
Fixes #11285
Fixes #11648
Closes #12070

21 months agotool_cb_wrt: fix write output for very old Windows versions
LoRd_MuldeR [Sun, 15 Oct 2023 14:55:43 +0000 (16:55 +0200)] 
tool_cb_wrt: fix write output for very old Windows versions

- Pass missing parameter for 'lpNumberOfCharsWritten' to WriteConsoleW()
  function.

Apparently this parameter was *not* optional on older Windows versions.

Issue observed on Windows XP SP2. Issue not observed on Windows 7 SP1.
So at some point between those two Microsoft changed the behavior.

Prior to this change, on those versions if parameter is NULL then the
function call fails with error ERROR_INVALID_ACCESS.

Regression since af3f4e41.

Ref: https://github.com/MicrosoftDocs/Console-Docs/issues/299

Fixes https://github.com/curl/curl/issues/12131
Closes https://github.com/curl/curl/pull/12130

21 months agotool_urlglob: fix build for old gcc versions
Jay Satiro [Sun, 15 Oct 2023 02:28:17 +0000 (22:28 -0400)] 
tool_urlglob: fix build for old gcc versions

- Don't use __builtin_mul_overflow for GCC 4 and earlier.

The function was added in GCC 5.

Ref: https://gcc.gnu.org/gcc-5/changes.html

Reported-by: Dan Fandrich
Fixes https://github.com/curl/curl/issues/12124
Closes https://github.com/curl/curl/pull/12128

21 months agodocs/libcurl: fix three minor man page format mistakes
Carlos Henrique Lima Melara [Sun, 15 Oct 2023 01:36:04 +0000 (22:36 -0300)] 
docs/libcurl: fix three minor man page format mistakes

Reported-by: Samuel Henrique
Closes https://github.com/curl/curl/pull/12126

21 months agotests/server: add more SOCKS5 handshake error checking
Jay Satiro [Sat, 14 Oct 2023 05:45:28 +0000 (01:45 -0400)] 
tests/server: add more SOCKS5 handshake error checking

- Add additional checking for missing and too-short SOCKS5 handshake
  messages.

Prior to this change the SOCKS5 test server did not check that all parts
of the handshake were received successfully. If those parts were missing
or too short then the server would access uninitialized memory.

This issue was discovered in CI job 'memory-sanitizer' test results.
Test 2055 was failing due to the SOCKS5 test server not running. It was
not running because either it crashed or memory sanitizer aborted it
during Test 728. Test 728 connects to the SOCKS5 test server on a
redirect but does not send any data on purpose. The test server was not
prepared for that.

Reported-by: Dan Fandrich
Fixes https://github.com/curl/curl/issues/12117
Closes https://github.com/curl/curl/pull/12118

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Sat, 14 Oct 2023 21:10:36 +0000 (23:10 +0200)] 
RELEASE-NOTES: synced

21 months agotool_getparam: limit --rate to be smaller than number of ms
Sohom Datta [Fri, 13 Oct 2023 21:01:16 +0000 (23:01 +0200)] 
tool_getparam: limit --rate to be smaller than number of ms

Currently, curl allows users to specify absurd request rates that might
be higher than the number of milliseconds in the unit (ex: curl --rate
3600050/h http://localhost:8080 does not error out despite there being
only 3600000ms in a hour).

This change adds a conditional check before the millisecond calculation
making sure that the number is not higher than the numerator (the unit)
If the number is higher, curl errors out with PARAM_NUMBER_TOO_LARGE

Closes #12116

21 months agoopts: fix two minor man page format mistakes
Daniel Stenberg [Sat, 14 Oct 2023 16:22:03 +0000 (18:22 +0200)] 
opts: fix two minor man page format mistakes

21 months agocurl_trc: remove a bad assertion
Jay Satiro [Fri, 13 Oct 2023 00:50:45 +0000 (20:50 -0400)] 
curl_trc: remove a bad assertion

- Remove DEBUGASSERT that an internal handle must not have user
  private_data set before calling the user's debug callback.

This is a follow-up to 0dc40b2a. The user can distinguish their easy
handle from an internal easy handle by setting CURLOPT_PRIVATE on their
easy handle. I had wrongly assumed that meant the user couldn't then
set CURLOPT_PRIVATE on an internal handle as well.

Bug: https://github.com/curl/curl/pull/12060#issuecomment-1754594697
Reported-by: Daniel Stenberg
Closes https://github.com/curl/curl/pull/12104

21 months agotest613: stop showing an error on missing output file
Dan Fandrich [Sat, 14 Oct 2023 03:24:08 +0000 (20:24 -0700)] 
test613: stop showing an error on missing output file

This test would show an error message if the output was missing during
the log post-processing step, but the message was not captured by the
test harness and wasn't useful since the normal golden log file
comparison would the problem more clearly.

21 months agoquic: manage connection idle timeouts
Stefan Eissing [Tue, 10 Oct 2023 10:51:25 +0000 (12:51 +0200)] 
quic: manage connection idle timeouts

- configure a 120s idle timeout on our side of the connection
- track the timestamp when actual socket IO happens
- check IO timestamp to our *and* the peer's idle timeouts
  in "is this connection alive" checks

Reported-by: calvin2021y on github
Fixes #12064
Closes #12077

21 months agoCI: ignore test 286 on Appveyor gcc 9 build
Dan Fandrich [Fri, 13 Oct 2023 02:33:19 +0000 (19:33 -0700)] 
CI: ignore test 286 on Appveyor gcc 9 build

This test fails sometimes with a super fast retry loop due to what may
just be a compiler bug. The test results are ignored on the one CI job
where it occurs because there seems to be nothing we can do to fix it.

Fixes #12040
Closes #12106

21 months agolib: fix gcc warning in printf call
Viktor Szakats [Wed, 11 Oct 2023 04:02:45 +0000 (04:02 +0000)] 
lib: fix gcc warning in printf call

Do not pass NULL to printf %s.

Seen with gcc 13.2.0 on Debian:
```
.../curl/lib/connect.c:696:27: warning: '%s' directive argument is null [-Wformat-overflow=]
```
Ref: https://github.com/curl/curl-for-win/actions/runs/6476161689/job/17584426483#step:3:11104

Ref: #10284
Co-authored-by: Jay Satiro
Closes #12082

21 months agohttp2: safer invocation of populate_binsettings
Alex Klyubin [Thu, 12 Oct 2023 18:27:47 +0000 (12:27 -0600)] 
http2: safer invocation of populate_binsettings

populate_binsettings now returns a negative value on error, instead of a
huge positive value. Both places which call this function have been
updated to handle this change in its contract.

The way populate_binsettings had been used prior to this change the huge
positive values -- due to signed->unsigned conversion of the potentially
negative result of nghttp2_pack_settings_payload which returns negative
values on error -- are not possible. But only because http2.c currently
always provides a large enough output buffer and provides H2 SETTINGS
IVs which pass the verification logic inside nghttp2.  If the
verification logic were to change or if http2.c started passing in more
IVs without increasing the output buffer size, the overflow could become
reachable, and libcurl/curl might start leaking memory contents to
servers/proxies...

Closes #12101

21 months agoopenssl: avoid BN_num_bits() NULL pointer derefs
Daniel Stenberg [Thu, 12 Oct 2023 14:00:38 +0000 (16:00 +0200)] 
openssl: avoid BN_num_bits() NULL pointer derefs

Reported-by: icy17 on github
Fixes #12099
Closes #12100

21 months agowolfssl: require WOLFSSL_SYS_CA_CERTS for loading system CA
Daniel Stenberg [Fri, 13 Oct 2023 07:00:50 +0000 (09:00 +0200)] 
wolfssl: require WOLFSSL_SYS_CA_CERTS for loading system CA

This define is set in wolfssl's options.h file when this function and
feature is present. Handles both builds with the feature explicitly
disabled and wolfSSL versions before 5.5.2 - which introduced this API
call.

Closes #12108

21 months agotool_urlglob: make multiply() bail out on negative values
Daniel Stenberg [Thu, 12 Oct 2023 22:13:23 +0000 (00:13 +0200)] 
tool_urlglob: make multiply() bail out on negative values

- Does not work correctly with negative values
- use __builtin_mul_overflow() on gcc

Reported-by: Torben Dury
Closes #12102

21 months agocmake: fix CURL_DISABLE_GETOPTIONS
Loïc Yhuel [Wed, 11 Oct 2023 11:13:50 +0000 (13:13 +0200)] 
cmake: fix CURL_DISABLE_GETOPTIONS

- Add CURL_DISABLE_GETOPTIONS to curl_config.h.cmake.

Prior to this change the option had no effect because it was missing
from that file.

Closes https://github.com/curl/curl/pull/12091

21 months agoeasy_lock: add a pthread_mutex_t fallback
Loïc Yhuel [Wed, 11 Oct 2023 11:07:48 +0000 (13:07 +0200)] 
easy_lock: add a pthread_mutex_t fallback

This allows to keep the init threadsafe with gcc < 4.9.0 (no C11
atomics).

Closes https://github.com/curl/curl/pull/12090

21 months agoCI: add autotools, out-of-tree, debug build to distro check job
Viktor Szakats [Wed, 11 Oct 2023 09:07:03 +0000 (09:07 +0000)] 
CI: add autotools, out-of-tree, debug build to distro check job

Add a job that builds curl from a generated source tarball sample, with
autotools, out-of-tree, in debug mode.

Ref: #12085
Closes #12088

21 months agohttp: avoid Expect: 100-continue if Upgrade: is used
Daniel Stenberg [Sun, 8 Oct 2023 10:04:59 +0000 (12:04 +0200)] 
http: avoid Expect: 100-continue if Upgrade: is used

Reported-by: Daniel Jelinski
Fixes #12022
Closes #12062

21 months agodocs: use SOURCE_DATE_EPOCH for generated manpages
Jan Alexander Steffens (heftig) [Sun, 8 Oct 2023 10:31:57 +0000 (12:31 +0200)] 
docs: use SOURCE_DATE_EPOCH for generated manpages

This should make builds from Git reproducible.

Closes #12092

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Thu, 12 Oct 2023 07:09:49 +0000 (09:09 +0200)] 
RELEASE-NOTES: synced

Bumped to 8.4.1

21 months agocmake: fix `HAVE_H_ERRNO_ASSIGNABLE` detection
Viktor Szakats [Wed, 11 Oct 2023 16:06:12 +0000 (16:06 +0000)] 
cmake: fix `HAVE_H_ERRNO_ASSIGNABLE` detection

Fix `HAVE_H_ERRNO_ASSIGNABLE` to not run, only compile its test snippet,
aligning this with autotools. This fixes an error when doing
cross-builds and also actually detects this feature. It affected systems
not allowlisted into this, e.g. SerenityOS.

We used this detection result to enable `HAVE_GETADDRINFO_THREADSAFE`.

Follow-up to 04a3a377d83fd72c4cf7a96c9cb6d44785e33264 #11979
Ref: #12095 (closed in favour of this patch)
Ref: #11964 (effort to sync cmake detections with autotools)

Reported-by: Kartatz on Github
Assisted-by: Kartatz on Github
Fixes #12093
Closes #12094

21 months agobuild: add `src/.checksrc` to source tarball
Viktor Szakats [Wed, 11 Oct 2023 08:28:31 +0000 (08:28 +0000)] 
build: add `src/.checksrc` to source tarball

Regression from e5bb88b8f824ed87620bd923552534c83c2a516e #11958

Bug: https://github.com/curl/curl/pull/11958#issuecomment-1757079071
Reported-by: Romain Geissler
Fixes #12084
Closes #12085

21 months agoRELEASE-NOTES: synced curl-8_4_0
Daniel Stenberg [Wed, 11 Oct 2023 05:34:19 +0000 (07:34 +0200)] 
RELEASE-NOTES: synced

21 months agoTHANKS: add contributors from 8.4.0
Daniel Stenberg [Wed, 11 Oct 2023 05:34:19 +0000 (07:34 +0200)] 
THANKS: add contributors from 8.4.0

21 months agosocks: return error if hostname too long for remote resolve
Jay Satiro [Wed, 11 Oct 2023 05:34:19 +0000 (07:34 +0200)] 
socks: return error if hostname too long for remote resolve

Prior to this change the state machine attempted to change the remote
resolve to a local resolve if the hostname was longer than 255
characters. Unfortunately that did not work as intended and caused a
security issue.

Bug: https://curl.se/docs/CVE-2023-38545.html

21 months agoCI: remove slowed-network tests
Stefan Eissing [Tue, 10 Oct 2023 08:50:17 +0000 (10:50 +0200)] 
CI: remove slowed-network tests

- remove these tests as they are currently not reliable in our CI
  setups.

curl handles the test cases, but CI sometimes fails on these due to
additional conditions. Rather than mix them in, an additional CI job
will be added in the future that is specific to them.

Closes https://github.com/curl/curl/pull/12075

21 months agolibcurl-env-dbg.3: move debug variables from libcurl-env.3
Jay Satiro [Thu, 7 Sep 2023 07:04:16 +0000 (03:04 -0400)] 
libcurl-env-dbg.3: move debug variables from libcurl-env.3

- Move documentation of libcurl environment variables used only in debug
  builds from libcurl-env into a separate document libcurl-env-dbg.

- Document more debug environment variables.

Previously undocumented or missing a description:

CURL_ALTSVC_HTTP, CURL_DBG_SOCK_WBLOCK, CURL_DBG_SOCK_WPARTIAL,
CURL_DBG_QUIC_WBLOCK, CURL_DEBUG, CURL_DEBUG_SIZE, CURL_GETHOSTNAME,
CURL_HSTS_HTTP, CURL_FORCETIME, CURL_SMALLREQSEND, CURL_SMALLSENDS,
CURL_TIME.

Closes https://github.com/curl/curl/pull/11811

21 months agotest670: increase the test timeout
Dan Fandrich [Mon, 9 Oct 2023 21:15:29 +0000 (14:15 -0700)] 
test670: increase the test timeout

This should make it more immune to loaded servers.

Ref: #11328

21 months agoMQTT: improve receive of ACKs
Stefan Eissing [Mon, 9 Oct 2023 09:36:37 +0000 (11:36 +0200)] 
MQTT: improve receive of ACKs

- add `mq->recvbuf` to provide buffering of incomplete
  ACK responses
- continue ACK reading until sufficient bytes available
- fixes test failures on low network receives

Closes #12071

21 months agoquic: fix BoringSSL build
Viktor Szakats [Sun, 8 Oct 2023 23:02:07 +0000 (23:02 +0000)] 
quic: fix BoringSSL build

Add guard around `SSL_CTX_set_ciphersuites()` use.

Bug: https://github.com/curl/curl/pull/12065#issuecomment-1752171885

Follow-up to aa9a6a177017e4b74d33cdf85a3594900f4a7f81

Co-authored-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Closes #12067

21 months agotest1540: improve reliability
Stefan Eissing [Mon, 9 Oct 2023 08:30:33 +0000 (10:30 +0200)] 
test1540: improve reliability

- print that bytes have been received on pausing, but not how many

Closes #12069

21 months agotest2302: improve reliability
Stefan Eissing [Mon, 9 Oct 2023 08:18:20 +0000 (10:18 +0200)] 
test2302: improve reliability

- make result print collected write data, unless
  change in meta flags is detected
- will show same result even when data arrives via
  several writecb invocations

Closes #12068

21 months agocurl_easy_pause: set "in callback" true on exit if true
Daniel Stenberg [Sun, 8 Oct 2023 08:39:39 +0000 (10:39 +0200)] 
curl_easy_pause: set "in callback" true on exit if true

Because it might have called another callback in the mean time that then
set the bit FALSE on exit.

Reported-by: Jay Satiro
Fixes #12059
Closes #12061

21 months agoh3: add support for ngtcp2 with AWS-LC builds
Viktor Szakats [Sun, 8 Oct 2023 17:43:10 +0000 (17:43 +0000)] 
h3: add support for ngtcp2 with AWS-LC builds

```
curl 8.4.0-DEV (x86_64-apple-darwin) libcurl/8.4.0-DEV (SecureTransport) AWS-LC/1.15.0 nghttp2/1.56.0 ngtcp2/0.19.1 nghttp3/0.15.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IPv6 Largefile MultiSSL NTLM SSL threadsafe UnixSockets
```

Also delete an obsolete GnuTLS TODO and update the header comment in
`FindNGTCP2.cmake`.

Reviewed-by: Daniel Stenberg
Closes #12066

21 months agobuild: do not publish `HAVE_BORINGSSL`, `HAVE_AWSLC` macros
Viktor Szakats [Sun, 8 Oct 2023 15:37:41 +0000 (15:37 +0000)] 
build: do not publish `HAVE_BORINGSSL`, `HAVE_AWSLC` macros

Syncing this up with CMake.

Source code uses the built-in `OPENSSL_IS_AWSLC` and
`OPENSSL_IS_BORINSSL` macros to detect BoringSSL and AWS-LC. No help is
necessary from the build tools.

The one use of `HAVE_BORINGSSL` in the source turned out to be no longer
necessary for warning-free BoringSSL + Schannel builds. Ref: #1610 #2634

autotools detects this anyway for display purposes.
CMake detects this to decide whether to use the BoringSSL-specific
crypto lib with ngtcp2. It detects AWS-LC, but doesn't use the detection
result just yet (planned in #12066).

Ref: #11964

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #12065

21 months agoCI: move distcheck job from Azure Pipelines to GitHub Actions
Marc Hoersken [Sat, 17 Sep 2022 21:13:27 +0000 (23:13 +0200)] 
CI: move distcheck job from Azure Pipelines to GitHub Actions

This will allow for more trigger excludes within Azure Pipelines.

Also fixes seemingly broken check with scripts/installcheck.sh.
Ref: 190374c74ec4e5247d9066544c86e8d095e1d7b5

Assisted-by: Philip Heiduck
Closes #9532

21 months agourl: fall back to http/https proxy env-variable if ws/wss not set
Daniel Stenberg [Sat, 7 Oct 2023 19:13:04 +0000 (21:13 +0200)] 
url: fall back to http/https proxy env-variable if ws/wss not set

Reported-by: Craig Andrews
Fixes #12031
Closes #12058

21 months agocf-socket: simulate slow/blocked receives in debug
Stefan Eissing [Thu, 5 Oct 2023 08:05:12 +0000 (10:05 +0200)] 
cf-socket: simulate slow/blocked receives in debug

add 2 env variables for non-UDP sockets:
1. CURL_DBG_SOCK_RBLOCK: percentage of receive calls that randomly
   should return EAGAIN
2. CURL_DBG_SOCK_RMAX: max amount of bytes read from socket

Closes #12035

21 months agohttp2: refused stream handling for retry
Stefan Eissing [Sat, 7 Oct 2023 14:29:58 +0000 (16:29 +0200)] 
http2: refused stream handling for retry

- answer HTTP/2 streams refused via a GOAWAY from the server to
  respond with CURLE_RECV_ERROR in order to trigger a retry
  on another connection

Reported-by: black-desk on github
Ref #11859
Closes #12054

21 months agoCURLOPT_DEBUGFUNCTION.3: warn about internal handles
Jay Satiro [Thu, 5 Oct 2023 07:19:47 +0000 (03:19 -0400)] 
CURLOPT_DEBUGFUNCTION.3: warn about internal handles

- Warn that the user's debug callback may be called with the handle
  parameter set to an internal handle.

Without this warning the user may assume that the only handles their
debug callback receives are the easy handles on which they set
CURLOPT_DEBUGFUNCTION.

This is a follow-up to f8cee8cc which changed DoH handles to inherit
the debug callback function set in the user's easy handle. As a result
those handles are now passed to the user's debug callback function.

Closes https://github.com/curl/curl/pull/12034

21 months agourl: fix typo
Jay Satiro [Sat, 7 Oct 2023 22:43:14 +0000 (18:43 -0400)] 
url: fix typo

21 months agotest458: verify --expand-output, expanding a file name accepting option
Daniel Stenberg [Sat, 7 Oct 2023 18:37:38 +0000 (20:37 +0200)] 
test458: verify --expand-output, expanding a file name accepting option

Verifies the fix in #12055 (commit f2c8086ff15e6e995e1)

21 months agotool_getparam: accept variable expansion on file names too
Daniel Stenberg [Sat, 7 Oct 2023 17:36:36 +0000 (19:36 +0200)] 
tool_getparam: accept variable expansion on file names too

Reported-by: PBudmark on github
Fixes #12048
Closes #12055

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Sat, 7 Oct 2023 21:01:06 +0000 (23:01 +0200)] 
RELEASE-NOTES: synced

21 months agomulti: do CURLM_CALL_MULTI_PERFORM at two more places
Daniel Stenberg [Sat, 7 Oct 2023 18:10:36 +0000 (20:10 +0200)] 
multi: do CURLM_CALL_MULTI_PERFORM at two more places

... when it does a state transition but there is no particular socket or
timer activity. This was made apparent when commit b5bb84c removed a
superfluous timer expiry.

Reported-by: Dan Fandrich.
Fixes #12033
Closes #12056

21 months agoGHA/linux: mbedtls 3.5.0 + minor dep bumps
Viktor Szakats [Sat, 7 Oct 2023 19:09:13 +0000 (19:09 +0000)] 
GHA/linux: mbedtls 3.5.0 + minor dep bumps

Closes #12057

21 months agoCI: bump OpenLDAP package version on FreeBSD
Dan Fandrich [Sat, 7 Oct 2023 19:37:14 +0000 (12:37 -0700)] 
CI: bump OpenLDAP package version on FreeBSD

The old one is no longer available.

21 months agodocs/libcurl/opts/Makefile.inc: add missing manpage files
Marc Hoersken [Tue, 19 Sep 2023 19:08:05 +0000 (21:08 +0200)] 
docs/libcurl/opts/Makefile.inc: add missing manpage files

Detected with #9532

21 months agotests: fix a race condition in ftp server disconnect
Dan Fandrich [Sat, 7 Oct 2023 01:18:49 +0000 (18:18 -0700)] 
tests: fix a race condition in ftp server disconnect

If a client disconnected and reconnected quickly, before the ftp server
had a chance to respond, the protocol message/ack (ping/pong) sequence
got out of sync, causing messages sent to the old client to be delivered
to the new.  A disconnect must now be acknowledged and intermediate
requests thrown out until it is, which ensures that such synchronization
problems can't occur. This problem could affect ftp, pop3, imap and smtp
tests.

Fixes #12002
Closes #12049

21 months agoappveyor: bump mingw-w64 job to gcc 13 (was: 8)
Viktor Szakats [Sat, 7 Oct 2023 10:29:39 +0000 (10:29 +0000)] 
appveyor: bump mingw-w64 job to gcc 13 (was: 8)

This sets gcc 6, 7, 9, 13 in our test mix (was: 6, 7, 8, 9).
Adding a modern gcc version to the tests.

(The gcc 8 job used to take around 50 minutes. The new image with gcc 13
finished in 32, 35, 34 minutes in the 3 test runs so far.)

It also adds a modern CMake version and OS env to our mingw-w64 builds.

Closes #12051

21 months agoopenssl: use X509_ALGOR_get0 instead of reaching into X509_ALGOR
David Benjamin [Thu, 5 Oct 2023 16:50:55 +0000 (12:50 -0400)] 
openssl: use X509_ALGOR_get0 instead of reaching into X509_ALGOR

While the struct is still public in OpenSSL, there is a (somewhat
inconvenient) accessor. Use it to remain compatible if it becomes opaque
in the future.

Closes #12038