]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
20 months agowindows: use built-in `_WIN32` macro to detect Windows
Viktor Szakats [Tue, 21 Nov 2023 16:54:49 +0000 (16:54 +0000)] 
windows: use built-in `_WIN32` macro to detect Windows

Windows compilers define `_WIN32` automatically. Windows SDK headers
or build env defines `WIN32`, or we have to take care of it. The
agreement seems to be that `_WIN32` is the preferred practice here.
Make the source code rely on that to detect we're building for Windows.

Public `curl.h` was using `WIN32`, `__WIN32__` and `CURL_WIN32` for
Windows detection, next to the official `_WIN32`. After this patch it
only uses `_WIN32` for this. Also, make it stop defining `CURL_WIN32`.

There is a slight chance these break compatibility with Windows
compilers that fail to define `_WIN32`. I'm not aware of any obsolete
or modern compiler affected, but in case there is one, one possible
solution is to define this macro manually.

grepping for `WIN32` remains useful to discover Windows-specific code.

Also:

- extend `checksrc` to ensure we're not using `WIN32` anymore.

- apply minor formatting here and there.

- delete unnecessary checks for `!MSDOS` when `_WIN32` is present.

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

20 months agourl: ConnectionExists revisited
Stefan Eissing [Tue, 21 Nov 2023 14:46:41 +0000 (15:46 +0100)] 
url: ConnectionExists revisited

- have common pattern of `if not match, continue`
- revert pages long if()s to return early
- move dead connection check to later since it may
  be relatively expensive
- check multiuse also when NOT building with NGHTTP2
- for MULTIUSE bundles, verify that the inspected
  connection indeed supports multiplexing when in use
  (bundles may contain a mix of connection, afaict)

Closes #12373

20 months agoCURLMOPT_MAX_CONCURRENT_STREAMS: make sure the set value is within range
Daniel Stenberg [Wed, 22 Nov 2023 09:54:40 +0000 (10:54 +0100)] 
CURLMOPT_MAX_CONCURRENT_STREAMS: make sure the set value is within range

... or use the default value.

Also clarify the documentation language somewhat.

Closes #12382

20 months agourldata: make maxconnects a 32 bit value
Daniel Stenberg [Tue, 21 Nov 2023 17:18:27 +0000 (18:18 +0100)] 
urldata: make maxconnects a 32 bit value

"2^32 idle connections ought to be enough for anybody"

Closes #12375

20 months agoFEATURES: update the URL phrasing
Daniel Stenberg [Wed, 22 Nov 2023 10:34:13 +0000 (11:34 +0100)] 
FEATURES: update the URL phrasing

The URL is length limited since a while back so "no limit" simply is not
true anymore. Mention the URL RFC standard used instead.

Closes #12383

20 months agowolfssh: remove redundant static prototypes
Daniel Stenberg [Wed, 22 Nov 2023 07:57:19 +0000 (08:57 +0100)] 
wolfssh: remove redundant static prototypes

vssh/wolfssh.c:346:18: error: redundant redeclaration of ‘wscp_recv’ [-Werror=redundant-decls]

Closes #12381

20 months agosetopt: remove superfluous use of ternary expressions
Daniel Stenberg [Tue, 21 Nov 2023 16:55:31 +0000 (17:55 +0100)] 
setopt: remove superfluous use of ternary expressions

Closes #12374

20 months agomime: store "form escape" as a single bit
Daniel Stenberg [Tue, 21 Nov 2023 16:44:05 +0000 (17:44 +0100)] 
mime: store "form escape" as a single bit

Closes #12374

20 months agosetopt: check CURLOPT_TFTP_BLKSIZE range on set
Daniel Stenberg [Tue, 21 Nov 2023 16:34:30 +0000 (17:34 +0100)] 
setopt: check CURLOPT_TFTP_BLKSIZE range on set

... instead of later when the transfer is about to happen.

Closes #12374

20 months agobuild: add more picky warnings and fix them
Viktor Szakats [Wed, 15 Nov 2023 14:43:36 +0000 (14:43 +0000)] 
build: add more picky warnings and fix them

Enable more picky compiler warnings. I've found these options in the
nghttp3 project when implementing the CMake quick picky warning
functionality for it [1].

`-Wunused-macros` was too noisy to keep around, but fixed a few issues
it revealed while testing.

- autotools: reflect the more precisely-versioned clang warnings.
  Follow-up to 033f8e2a08eb1d3102f08c4d8c8e85470f8b460e #12324
- autotools: sync between clang and gcc the way we set `no-multichar`.
- autotools: avoid setting `-Wstrict-aliasing=3` twice.
- autotools: disable `-Wmissing-noreturn` for MSYS gcc targets [2].
  It triggers in libtool-generated stub code.

- lib/timeval: delete a redundant `!MSDOS` guard from a `WIN32` branch.

- lib/curl_setup.h: delete duplicate declaration for `fileno`.
  Added in initial commit ae1912cb0d494b48d514d937826c9fe83ec96c4d
  (1999-12-29). This suggests this may not be needed anymore, but if
  it does, we may restore this for those specific (non-Windows) systems.
- lib: delete unused macro `FTP_BUFFER_ALLOCSIZE` since
  c1d6fe2aaa5a26e49a69a4f2495b3cc7a24d9394.
- lib: delete unused macro `isxdigit_ascii` since
  f65f750742068f579f4ee6d8539ed9d5f0afcb85.
- lib/mqtt: delete unused macro `MQTT_HEADER_LEN`.
- lib/multi: delete unused macro `SH_READ`/`SH_WRITE`.
- lib/hostip: add `noreturn` function attribute via new `CURL_NORETURN`
  macro.
- lib/mprintf: delete duplicate declaration for `Curl_dyn_vprintf`.
- lib/rand: fix `-Wunreachable-code` and related fallouts [3].
- lib/setopt: fix `-Wunreachable-code-break`.
- lib/system_win32 and lib/timeval: fix double declarations for
  `Curl_freq` and `Curl_isVistaOrGreater` in CMake UNITY mode [4].
- lib/warnless: fix double declarations in CMake UNITY mode [5].
  This was due to force-disabling the header guard of `warnless.h` to
  to reapply it to source code coming after `warnless.c` in UNITY
  builds. This reapplied declarations too, causing the warnings.
  Solved by adding a header guard for the lines that actually need
  to be reapplied.
- lib/vauth/digest: fix `-Wunreachable-code-break` [6].
- lib/vssh/libssh2: fix `-Wunreachable-code-break` and delete redundant
  block.
- lib/vtls/sectransp: fix `-Wunreachable-code-break` [7].
- lib/vtls/sectransp: suppress `-Wunreachable-code`.
  Detected in `else` branches of dynamic feature checks, with results
  known at compile-time, e.g.
  ```c
  if(SecCertificateCopySubjectSummary)  /* -> true */
  ```
  Likely fixable as a separate micro-project, but given SecureTransport
  is deprecated anyway, let's just silence these locally.
- src/tool_help: delete duplicate declaration for `helptext`.
- src/tool_xattr: fix `-Wunreachable-code`.
- tests: delete duplicate declaration for `unitfail` [8].
- tests: delete duplicate declaration for `strncasecompare`.
- tests/libtest: delete duplicate declaration for `gethostname`.
  Originally added in 687df5c8c39c370a59999b9afc0917d808d978b7
  (2010-08-02).
  Got complicated later: c49e9683b85ba9d12cbb6eebc4ab2c8dba68fbdc
  If there are still systems around with warnings, we may restore the
  prototype, but limited for those systems.
