]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

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

2 years 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

2 years 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

2 years agovtls: late clone of connection ssl config
Stefan Eissing [Tue, 31 Oct 2023 14:25:08 +0000 (15:25 +0100)] 
vtls: late clone of connection ssl config

- perform connection cache matching against `data->set.ssl.primary`
  and proxy counterpart
- fully clone connection ssl config only when connection is used

Closes #12237

2 years agomsh3: error when built with CURL_DISABLE_SOCKETPAIR set
Stefan Eissing [Thu, 2 Nov 2023 10:40:59 +0000 (11:40 +0100)] 
msh3: error when built with CURL_DISABLE_SOCKETPAIR set

Reported-by: Gisle Vanem
Closes #12252
Fixes #12213

2 years agohsts: skip single-dot hostname
Daniel Stenberg [Thu, 2 Nov 2023 09:52:46 +0000 (10:52 +0100)] 
hsts: skip single-dot hostname

Reported-by: Maksymilian Arciemowicz
Closes #12247

2 years agovtls: fix build without proxy
Daniel Stenberg [Wed, 1 Nov 2023 09:52:21 +0000 (10:52 +0100)] 
vtls: fix build without proxy

Follow-up to bf0e278a3c54bc7fee7360da17c

closes #12243

2 years agodocs/example/keepalive.c: show TCP keep-alive options
Daniel Stenberg [Wed, 1 Nov 2023 09:36:45 +0000 (10:36 +0100)] 
docs/example/keepalive.c: show TCP keep-alive options

Closes #12242

2 years agolib1560: verify appending blank URL encoded query string
Daniel Stenberg [Tue, 31 Oct 2023 15:22:39 +0000 (16:22 +0100)] 
lib1560: verify appending blank URL encoded query string

2 years agourlapi: skip appending NULL pointer query
Daniel Stenberg [Tue, 31 Oct 2023 15:22:07 +0000 (16:22 +0100)] 
urlapi: skip appending NULL pointer query

Reported-by: kirbyn17 on hackerone
Closes #12240

2 years agolib1560: verify setting host to "" with and without URL encode
Daniel Stenberg [Tue, 31 Oct 2023 10:35:25 +0000 (11:35 +0100)] 
lib1560: verify setting host to "" with and without URL encode

2 years agourlapi: avoid null deref if setting blank host to url encode
Daniel Stenberg [Tue, 31 Oct 2023 10:24:13 +0000 (11:24 +0100)] 
urlapi: avoid null deref if setting blank host to url encode

Reported-by: kirbyn17 on hackerone
Closes #12240

2 years agodynbuf: assert for NULL pointer inputs
Daniel Stenberg [Tue, 31 Oct 2023 15:21:35 +0000 (16:21 +0100)] 
dynbuf: assert for NULL pointer inputs

Help us catch more mistakes.

Closes #12238

2 years agoHTTP3: ngtcp2 builds are no longer experimental
Daniel Stenberg [Tue, 17 Oct 2023 16:04:50 +0000 (18:04 +0200)] 
HTTP3: ngtcp2 builds are no longer experimental

The other HTTP/3 backends are still experimental.

Closes #12235

2 years agovtls: cleanup SSL config management
Stefan Eissing [Thu, 26 Oct 2023 09:27:42 +0000 (11:27 +0200)] 
vtls: cleanup SSL config management

- remove `Curl_ssl_get_config()`, no longer needed

Closes #12204

2 years agolibcurl-thread.3: simplify the TLS section
Daniel Stenberg [Mon, 30 Oct 2023 20:26:40 +0000 (21:26 +0100)] 
libcurl-thread.3: simplify the TLS section

All TLS libraries curl can use are threadsafe since OpenSSL 1.1.x, August
2016.

Closes #12233

2 years agoconfigure: better --disable-http
Daniel Stenberg [Sat, 28 Oct 2023 09:05:13 +0000 (11:05 +0200)] 
configure: better --disable-http

- disable HTTPS-proxy as well, since it can't work without HTTP