- tests/lib2305: delete duplicate declaration for
  `libtest_debug_config`.
- tests/h2-download: fix `-Wunreachable-code-break`.

[1] https://github.com/ngtcp2/nghttp3/blob/a70edb08e954d690e8fb2c1df999b5a056f8bf9f/cmake/PickyWarningsC.cmake
[2] https://ci.appveyor.com/project/curlorg/curl/builds/48553586/job/3qkgjauiqla5fj45?fullLog=true#L1675
[3] https://github.com/curl/curl/actions/runs/6880886309/job/18716044703?pr=12331#step:7:72
    https://github.com/curl/curl/actions/runs/6883016087/job/18722707368?pr=12331#step:7:109
[4] https://ci.appveyor.com/project/curlorg/curl/builds/48555101/job/9g15qkrriklpf1ut#L204
[5] https://ci.appveyor.com/project/curlorg/curl/builds/48555101/job/9g15qkrriklpf1ut#L218
[6] https://github.com/curl/curl/actions/runs/6880886309/job/18716042927?pr=12331#step:7:290
[7] https://github.com/curl/curl/actions/runs/6891484996/job/18746659406?pr=12331#step:9:1193
[8] https://github.com/curl/curl/actions/runs/6882803986/job/18722082562?pr=12331#step:33:1870

Closes #12331

20 months agotransfer: avoid unreachable expression
Daniel Stenberg [Tue, 21 Nov 2023 07:13:08 +0000 (08:13 +0100)] 
transfer: avoid unreachable expression

If curl_off_t and size_t have the same size (which is common on modern
64 bit systems), a condition cannot occur which Coverity pointed
out. Avoid the warning by having the code conditionally only used if
curl_off_t actually is larger.

Follow-up to 1cd2f0072fa482e25baa2

Closes #12370

20 months agotransfer: readwrite improvements
Stefan Eissing [Mon, 6 Nov 2023 16:06:06 +0000 (17:06 +0100)] 
transfer: readwrite improvements

- changed header/chunk/handler->readwrite prototypes to accept `buf`,
  `blen` and a `pconsumed` pointer. They now get the buffer to work on
  and report back how many bytes they consumed
- eliminated `k->str` in SingleRequest
- improved excess data handling to properly calculate with any body data
  left in the headerb buffer
- eliminated `k->badheader` enum to only be a bool

Closes #12283

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Tue, 21 Nov 2023 07:01:42 +0000 (08:01 +0100)] 
RELEASE-NOTES: synced

20 months agotransfer: avoid calling the read callback again after EOF
Jiří Hruška [Mon, 20 Nov 2023 08:26:59 +0000 (09:26 +0100)] 
transfer: avoid calling the read callback again after EOF

Regression since 7f43f3dc5994d01b12 (7.84.0)

Bug: https://curl.se/mail/lib-2023-11/0017.html

Closes #12363

20 months agodoh: provide better return code for responses w/o addresses
Daniel Stenberg [Mon, 20 Nov 2023 12:33:31 +0000 (13:33 +0100)] 
doh: provide better return code for responses w/o addresses

Previously it was wrongly returning CURLE_OUT_OF_MEMORY when the
response did not contain any addresses. Now it more accurately returns
CURLE_COULDNT_RESOLVE_HOST.

Reported-by: lRoccoon on github
Fixes #12365
Closes #12366

20 months agoHTTP/2, HTTP/3: handle detach of onoing transfers
Stefan Eissing [Mon, 20 Nov 2023 10:32:19 +0000 (11:32 +0100)] 
HTTP/2, HTTP/3: handle detach of onoing transfers

- refs #12356 where a UAF is reported when closing a connection
  with a stream whose easy handle was cleaned up already
- handle DETACH events same as DONE events in h2/h3 filters

Fixes #12356
Reported-by: Paweł Wegner
Closes #12364

20 months agoautotools: stop setting `-std=gnu89` with `--enable-warnings`
Viktor Szakats [Thu, 16 Nov 2023 21:44:45 +0000 (21:44 +0000)] 
autotools: stop setting `-std=gnu89` with `--enable-warnings`

Do not alter the C standard when building with `--enable-warnings` when
building with gcc.

On one hand this alters warning results compared to a default build.
On the other, it may produce different binaries, which is unexpected.

Also fix new warnings that appeared after removing `-std=gnu89`:

- include: fix public curl headers to use the correct printf mask for
  `CURL_FORMAT_CURL_OFF_T` and `CURL_FORMAT_CURL_OFF_TU` with mingw-w64
  and Visual Studio 2013 and newer. This fixes the printf mask warnings
  in examples and tests. E.g. [1]

- conncache: fix printf format string [2].

- http2: fix potential null pointer dereference [3].
  (seen on Slackware with gcc 11.)

- libssh: fix printf format string in SFTP code [4].
  Also make MSVC builds compatible with old CRT versions.

- libssh2: fix printf format string in SFTP code for MSVC.
  Applying the same fix as for libssh above.

- unit1395: fix `argument is null` and related issues [5]:
  - stop calling `strcmp()` with NULL to avoid undefined behaviour.
  - fix checking results if some of them were NULL.
  - do not pass NULL to printf `%s`.

- ci: keep a build job with `-std=gnu89` to continue testing for
  C89-compliance. We can apply this to other gcc jobs as needed.
  Ref: b23ce2cee7329bbf425f18b49973b7a5f23dfcb4 (2022-09-23) #9542

[1] https://dev.azure.com/daniel0244/curl/_build/results?buildId=18581&view=logs&jobId=ccf9cc6d-2ef1-5cf2-2c09-30f0c14f923b
[2] https://github.com/curl/curl/actions/runs/6896854263/job/18763831142?pr=12346#step:6:67
[3] https://github.com/curl/curl/actions/runs/6896854253/job/18763839238?pr=12346#step:30:214
[4] https://github.com/curl/curl/actions/runs/6896854253/job/18763838007?pr=12346#step:29:895
[5] https://github.com/curl/curl/actions/runs/6896854253/job/18763836775?pr=12346#step:33:1689

Closes #12346

20 months agoautotools: fix/improve gcc and Apple clang version detection
Viktor Szakats [Sun, 19 Nov 2023 23:31:40 +0000 (23:31 +0000)] 
autotools: fix/improve gcc and Apple clang version detection