- curl_setup: when HTTP is disabled, also disable all features that are
  HTTP-only

- version: HTTPS-proxy only exists if HTTP support exists

Closes #12223

2 years agohttp: consider resume with CURLOPT_FAILONERRROR and 416 to be fine
Daniel Stenberg [Sat, 21 Oct 2023 12:32:30 +0000 (14:32 +0200)] 
http: consider resume with CURLOPT_FAILONERRROR and 416 to be fine

Finding a 'Content-Range:' in the response changed the handling.

Add test case 1475 to verify -C - with 416 and Content-Range: header,
which is almost exactly like test 194 which instead uses a fixed -C
offset. Adjusted test 194 to also be considered fine.

Fixes #10521
Reported-by: Smackd0wn
Fixes #12174
Reported-by: Anubhav Rai
Closes #12176

2 years agoGHA: fix checkout of quictls repository to use correct branch name
Stefan Eissing [Mon, 30 Oct 2023 14:16:49 +0000 (15:16 +0100)] 
GHA: fix checkout of quictls repository to use correct branch name

Follow-up to c868b0e30f10cd0ac7

Closes #12232

2 years agodocs/example/localport.c: show off CURLOPT_LOCALPORT
Daniel Stenberg [Mon, 30 Oct 2023 10:48:19 +0000 (11:48 +0100)] 
docs/example/localport.c: show off CURLOPT_LOCALPORT

Closes #12230

2 years agodocs/examples/interface.c: show CURLOPT_INTERFACE use
Daniel Stenberg [Mon, 30 Oct 2023 10:40:07 +0000 (11:40 +0100)] 
docs/examples/interface.c: show CURLOPT_INTERFACE use

Although super simple.

Closes #12229

2 years agobuild: fix compiler warning with auths disabled
Viktor Szakats [Sun, 29 Oct 2023 20:37:20 +0000 (20:37 +0000)] 
build: fix compiler warning with auths disabled

```
./curl/lib/http.c:979:12: warning: unused function 'is_valid_auth_separator' [-Wunused-function]
static int is_valid_auth_separator(char ch)
           ^
5 warnings generated.
```

Follow-up to e92edfbef64448ef461117769881f3ed776dec4e #11490

Closes #12227

2 years agobuild: require Windows XP or newer
Viktor Szakats [Sat, 28 Oct 2023 10:52:23 +0000 (10:52 +0000)] 
build: require Windows XP or newer

After this patch we assume availability of `getaddrinfo` and
`freeaddrinfo`, first introduced in Windows XP. Meaning curl
now requires building for Windows XP as a minimum.

TODO: assume these also in autotools.

Ref: https://github.com/curl/curl/pull/12221#issuecomment-1783761806
Closes #12225

2 years agoappveyor: bump one job to OpenSSL 3.1 (was 1.1.1)
Viktor Szakats [Sun, 29 Oct 2023 18:15:11 +0000 (18:15 +0000)] 
appveyor: bump one job to OpenSSL 3.1 (was 1.1.1)

Use 3.1 with the modern runner image.

We still use 1.1.1 in 8 jobs.

1.1.1 is EOL since 2023-09-11:
https://www.openssl.org/blog/blog/2023/03/28/1.1.1-EOL/

Also:
- add missing SSL-backend to job descriptions.
- tidy up CPU in job descriptions.

Closes #12226

2 years agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 30 Oct 2023 07:48:26 +0000 (08:48 +0100)] 
RELEASE-NOTES: synced

2 years agoGHA: bump ngtcp2, nghttp3, nghttp2 and quictls versions
Daniel Stenberg [Fri, 27 Oct 2023 14:37:41 +0000 (16:37 +0200)] 
GHA: bump ngtcp2, nghttp3, nghttp2 and quictls versions

ngtcp2 1.0.1
nghttp3 1.0.0
nghttp2 1.58.0
quictls 3.1.4+quic

also sync HTTP3.md with these changes

Closes #12132

2 years agowolfssl: add default case for wolfssl_connect_step1 switch
Kareem [Fri, 27 Oct 2023 21:23:33 +0000 (14:23 -0700)] 
wolfssl: add default case for wolfssl_connect_step1 switch

Closes #12218

2 years agocurl_setup: disallow Windows IPv6 builds missing getaddrinfo
Jay Satiro [Sat, 28 Oct 2023 04:23:40 +0000 (00:23 -0400)] 
curl_setup: disallow Windows IPv6 builds missing getaddrinfo

- On Windows if IPv6 is enabled but getaddrinfo is missing then #error
  the build.

curl can be built with IPv6 support (ENABLE_IPV6) but without the
ability to resolve hosts to IPv6 addresses (HAVE_GETADDRINFO). On
Windows this is highly unlikely and should be considered a bad build
configuration.

Such a bad configuration has already given us a bug that was hard to
diagnose. See #12134 and #12136 for discussion.

Ref: https://github.com/curl/curl/issues/12134
Ref: https://github.com/curl/curl/pull/12136

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

2 years agoopenssl: make CURLSSLOPT_NATIVE_CA import Windows intermediate CAs
Nico Rieck [Mon, 23 Oct 2023 10:38:19 +0000 (12:38 +0200)] 
openssl: make CURLSSLOPT_NATIVE_CA import Windows intermediate CAs

- If CURLSSLOPT_NATIVE_CA on Windows then import from intermediate CA
  "CA" store after importing from root CA "ROOT" store.

This change allows curl to work in situations where a server does not
send all intermediate certs and they are present in the "CA" store (the
store with intermediate CAs). This is already allowed by the Schannel
backend.

Also this change makes partial chain verification possible for those
certs since we allow partial chain verification by default for OpenSSL
(unless CURLSSLOPT_NO_PARTIALCHAIN). This is not allowed by the Schannel
backend.

Prior to this change CURLSSLOPT_NATIVE_CA only imported "ROOT" certs.

Fixes https://github.com/curl/curl/issues/12155
Closes https://github.com/curl/curl/pull/12185

2 years agoMakefile.mk: fix `-rtmp` option for non-Windows [ci skip]
Viktor Szakats [Sat, 28 Oct 2023 10:06:43 +0000 (10:06 +0000)] 
Makefile.mk: fix `-rtmp` option for non-Windows [ci skip]

2 years agoasyn-ares: handle no connection in the addrinfo callback
Daniel Stenberg [Fri, 27 Oct 2023 22:22:49 +0000 (00:22 +0200)] 
asyn-ares: handle no connection in the addrinfo callback

To avoid crashing.

Follow-up from 56a4db2
Closes #12219

2 years agohostip6: fix DEBUG_ADDRINFO builds
Jay Satiro [Fri, 27 Oct 2023 07:40:05 +0000 (03:40 -0400)] 
hostip6: fix DEBUG_ADDRINFO builds

- Removed unused and incorrect parameter from dump_addrinfo().

Bug: https://github.com/curl/curl/commit/56a4db2e#commitcomment-131050442
Reported-by: Gisle Vanem
Closes https://github.com/curl/curl/pull/12212

2 years agoMakefile.mk: restore `_mingw.h` for default `_WIN32_WINNT`
Viktor Szakats [Fri, 27 Oct 2023 10:20:47 +0000 (10:20 +0000)] 
Makefile.mk: restore `_mingw.h` for default `_WIN32_WINNT`

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

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

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

Regression from 38029101e2d78ba125732b3bab6ec267b80a0e72 #11625

Reported-by: zhengqwe on github
Helped-by: Nico Rieck
Fixes #12134
Fixes #12136
Closes #12217

2 years agohostip: silence compiler warning `-Wparentheses-equality`
Viktor Szakats [Fri, 27 Oct 2023 09:48:41 +0000 (09:48 +0000)] 
hostip: silence compiler warning `-Wparentheses-equality`

Seen with LLVM 17.

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

Follow-up to b651aba0962bb31353f55de4dc35f745952a1b10 #12145