- Before this patch we expected `n.n` `-dumpversion` output, but Ubuntu
  may return `n-win32` (also with `-dumpfullversion`). Causing these
  errors and failing to enable picky warnings:
  ```
  ../configure: line 23845: test: : integer expression expected
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/6263453828/job/17007893718#step:5:143

  Fix that by stripping any dash-suffix and handling a dotless (major-only)
  version number by assuming `.0` in that case.

  `9.3-posix`, `9.3-win32`, `6`, `9.3.0`, `11`, `11.2`, `11.2.0`
  Ref: https://github.com/mamedev/mame/pull/9767

- fix Apple clang version detection for releases between
  'Apple LLVM version 7.3.0' and 'Apple LLVM version 10.0.1' where the
  version was under-detected as 3.7 llvm/clang equivalent.

- fix Apple clang version detection for 'Apple clang version 11.0.0'
  and newer where the Apple clang version was detected, instead of its
  llvm/clang equivalent.

- display detected clang/gcc/icc compiler version.

Via libssh2:
- https://github.com/libssh2/libssh2/commit/00a3b88c51cdb407fbbb347a2e38c5c7d89875ad
  https://github.com/libssh2/libssh2/pull/1187
- https://github.com/libssh2/libssh2/commit/89ccc83c7da73e7ca3a112e350008131942b592e
  https://github.com/libssh2/libssh2/pull/1232

Closes #12362

20 months agoautotools: delete LCC compiler support bits
Viktor Szakats [Sun, 19 Nov 2023 17:45:24 +0000 (17:45 +0000)] 
autotools: delete LCC compiler support bits

Follow-up to fd7ef00f4305a2919e6950def1cf83d0110a4acd #12222

Closes #12357

20 months agocmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API`
Viktor Szakats [Fri, 17 Nov 2023 21:42:54 +0000 (21:42 +0000)] 
cmake: add test for `DISABLE` options, add `CURL_DISABLE_HEADERS_API`

- tests: verify CMake `DISABLE` options.

  Make an exception for 2 CMake-only ones, and one more that's
  using a different naming scheme, also in autotools and source.

- cmake: add support for `CURL_DISABLE_HEADERS_API`.

Suggested-by: Daniel Stenberg
Ref: https://github.com/curl/curl/pull/12345#pullrequestreview-1736238641

Closes #12353

20 months agohyper: temporarily remove HTTP/2 support
Jacob Hoffman-Andrews [Tue, 24 Oct 2023 14:51:05 +0000 (07:51 -0700)] 
hyper: temporarily remove HTTP/2 support

The current design of the Hyper integration requires rebuilding the
Hyper clientconn for each request. However, building the clientconn
requires resending the HTTP/2 connection preface, which is incorrect
from a protocol perspective. That in turn causes servers to send GOAWAY
frames, effectively degrading performance to "no connection reuse" in
the best case. It may also be triggering some bugs where requests get
dropped entirely and reconnects take too long.

This doesn't rule out HTTP/2 support with Hyper, but it may take a
redesign of the Hyper integration in order to make things work.

Closes #12191

20 months agoschannel: fix unused variable warning
Jay Satiro [Sun, 19 Nov 2023 23:06:55 +0000 (18:06 -0500)] 
schannel: fix unused variable warning

Bug: https://github.com/curl/curl/pull/12349#issuecomment-1818000846
Reported-by: Viktor Szakats
Closes https://github.com/curl/curl/pull/12361

20 months agourl: find scheme with a "perfect hash"
Daniel Stenberg [Fri, 17 Nov 2023 12:04:13 +0000 (13:04 +0100)] 
url: find scheme with a "perfect hash"

Instead of a loop to scan over the potentially 30+ scheme names, this
uses a "perfect hash" table. This works fine because the set of schemes
is known and cannot change in a build. The hash algorithm and table size
is made to only make a single scheme index per table entry.

The perfect hash is generated by a separate tool (scripts/schemetable.c)

Closes #12347

20 months agoscripts: add schemetable.c
Daniel Stenberg [Fri, 17 Nov 2023 12:33:17 +0000 (13:33 +0100)] 
scripts: add schemetable.c

This tool generates a scheme-matching table.

It iterates over a number of different initial and shift values in order
to find the hash algorithm that needs the smallest possible table.

The generated hash function, table and table size then needs to be used
by the url.c:Curl_getn_scheme_handler() function.

20 months agovtls/vquic, keep peer name information together
Stefan Eissing [Fri, 17 Nov 2023 14:26:08 +0000 (15:26 +0100)] 
vtls/vquic, keep peer name information together

- add `struct ssl_peer` to keep hostname, dispname and sni
  for a filter
- allocate `sni` for use in VTLS backend
- eliminate `Curl_ssl_snihost()` and its use of the download buffer
- use ssl_peer in SSL and QUIC filters

Closes #12349

20 months agobuild: always revert `#pragma GCC diagnostic` after use
Viktor Szakats [Fri, 17 Nov 2023 19:13:13 +0000 (19:13 +0000)] 
build: always revert `#pragma GCC diagnostic` after use

Before this patch some source files were overriding gcc warning options,
but without restoring them at the end of the file. In CMake UNITY builds
these options spilled over to the remainder of the source code,
effecitvely disabling them for a larger portion of the codebase than
intended.

`#pragma clang diagnostic` didn't have such issue in the codebase.

Reviewed-by: Marcel Raad
Closes #12352

20 months agotidy-up: casing typos, delete unused Windows version aliases
Viktor Szakats [Wed, 15 Nov 2023 22:31:44 +0000 (22:31 +0000)] 
tidy-up: casing typos, delete unused Windows version aliases

- cmake: fix casing of `UnixSockets` to match the rest of the codebase.

- curl-compilers.m4: fix casing in a comment.

- setup-win32: delete unused Windows version constant aliases.

Reviewed-by: Marcel Raad
Closes #12351

20 months agokeylog: disable if unused
Viktor Szakats [Fri, 17 Nov 2023 16:45:40 +0000 (16:45 +0000)] 
keylog: disable if unused

Fully disable keylog code if there is no TLS or QUIC subsystem using it.

Closes #12350

20 months agocmake: add `CURL_DISABLE_BINDLOCAL` option
Viktor Szakats [Thu, 16 Nov 2023 21:08:49 +0000 (21:08 +0000)] 
cmake: add `CURL_DISABLE_BINDLOCAL` option

To match similar autotools option.

Default is `ON`.

Reviewed-by: Daniel Stenberg
Closes #12345

20 months agourl: fix `-Wzero-length-array` with no protocols
Viktor Szakats [Thu, 16 Nov 2023 18:52:13 +0000 (18:52 +0000)] 
url: fix `-Wzero-length-array` with no protocols

Fixes:
```
./lib/url.c:178:56: warning: use of an empty initializer is a C2x extension [-Wc2x-extensions]
  178 | static const struct Curl_handler * const protocols[] = {
      |                                                        ^
./lib/url.c:178:56: warning: zero size arrays are an extension [-Wzero-length-array]
```

Closes #12344

20 months agourl: fix builds with `CURL_DISABLE_HTTP`
Viktor Szakats [Thu, 16 Nov 2023 16:50:27 +0000 (16:50 +0000)] 
url: fix builds with `CURL_DISABLE_HTTP`

Fixes:
```
./lib/url.c:456:35: error: no member named 'formp' in 'struct UrlState'
  456 |   Curl_mime_cleanpart(data->state.formp);
      |                       ~~~~~~~~~~~ ^
```

Regression from 74b87a8af13a155c659227f5acfa78243a8b2aa6 #11682

Closes #12343

20 months agohttp: fix `-Wunused-parameter` with no auth and no proxy
Viktor Szakats [Thu, 16 Nov 2023 12:39:01 +0000 (12:39 +0000)] 
http: fix `-Wunused-parameter` with no auth and no proxy

```
lib/http.c:734:26: warning: unused parameter 'proxy' [-Wunused-parameter]
                    bool proxy)
                         ^
```

Reviewed-by: Marcel Raad
Closes #12338