Reviewed-by: Daniel Stenberg
Closes #12215

2 years agodoh: use PIPEWAIT when HTTP/2 is attempted
Stefan Eissing [Fri, 27 Oct 2023 09:26:19 +0000 (11:26 +0200)] 
doh: use PIPEWAIT when HTTP/2 is attempted

Closes #12214

2 years agosetopt: remove outdated cookie comment
Daniel Stenberg [Thu, 26 Oct 2023 14:11:01 +0000 (16:11 +0200)] 
setopt: remove outdated cookie comment

Closes #12206

2 years agocfilter: provide call to tell connection to forget a socket
Stefan Eissing [Thu, 26 Oct 2023 15:02:45 +0000 (17:02 +0200)] 
cfilter: provide call to tell connection to forget a socket

- fixed libssh.c workaround for a socket being closed by
  the library
- eliminate the terrible hack in cf-socket.c to guess when
  this happened and try not closing the socket again.
- fixes race in eyeballing when socket could have failed to
  be closed for a discarded connect attempt

Closes #12207

2 years agourl: protocol handler lookup tidy-up
Stefan Eissing [Fri, 27 Oct 2023 09:53:26 +0000 (11:53 +0200)] 
url: protocol handler lookup tidy-up

- rename lookup to what it does
- use ARRAYSIZE instead of NULL check for end
- offer alternate lookup for 0-terminated strings

Closes #12216

2 years agobuild: variadic macro tidy-ups
Viktor Szakats [Fri, 13 Oct 2023 00:25:20 +0000 (00:25 +0000)] 
build: variadic macro tidy-ups

- delete unused `HAVE_VARIADIC_MACROS_C99/GCC` feature checks.
  (both autotools and CMake.)
- delete duplicate `NULL` check in `Curl_trc_cf_infof()`.
- fix compiler warning in `CURL_DISABLE_VERBOSE_STRINGS` builds.
  ```
  ./lib/cf-socket.c:122:41: warning: unused parameter 'data' [-Wunused-parameter]
  static void nosigpipe(struct Curl_easy *data,
                                          ^
  ```
- fix `#ifdef` comments in `lib/curl_trc.{c,h}`.
- fix indentation in some `infof()` calls.

Follow-up to dac293cfb7026b1ca4175d88b80f1432d3d3c684 #12167

Cherry-picked from #12105
Closes #12210

2 years agocmake: speed up threads setup for Windows
Viktor Szakats [Thu, 26 Oct 2023 08:28:20 +0000 (08:28 +0000)] 
cmake: speed up threads setup for Windows

Win32 threads are always available. We enabled them unconditionally
(with `ENABLE_THREADED_RESOLVER`). CMake built-in thread detection
logic has this condition hard-coded for Windows as well (since at least
2007).

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

This saves 1-3 slow CMake configuration steps.

Reviewed-by: Daniel Stenberg
Closes #12202

2 years agocmake: speed up zstd detection
Viktor Szakats [Wed, 25 Oct 2023 23:37:48 +0000 (23:37 +0000)] 
cmake: speed up zstd detection

Before this patch we detected the presence of a specific zstd API to
see if we can use the library. zstd published that API in its first
stable release: v1.0.0 (2016-08-31).

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

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

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

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

Reviewed-by: Daniel Stenberg
Closes #12200

2 years agoopenssl: fix infof() to avoid compiler warning for %s with null
Daniel Stenberg [Wed, 25 Oct 2023 07:26:23 +0000 (09:26 +0200)] 
openssl: fix infof() to avoid compiler warning for %s with null

vtls/openssl.c: In function ‘ossl_connect_step2’:
../lib/curl_trc.h:120:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  120 |          Curl_infof(data, __VA_ARGS__); } while(0)
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/openssl.c:4008:5: note: in expansion of macro ‘infof’
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |     ^~~~~
vtls/openssl.c:4008:49: note: format string is defined here
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |                                                 ^~

Follow-up to b6e6d4ff8f253c8b8055bab
Closes #12196

2 years 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

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

2 years 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