20 months agoTODO: Some TLS options are not offered for HTTPS proxies
Daniel Stenberg [Thu, 16 Nov 2023 15:48:16 +0000 (16:48 +0100)] 
TODO: Some TLS options are not offered for HTTPS proxies

Closes #12286
Closes #12342

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Thu, 16 Nov 2023 14:59:12 +0000 (15:59 +0100)] 
RELEASE-NOTES: synced

20 months agoduphandle: make dupset() not return with pointers to old alloced data
Daniel Stenberg [Thu, 16 Nov 2023 09:04:35 +0000 (10:04 +0100)] 
duphandle: make dupset() not return with pointers to old alloced data

As the blob pointers are to be duplicated, the function must not return
mid-function with lingering pointers to the old handle's allocated data,
as that would lead to double-free in OOM situations.

Make sure to clear all destination pointers first to avoid this risk.

Closes #12337

20 months agohttp: fix `-Wunused-variable` compiler warning
Viktor Szakats [Thu, 16 Nov 2023 00:12:54 +0000 (00:12 +0000)] 
http: fix `-Wunused-variable` compiler warning

Fix compiler warnings in builds with disabled auths, NTLM and SPNEGO.

E.g. with `CURL_DISABLE_BASIC_AUTH` + `CURL_DISABLE_BEARER_AUTH` +
`CURL_DISABLE_DIGEST_AUTH` + `CURL_DISABLE_NEGOTIATE_AUTH` +
`CURL_DISABLE_NTLM` on non-Windows.

```
./curl/lib/http.c:737:12: warning: unused variable 'result' [-Wunused-variable]
  CURLcode result = CURLE_OK;
           ^
./curl/lib/http.c:995:18: warning: variable 'availp' set but not used [-Wunused-but-set-variable]
  unsigned long *availp;
                 ^
./curl/lib/http.c:996:16: warning: variable 'authp' set but not used [-Wunused-but-set-variable]
  struct auth *authp;
               ^
```

Regression from e92edfbef64448ef461117769881f3ed776dec4e #11490

Fixes #12228
Closes #12335

20 months agotool: support bold headers in Windows
Jay Satiro [Tue, 14 Nov 2023 09:11:04 +0000 (04:11 -0500)] 
tool: support bold headers in Windows

- If virtual terminal processing is enabled in Windows then use ANSI
  escape codes Esc[1m and Esc[22m to turn bold on and off.

Suggested-by: Gisle Vanem
Ref: https://github.com/curl/curl/discussions/11770

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

20 months agobuild: fix libssh2 + `CURL_DISABLE_DIGEST_AUTH` + `CURL_DISABLE_AWS`
Viktor Szakats [Wed, 15 Nov 2023 15:58:11 +0000 (15:58 +0000)] 
build: fix libssh2 + `CURL_DISABLE_DIGEST_AUTH` + `CURL_DISABLE_AWS`

Builds with libssh2 + `-DCURL_DISABLE_DIGEST_AUTH=ON` +
`-DCURL_DISABLE_AWS=ON` in combination with either Schannel on Windows,
or `-DCURL_DISABLE_NTLM=ON` on other operating systems failed while
compiling due to a missing HMAC declaration.

The reason is that HMAC is required by `lib/sha256.c` which publishes
`Curl_sha256it()` which is required by `lib/vssh/libssh2.c` when
building for libssh2 v1.8.2 (2019-05-25) or older.

Make sure to compile the HMAC bits for a successful build.

Both HMAC and `Curl_sha256it()` rely on the same internals, so splitting
them into separate sources isn't practical.

Fixes:
```
[...]
In file included from ./curl/_x64-win-ucrt-cmake-llvm-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c:310:
./curl/lib/sha256.c:527:42: error: array has incomplete element type 'const struct HMAC_params'
  527 | const struct HMAC_params Curl_HMAC_SHA256[] = {
      |                                          ^
./curl/lib/curl_sha256.h:34:21: note: forward declaration of 'struct HMAC_params'
[...]
```

Regression from e92edfbef64448ef461117769881f3ed776dec4e #11490

Fixes #12273
Closes #12332

20 months agoduphandle: also free 'outcurl->cookies' in error path
Daniel Stenberg [Wed, 15 Nov 2023 10:48:32 +0000 (11:48 +0100)] 
duphandle: also free 'outcurl->cookies' in error path

Fixes memory-leak when OOM mid-function

Use plain free instead of safefree, since the entire struct is
freed below.

Remove some free calls that is already freed in Curl_freeset()

Closes #12329

20 months agoconfig-win32: set `HAVE_SNPRINTF` for mingw-w64
Viktor Szakats [Wed, 15 Nov 2023 02:54:43 +0000 (02:54 +0000)] 
config-win32: set `HAVE_SNPRINTF` for mingw-w64

It's available in all mingw-w64 releases. We already pre-fill this
detection in CMake.

Closes #12325

20 months agosasl: fix `-Wunused-function` compiler warning
Viktor Szakats [Wed, 15 Nov 2023 03:10:04 +0000 (03:10 +0000)] 
sasl: fix `-Wunused-function` compiler warning

In builds with disabled auths.

```
lib/curl_sasl.c:266:17: warning: unused function 'get_server_message' [-Wunused-function]
static CURLcode get_server_message(struct SASL *sasl, struct Curl_easy *data,
                ^
1 warning generated.
```
Ref: https://github.com/curl/trurl/actions/runs/6871732122/job/18689066151#step:3:3822

Reviewed-by: Daniel Stenberg
Closes #12326

20 months agobuild: picky warning updates
Viktor Szakats [Wed, 15 Nov 2023 00:32:43 +0000 (00:32 +0000)] 
build: picky warning updates

- cmake: sync some picky gcc warnings with autotools.
- cmake, autotools: add `-Wold-style-definition` for clang too.
- cmake: more precise version info for old clang options.
- cmake: use `IN LISTS` syntax in `foreach()`.

Reviewed-by: Daniel Stenberg
Reviewed-by: Marcel Raad
Closes #12324

20 months agourldata: move cookielist from UserDefined to UrlState
Daniel Stenberg [Tue, 14 Nov 2023 21:52:18 +0000 (22:52 +0100)] 
urldata: move cookielist from UserDefined to UrlState

1. Because the value is not strictly set with a setopt option.

2. Because otherwise when duping a handle when all the set.* fields are
   first copied and an error happens (think out of memory mid-function),
   the function would easily free the list *before* it was deep-copied,
   which could lead to a double-free.

Closes #12323

20 months agoautotools: avoid passing `LDFLAGS` twice to libcurl
Viktor Szakats [Mon, 13 Nov 2023 00:02:45 +0000 (00:02 +0000)] 
autotools: avoid passing `LDFLAGS` twice to libcurl

autotools passes `LDFLAGS` automatically linker commands. curl's
`lib/Makefile.am` customizes libcurl linker flags. In that
customization, it added `LDFLAGS` to the custom flags. This resulted in
passing `LDFLAGS` _twice_ to the `libtool` command.

Most of the time this is benign, but some `LDFLAGS` options can break
the build when passed twice. One such example is passing `.o` files,
e.g. `crt*.o` files necessary when customizing the C runtime, e.g. for
MUSL builds.

Passing them twice resulted in duplicate symbol errors:
```
libtool: link:  clang-15 --target=aarch64-unknown-linux-musl [...] /usr/lib/aarch64-linux-musl/crt1.o [...] /usr/lib/aarch64-linux-musl/crt1.o [...]
ld.lld-15: error: duplicate symbol: _start
>>> defined at crt1.c
>>>            /usr/lib/aarch64-linux-musl/crt1.o:(.text+0x0)
>>> defined at crt1.c
>>>            /usr/lib/aarch64-linux-musl/crt1.o:(.text+0x0)
[...]
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

This behaviour came with commit 1a593191c2769a47b8c3e4d9715ec9f6dddf5e36
(2013-07-23) as a fix for bug https://curl.haxx.se/bug/view.cgi?id=1217.
The patch was a works-for-me hack that ended up merged in curl:
https://sourceforge.net/p/curl/bugs/1217/#06ef
With the root cause remaining unclear.

Perhaps the SUNPro 12 linker was sensitive to `-L` `-l` order, requiring
`-L` first? This would be unusual and suggests a bug in either the
linker or in `libtool`.

The curl build does pass the list of detected libs via its own
`LIBCURL_LIBS` variable, which ends up before `LDFLAGS` on the `libtool`
command line, but it's the job of `libtool` to ensure that even
a peculiar linker gets the options in the expected order. Also because
autotools passes `LDFLAGS` last, making it hardly possible to pass
anything after it.

Perhaps in the 10 years since this issue, this already got a fix
upstream.

This patch deletes `LDFLAGS` from our customized libcurl options,
leaving a single copy of them as passed by autotools automatically.

Reverts 1a593191c2769a47b8c3e4d9715ec9f6dddf5e36
Closes #12310

20 months agoautotools: accept linker flags via `CURL_LDFLAGS_{LIB,BIN}`
Viktor Szakats [Mon, 13 Nov 2023 00:02:45 +0000 (00:02 +0000)] 
autotools: accept linker flags via `CURL_LDFLAGS_{LIB,BIN}`

To allow passing `LDFLAGS` specific to libcurl (`CURL_LDFLAGS_LIB`) and
curl tool (`CURL_LDFLAGS_BIN`).

This makes it possible to build libcurl and curl with a single
invocation with lib- and tool-specific custom linker flags.

Such flag can be enabling `.map` files, a `.def` file for libcurl DLL,
controlling static/shared, incl. requesting a static curl tool (with
`-static-libtool-libs`) while building both shared and static libcurl.

curl-for-win uses the above and some more.

These options are already supported in `Makefile.mk`. CMake has built-in
variables for this.

Closes #12312

20 months agotool_cb_hdr: add an additional parsing check
Jay Satiro [Tue, 14 Nov 2023 06:19:14 +0000 (01:19 -0500)] 
tool_cb_hdr: add an additional parsing check

- Don't dereference the past-the-end element when parsing the server's
  Content-disposition header.

As 'p' is advanced it can point to the past-the-end element and prior
to this change 'p' could be dereferenced in that case.

Technically the past-the-end element is not out of bounds because dynbuf
(which manages the header line) automatically adds a null terminator to
every buffer and that is not included in the buffer length passed to
the header callback.

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

20 months ago.cirrus.yml: freebsd 14
Philip H [Sat, 7 Oct 2023 13:45:14 +0000 (15:45 +0200)] 
.cirrus.yml: freebsd 14

ensure curl works on latest freebsd version

Closes #12053

20 months agoeasy: in duphandle, init the cookies for the new handle
Daniel Stenberg [Mon, 13 Nov 2023 18:55:28 +0000 (19:55 +0100)] 
easy: in duphandle, init the cookies for the new handle

... not the source handle.

Closes #12318

20 months agoduphandle: use strdup to clone *COPYPOSTFIELDS if size is not set
Daniel Stenberg [Mon, 13 Nov 2023 14:50:24 +0000 (15:50 +0100)] 
duphandle: use strdup to clone *COPYPOSTFIELDS if size is not set

Previously it would unconditionally use the size, which is set to -1
when strlen is requested.

Updated test 544 to verify.

Closes #12317

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 13 Nov 2023 15:01:12 +0000 (16:01 +0100)] 
RELEASE-NOTES: synced

20 months agocurl_easy_duphandle.3: clarify how HSTS and alt-svc are duped
Daniel Stenberg [Mon, 13 Nov 2023 11:48:41 +0000 (12:48 +0100)] 
curl_easy_duphandle.3: clarify how HSTS and alt-svc are duped

Closes #12315

20 months agourldata: move hstslist from 'set' to 'state'
Daniel Stenberg [Mon, 13 Nov 2023 11:37:50 +0000 (12:37 +0100)] 
urldata: move hstslist from 'set' to 'state'

To make it work properly with curl_easy_duphandle(). This, because
duphandle duplicates the entire 'UserDefined' struct by plain copy while
'hstslist' is a linked curl_list of file names. This would lead to a
double-free when the second of the two involved easy handles were
closed.

Closes #12315

20 months agotest1900: verify duphandle with HSTS using multiple files
Daniel Stenberg [Mon, 13 Nov 2023 11:36:42 +0000 (12:36 +0100)] 
test1900: verify duphandle with HSTS using multiple files

Closes #12315

20 months agohttp: allow longer HTTP/2 request method names
Goro FUJI [Mon, 13 Nov 2023 01:18:47 +0000 (01:18 +0000)] 
http: allow longer HTTP/2 request method names

- Increase the maximum request method name length from 11 to 23.

For HTTP/1.1 and earlier there's not a specific limit in libcurl for
method length except that it is limited by the initial HTTP request
limit (DYN_HTTP_REQUEST). Prior to fc2f1e54 HTTP/2 was treated the same
and there was no specific limit.

According to Internet Assigned Numbers Authority (IANA) the longest
registered method is UPDATEREDIRECTREF which is 17 characters.

Also there are unregistered methods used by some companies that are
longer than 11 characters.

The limit was originally added by 61f52a97 but not used until fc2f1e54.

Ref: https://www.iana.org/assignments/http-methods/http-methods.xhtml

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

20 months agoCURLOPT_CAINFO_BLOB.3: explain what CURL_BLOB_COPY does
Jay Satiro [Mon, 6 Nov 2023 07:09:31 +0000 (02:09 -0500)] 
CURLOPT_CAINFO_BLOB.3: explain what CURL_BLOB_COPY does

- Add an explanation of the CURL_BLOB_COPY flag to CURLOPT_CAINFO_BLOB
  and CURLOPT_PROXY_CAINFO_BLOB docs.

All the other _BLOB option docs already have the same explanation.

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

20 months agotidy-up: dedupe Windows system libs in cmake
Viktor Szakats [Sat, 11 Nov 2023 18:38:02 +0000 (18:38 +0000)] 
tidy-up: dedupe Windows system libs in cmake

Reviewed-by: Daniel Stenberg
Closes #12307

20 months agoci: test with latest quiche release (0.19.0)
Junho Choi [Sun, 22 Oct 2023 10:55:05 +0000 (19:55 +0900)] 
ci: test with latest quiche release (0.19.0)

Closes #12180

20 months agoquiche: use quiche_conn_peer_transport_params()
Junho Choi [Sun, 22 Oct 2023 10:51:17 +0000 (19:51 +0900)] 
quiche: use quiche_conn_peer_transport_params()

In recent quiche, transport parameter API is separated
with quiche_conn_peer_transport_params().
(https://github.com/cloudflare/quiche/pull/1575)
It breaks with bulding with latest(post 0.18.0) quiche.

Closes #12180

20 months agoMakefile: generate the VC 14.20 project files at dist-time
Daniel Stenberg [Tue, 7 Nov 2023 10:03:32 +0000 (11:03 +0100)] 
Makefile: generate the VC 14.20 project files at dist-time

Follow-up to 28287092cc5a6d6ef8 (#12282)

Closes #12290

20 months agomisc: fix -Walloc-size warnings
Sam James [Tue, 7 Nov 2023 23:22:58 +0000 (23:22 +0000)] 
misc: fix -Walloc-size warnings

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:

```
src/tool_operate.c: In function ‘add_per_transfer’:
src/tool_operate.c:213:5: warning: allocation of insufficient size ‘1’ for type ‘struct per_transfer’ with size ‘480’ [-Walloc-size]
  213 |   p = calloc(sizeof(struct per_transfer), 1);
      |     ^
src/var.c: In function ‘addvariable’:
src/var.c:361:5: warning: allocation of insufficient size ‘1’ for type ‘struct var’ with size ‘32’ [-Walloc-size]
  361 |   p = calloc(sizeof(struct var), 1);
      |     ^
```

The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
    ```

So, just swap the number of members and size arguments to match the
prototype, as we're initialising 1 struct of size `sizeof(struct
...)`. GCC then sees we're not doing anything wrong.

Closes #12292

20 months agoIPFS: bugfixes
Mark Gaiser [Sat, 11 Nov 2023 12:08:59 +0000 (13:08 +0100)] 
IPFS: bugfixes

- Fixed endianness bug in gateway file parsing
- Use IPFS_PATH in tests where IPFS_DATA was used
- Fixed typos from traling -> trailing
- Fixed broken link in IPFS.md

Follow-up to 859e88f6533f9e

Reported-by: Michael Kaufmann
Bug: https://github.com/curl/curl/pull/12152#issuecomment-1798214137
Closes #12305

20 months agoVULN-DISCLOSURE-POLIC: remove broken link to hackerone
Daniel Stenberg [Sat, 11 Nov 2023 20:33:14 +0000 (21:33 +0100)] 
VULN-DISCLOSURE-POLIC: remove broken link to hackerone

It should ideally soon not be done from hackerone anyway

Closes #12308

20 months agoschannel: add CA cache support for files and memory blobs
Andrew Kurushin [Fri, 3 Nov 2023 15:25:00 +0000 (18:25 +0300)] 
schannel: add CA cache support for files and memory blobs

- Support CA bundle and blob caching.

Cache timeout is 24 hours or can be set via CURLOPT_CA_CACHE_TIMEOUT.

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

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Fri, 10 Nov 2023 22:25:58 +0000 (23:25 +0100)] 
RELEASE-NOTES: synced

20 months agocmake: option to disable install & drop `curlu` target when unused
Charlie C [Mon, 6 Nov 2023 21:19:00 +0000 (14:19 -0700)] 
cmake: option to disable install & drop `curlu` target when unused

This patch makes the following changes:
- adds the option `CURL_DISABLE_INSTALL` - to disable 'install' targets.
- Removes the target `curlu` when the option `BUILD_TESTING` is set to
  `OFF` - to prevent it from being loaded in Visual Studio.

Closes #12287

20 months agocmake: fix multiple include of CURL package
Kai Pastor [Fri, 22 Sep 2023 05:48:36 +0000 (07:48 +0200)] 
cmake: fix multiple include of CURL package

Fixes errors on second `find_package(CURL)`. This is a frequent case
with transitive dependencies:
```
CMake Error at ...:
  add_library cannot create ALIAS target "CURL::libcurl" because another
  target with the same name already exists.
```

Test to reproduce:
```cmake
cmake_minimum_required(VERSION 3.27)  # must be 3.18 or higher

project(curl)

set(CURL_DIR "example/lib/cmake/CURL/")
find_package(CURL CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)  # fails

add_executable(main main.c)
target_link_libraries(main CURL::libcurl)
```

Ref: https://cmake.org/cmake/help/latest/release/3.18.html#other-changes
Ref: https://cmake.org/cmake/help/v3.18/policy/CMP0107.html
Ref: #12300
Assisted-by: Harry Mallon
Closes #11913

20 months agotidy-up: use `OPENSSL_VERSION_NUMBER`
Viktor Szakats [Wed, 8 Nov 2023 04:39:54 +0000 (04:39 +0000)] 
tidy-up: use `OPENSSL_VERSION_NUMBER`

Uniformly use `OPENSSL_VERSION_NUMBER` to check for OpenSSL version.
Before this patch some places used `OPENSSL_VERSION_MAJOR`.

Also fix `lib/md4.c`, which included `opensslconf.h`, but that doesn't
define any version number in these implementations: BoringSSL, AWS-LC,
LibreSSL, wolfSSL. (Only in mainline OpenSSL/quictls). Switch that to
`opensslv.h`. This wasn't causing a deeper problem because the code is
looking for v3, which is only provided by OpenSSL/quictls as of now.

According to https://github.com/openssl/openssl/issues/17517, the macro
`OPENSSL_VERSION_NUMBER` is safe to use and not deprecated.

Reviewed-by: Marcel Raad
Closes #12298

20 months agoresolve.d: drop a multi use-sentence
Daniel Stenberg [Wed, 8 Nov 2023 10:05:41 +0000 (11:05 +0100)] 
resolve.d: drop a multi use-sentence

Since the `multi:` keyword adds that message.

Reported-by: 積丹尼 Dan Jacobson
Fixes https://github.com/curl/curl/discussions/12294
Closes #12295

20 months agocontent_encoding: make Curl_all_content_encodings allocless
Daniel Stenberg [Tue, 7 Nov 2023 09:58:08 +0000 (10:58 +0100)] 
content_encoding: make Curl_all_content_encodings allocless

- Fixes a memory leak pointed out by Coverity
- Also found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63947
- Avoids unncessary allocations

Follow-up ad051e1cbec68b2456a22661b

Closes #12289

20 months agovtls: use ALPN "http/1.1" for HTTP/1.x, including HTTP/1.0
Michael Kaufmann [Mon, 6 Nov 2023 16:15:59 +0000 (17:15 +0100)] 
vtls: use ALPN "http/1.1" for HTTP/1.x, including HTTP/1.0

Some servers don't support the ALPN protocol "http/1.0" (e.g. IIS 10),
avoid it and use "http/1.1" instead.

This reverts commit df856cb5c9 (#10183).

Fixes #12259
Closes #12285

20 months agoMakefile.am: drop vc10, vc11 and vc12 projects from dist
Daniel Stenberg [Tue, 7 Nov 2023 08:34:04 +0000 (09:34 +0100)] 
Makefile.am: drop vc10, vc11 and vc12 projects from dist

They are end of life products. Support for generating them remain in the
repo for a while but this change drops them from distribution.

Closes #12288

20 months agoprojects: add VC14.20 project files
David Suter [Mon, 6 Nov 2023 15:45:44 +0000 (15:45 +0000)] 
projects: add VC14.20 project files

Windows projects included VC14, VC14.10, VC14.30 but not VC14.20.
OpenSSL and Wolf SSL scripts mention VC14.20 so I don't see a reason why
this is missing. Updated the templates to produce a VC14.20 project.
Project opens in Visual Studio 2019 as expected.

Closes #12282

20 months agocurl: move IPFS code into src/tool_ipfs.[ch]
Daniel Stenberg [Mon, 6 Nov 2023 12:24:43 +0000 (13:24 +0100)] 
curl: move IPFS code into src/tool_ipfs.[ch]

- convert ensure_trailing into ensure_trailing_slash
- strdup the URL string to own it proper
- use shorter variable names
- combine some expressions
- simplify error handling in ipfs_gateway()
- add MAX_GATEWAY_URL_LEN + proper bailout if maximum is reached
- ipfs-gateway.d polish and simplification
- shorten ipfs error message + make them "synthetic"

Closes #12281

20 months agobuild: delete support bits for obsolete Windows compilers
Viktor Szakats [Sat, 28 Oct 2023 01:10:01 +0000 (01:10 +0000)] 
build: delete support bits for obsolete Windows compilers

- Pelles C: Unclear status, failed to obtain a fresh copy a few months
  ago. Possible website is HTTP-only. ~10 years ago I left this compiler
  dealing with crashes and other issues with no response on the forum
  for years. It has seen some activity in curl back in 2021.
- LCC: Last stable release in September 2002.
- Salford C: Misses winsock2 support, possibly abandoned? Last mentioned
  in 2006.
- Borland C++: We dropped Borland C++ support in 2018.
- MS Visual C++ 6.0: Released in 1998. curl already requires VS 2010
  (or possibly 2008) as a minimum.

Closes #12222

20 months agobuild: delete `HAVE_STDINT_H` and `HAVE_INTTYPES_H`
Viktor Szakats [Mon, 6 Nov 2023 02:17:39 +0000 (02:17 +0000)] 
build: delete `HAVE_STDINT_H` and `HAVE_INTTYPES_H`

We use `stdint.h` unconditionally in all places except one. These uses
are imposed by external dependencies / features. nghttp2, quic, wolfSSL
and `HAVE_MACH_ABSOLUTE_TIME` do require this C99 header. It means that
any of these features make curl require a C99 compiler. (In case of
MSVC, this means Visual Studio 2010 or newer.)

This patch changes the single use of `stdint.h` guarded by
`HAVE_STDINT_H` to use `stdint.h` unconditionally. Also stop using
`inttypes.h` as an alternative there. `HAVE_INTTYPES_H` wasn't used
anywhere else, allowing to delete this feature check as well.

Closes #12275

20 months agotool_operate: do not mix memory models
Daniel Stenberg [Mon, 6 Nov 2023 12:24:43 +0000 (13:24 +0100)] 
tool_operate: do not mix memory models

Make sure 'inputpath' only points to memory allocated by libcurl so that
curl_free works correctly.

Pointed out by Coverity

Follow-up to 859e88f6533f9e1f890

Closes #12280

20 months agolib: client writer, part 2, accounting + logging
Stefan Eissing [Mon, 23 Oct 2023 08:33:07 +0000 (10:33 +0200)] 
lib: client writer, part 2, accounting + logging

This PR has these changes:

Renaming of unencode_* to cwriter, e.g. client writers
- documentation of sendf.h functions
- move max decode stack checks back to content_encoding.c
- define writer phase which was used as order before
- introduce phases for monitoring inbetween decode phases
- offering default implementations for init/write/close

Add type paramter to client writer's do_write()
- always pass all writes through the writer stack
- writers who only care about BODY data will pass other writes unchanged

add RAW and PROTOCOL client writers
- RAW used for Curl_debug() logging of CURLINFO_DATA_IN
- PROTOCOL used for updates to data->req.bytecount, max_filesize checks and
  Curl_pgrsSetDownloadCounter()
- remove all updates of data->req.bytecount and calls to
  Curl_pgrsSetDownloadCounter() and Curl_debug() from other code
- adjust test457 expected output to no longer see the excess write

Closes #12184

20 months agoVULN-DISCLOSURE-POLICY: escape sequences are not a security flaw
Daniel Stenberg [Mon, 6 Nov 2023 07:39:29 +0000 (08:39 +0100)] 
VULN-DISCLOSURE-POLICY: escape sequences are not a security flaw

Closes #12278

20 months agorand: fix build error with autotools + LibreSSL
Viktor Szakats [Sun, 5 Nov 2023 23:27:55 +0000 (23:27 +0000)] 
rand: fix build error with autotools + LibreSSL

autotools unexpectedly detects `arc4random` because it is also looking
into dependency libs. One dependency, LibreSSL, happens to publish an
`arc4random` function (via its shared lib before v3.7, also via static
lib as of v3.8.2). When trying to use this function in `lib/rand.c`,
its protoype is missing. To fix that, curl included a prototype, but
that used a C99 type without including `stdint.h`, causing:

```
../../lib/rand.c:37:1: error: unknown type name 'uint32_t'
   37 | uint32_t arc4random(void);
      | ^
1 error generated.
```

This patch improves this by dropping the local prototype and instead
limiting `arc4random` use for non-OpenSSL builds. OpenSSL builds provide
their own random source anyway.

The better fix would be to teach autotools to not link dependency libs
while detecting `arc4random`.

LibreSSL publishing a non-namespaced `arc4random` tracked here:
https://github.com/libressl/portable/issues/928

Regression from 755ddbe901cd0c921fbc3ac5b3775c0dc683bc73 #10672

Reviewed-by: Daniel Stenberg
Fixes #12257
Closes #12274

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Sun, 5 Nov 2023 22:26:30 +0000 (23:26 +0100)] 
RELEASE-NOTES: synced

20 months agostrdup: do Curl_strndup without strncpy
Daniel Stenberg [Sat, 4 Nov 2023 22:47:05 +0000 (23:47 +0100)] 
strdup: do Curl_strndup without strncpy

To avoid (false positive) gcc-13 compiler warnings.

Follow-up to 4855debd8a2c1cb

Assisted-by: Jay Satiro
Reported-by: Viktor Szakats
Fixes #12258

20 months agoHTTP: fix empty-body warning
Enno Boland [Fri, 3 Nov 2023 19:00:38 +0000 (20:00 +0100)] 
HTTP: fix empty-body warning

This change fixes a compiler warning with gcc-12.2.0 when
`-DCURL_DISABLE_BEARER_AUTH=ON` is used.

    /home/tox/src/curl/lib/http.c: In function 'Curl_http_input_auth':
    /home/tox/src/curl/lib/http.c:1147:12: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
     1147 |            ;
          |            ^

Closes #12262

20 months agoopenssl: identify the "quictls" backend correctly
Daniel Stenberg [Sat, 4 Nov 2023 22:36:40 +0000 (23:36 +0100)] 
openssl: identify the "quictls" backend correctly

Since vanilla OpenSSL does not support the QUIC API I think it helps
users to identify the correct OpenSSL fork in version output. The best
(crude) way to do that right now seems to be to check if ngtcp2 support
is enabled.

Closes #12270

20 months agocurl: improved IPFS and IPNS URL support
Mark Gaiser [Wed, 18 Oct 2023 00:28:06 +0000 (02:28 +0200)] 
curl: improved IPFS and IPNS URL support

Previously just ipfs://<cid> and ipns://<cid> was supported, which is
too strict for some usecases.

This patch allows paths and query arguments to be used too.
Making this work according to normal http semantics:

 ipfs://<cid>/foo/bar?key=val
 ipns://<cid>/foo/bar?key=val

The gateway url support is changed.
It now only supports gateways in the form of:

 http://<gateway>/foo/bar
 http://<gateway>

Query arguments here are explicitly not allowed and trigger an intended
malformed url error.

There also was a crash when IPFS_PATH was set with a non trailing
forward slash. This has been fixed.

Lastly, a load of test cases have been added to verify the above.

Reported-by: Steven Allen
Fixes #12148
Closes #12152

20 months agodocs: KNOWN_BUGS cleanup
Harry Mallon [Wed, 1 Nov 2023 13:01:12 +0000 (13:01 +0000)] 
docs: KNOWN_BUGS cleanup

* Remove other mention of hyper memory-leaks from `KNOWN_BUGS`.
  Should have been removed in 629723ecf22a8eae78d64cceec2f3bdae703ec95

* Remove mention of aws-sigv4 sort query string from `KNOWN_BUGS`.
  Fixed in #11806

* Remove mention of aws-sigv4 query empty value problems

* Remove mention of aws-sigv4 missing amz-content-sha256
  Fixed in #9995

20 months agohttp_aws_sigv4: canonicalise valueless query params
Harry Mallon [Wed, 1 Nov 2023 14:46:46 +0000 (14:46 +0000)] 
http_aws_sigv4: canonicalise valueless query params

Fixes #8107
Closes #12244

20 months agodocs: preserve the modification date when copying the prebuilt man page
Michael Kaufmann [Sat, 28 Oct 2023 08:24:25 +0000 (10:24 +0200)] 
docs: preserve the modification date when copying the prebuilt man page

The previously built man page "curl.1" must be copied with the original
modification date, otherwise the man page is never updated.

This fixes a bug that has been introduced with commit 2568441cab.

Reviewed-by: Dan Fandrich
Reviewed-by: Daniel Stenberg
Closes #12199

20 months agodocs: remove bold from some man page SYNOPSIS sections
Daniel Stenberg [Sat, 4 Nov 2023 11:01:50 +0000 (12:01 +0100)] 
docs: remove bold from some man page SYNOPSIS sections

In the name of consistency

Closes #12267

20 months agoopenssl: two multi pointer checks should probably rather be asserts
Daniel Stenberg [Fri, 3 Nov 2023 23:01:28 +0000 (00:01 +0100)] 
openssl: two multi pointer checks should probably rather be asserts

... so add the asserts now and consider removing the dynamic checks in a
future.

Ref: #12261
Closes #12264

20 months agodocs: add supported version for the json write-out
boilingoden [Sat, 4 Nov 2023 08:05:13 +0000 (11:35 +0330)] 
docs: add supported version for the json write-out

xref: https://curl.se/changes.html#7_70_0

Closes #12266

20 months agoappveyor: make VS2008-built curl tool runnable
Viktor Szakats [Fri, 3 Nov 2023 22:31:49 +0000 (22:31 +0000)] 
appveyor: make VS2008-built curl tool runnable

By linking the CRT statically. This avoids the error about missing
runtime DLL `MSVCR90.dll` when running the freshly built `curl.exe`.

Closes #12263

20 months agourl: proxy ssl connection reuse fix
Stefan Eissing [Fri, 3 Nov 2023 10:46:14 +0000 (11:46 +0100)] 
url: proxy ssl connection reuse fix

- tunnel https proxy used for http: transfers does
  no check if proxy-ssl configuration matches
- test cases added, test_10_12 fails on 8.4.0

Closes #12255

21 months agocurl_sspi: support more revocation error names in error messages
Jay Satiro [Wed, 1 Nov 2023 07:18:53 +0000 (03:18 -0400)] 
curl_sspi: support more revocation error names in error messages

- Add these revocation errors to sspi error list:
  CRYPT_E_NO_REVOCATION_DLL, CRYPT_E_NO_REVOCATION_CHECK,
  CRYPT_E_REVOCATION_OFFLINE and CRYPT_E_NOT_IN_REVOCATION_DATABASE.

Prior to this change those error codes were not matched to their macro
name and instead shown as "unknown error".

Before:

schannel: next InitializeSecurityContext failed:
Unknown error (0x80092013) - The revocation function was
unable to check revocation because the revocation server was offline.

After:

schannel: next InitializeSecurityContext failed:
CRYPT_E_REVOCATION_OFFLINE (0x80092013) - The revocation function was
unable to check revocation because the revocation server was offline.

Bug: https://github.com/curl/curl/issues/12239
Reported-by: Niracler Li
Closes https://github.com/curl/curl/pull/12241

21 months agostrdup: don't allow Curl_strndup to read past a null terminator
Jay Satiro [Thu, 2 Nov 2023 22:56:06 +0000 (18:56 -0400)] 
strdup: don't allow Curl_strndup to read past a null terminator

- Use malloc + strncpy instead of Curl_memdup to dupe the string before
  null terminating it.

Prior to this change if Curl_strndup was passed a length longer than
the allocated string then it could copy out of bounds.

This change is for posterity. Curl_strndup was added in the parent
commit and currently none of the calls to it pass a length that would
cause it to read past the allocated length of the input.

Follow-up to d3b3ba35.

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

21 months agolib: add and use Curl_strndup()
Daniel Stenberg [Thu, 2 Nov 2023 12:47:15 +0000 (13:47 +0100)] 
lib: add and use Curl_strndup()

The Curl_strndup() function is similar to memdup(), but copies 'n' bytes
then adds a terminating null byte ('\0').

Closes #12251

21 months agoCURPOST_POSTFIELDS.3: add CURLOPT_COPYPOSTFIELDS in SEE ALSO
Daniel Stenberg [Thu, 2 Nov 2023 19:34:14 +0000 (20:34 +0100)] 
CURPOST_POSTFIELDS.3: add CURLOPT_COPYPOSTFIELDS in SEE ALSO

21 months agopytest: use lower count in repeat tests
Stefan Eissing [Thu, 2 Nov 2023 10:24:03 +0000 (11:24 +0100)] 
pytest: use lower count in repeat tests

- lower large iteration counts in some tests somewhat for
  the same coverage with less duration

Closes #12248

21 months agoRELEASE-NOTES: synced
Daniel Stenberg [Thu, 2 Nov 2023 15:30:15 +0000 (16:30 +0100)] 
RELEASE-NOTES: synced

21 months agodocs: clarify that curl passes on input unfiltered
Daniel Stenberg [Thu, 2 Nov 2023 12:05:10 +0000 (13:05 +0100)] 
docs: clarify that curl passes on input unfiltered

... for several options.

Reported-by: Ophir Lojkine
Closes #12249

21 months agourlapi: when URL encoding the fragment, pass in the right length
Daniel Stenberg [Thu, 2 Nov 2023 12:43:54 +0000 (13:43 +0100)] 
urlapi: when URL encoding the fragment, pass in the right length

A benign bug because it would only add an extra null terminator.

Made lib1560 get a test that runs this code.

Closes #12250