]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
20 months agomime: add client reader
Stefan Eissing [Thu, 29 Feb 2024 09:12:39 +0000 (10:12 +0100)] 
mime: add client reader

Add `mime` client reader. Encapsulates reading from mime parts, getting
their length, rewinding and unpausing.

- remove special mime handling from sendf.c and easy.c
- add general "unpause" method to client readers
- use new reader in http/imap/smtp
- make some mime functions static that are now only used internally

In addition:
- remove flag 'forbidchunk' as no longer needed

Closes #13039

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Tue, 5 Mar 2024 16:15:27 +0000 (17:15 +0100)] 
RELEASE-NOTES: synced

20 months agoTODO: remove "build HTTP/3 with OpenSSL and nghttp3 using cmake"
Daniel Stenberg [Tue, 5 Mar 2024 16:09:46 +0000 (17:09 +0100)] 
TODO: remove "build HTTP/3 with OpenSSL and nghttp3 using cmake"

Follow-up to 8e741644a229c37

20 months agocmake: add USE_OPENSSL_QUIC support
Tal Regev [Sun, 3 Mar 2024 19:57:03 +0000 (21:57 +0200)] 
cmake: add USE_OPENSSL_QUIC support

Closes #13034

20 months agoTIMER_STARTTRANSFER: set the same for everyone
Stefan Eissing [Tue, 5 Mar 2024 10:48:16 +0000 (11:48 +0100)] 
TIMER_STARTTRANSFER: set the same for everyone

- set TIMER_STARTTRANSFER on seeing the first response bytes
  in the download client writer, not coming from a CONNECT
- initialized the timer the same way for all protocols
- remove explicit setting of TIMER_STARTTRANSFER in file.c
  and c-hyper.c

Closes #13052

20 months agohttp: better error message for HTTP/1.x response without status line
Michael Kaufmann [Mon, 4 Mar 2024 17:15:08 +0000 (18:15 +0100)] 
http: better error message for HTTP/1.x response without status line

If a response without a status line is received, and the connection is
known to use HTTP/1.x (not HTTP/0.9), report the error "Invalid status
line" instead of "Received HTTP/0.9 when not allowed".

Closes #13045

20 months agoKNOWN_BUGS: fix typo
Viktor Szakats [Tue, 5 Mar 2024 10:52:04 +0000 (10:52 +0000)] 
KNOWN_BUGS: fix typo

Reviewed-by: Daniel Stenberg
Closes #13051

20 months agosmpt: fix starttls
Sebastian Neubauer [Tue, 5 Mar 2024 01:11:46 +0000 (02:11 +0100)] 
smpt: fix starttls

In cases where the connection was fast, curl sometimes failed to open a
connection. This fixes a regression of c2d973627bab12abc5486a3f3.

The regression triggered in these steps:

1. Create an smtp connection
2. Use STARTTLS
3. Receive the response
4. We are inside the loop in `smtp_statemachine`, calling
   `smtp_state_starttls_resp`
5. In the good flow, we exit the loop, re-enter `smtp_statemachine` and
   run `smtp_perform_upgrade_tls` at the start of the function.

   In the bad flow, we stay in the while loop, calling
   `Curl_pp_readresp`, which reads part of the TLS handshake and things
   go wrong.

The reason is that `Curl_pp_moredata` changed behavior and always
returns `true`, so we stay in the loop in `smtp_statemachine`. With a
slow connection `Curl_pp_readresp` cannot read new data and returns
`CURL_AGAIN`, so we leave the loop and re-enter `smtp_statemachine`.

With a fast connection, `Curl_pp_readresp` reads new data from the tcp
connection, which is part of the TLS handshake.

The fix is in `Curl_pp_moredata`, which needs to take the final line
into account and return `false` if only the final line is stored.

Closes #13048

20 months agolib: enhance client reader resume + rewind
Stefan Eissing [Thu, 29 Feb 2024 09:12:39 +0000 (10:12 +0100)] 
lib: enhance client reader resume + rewind

- update client reader documentation
- client reader, add rewind capabilities
    - tell creader to rewind on next start
    - Curl_client_reset() will keep reader for future rewind if requested
    - add Curl_client_cleanup() for freeing all resources independent of
      rewinds
    - add Curl_client_start() to trigger rewinds
    - move rewind code from multi.c to sendf.c and make part of
      "cr-in"'s implementation
- http, move the "resume_from" handling into the client readers
    - the setup of a HTTP request is reshuffled to follow:
      * determine method, target, auth negotiation
      * install the client reader(s) for the request, including crlf
        conversions and "chunked" encoding
      * apply ranges to client reader
      * concat request headers, upgrades, cookies, etc.
      * complete request by determining Content-Length of installed
        readers in combination with method
      * send
    - add methods for client readers to
      * return the overall length they will generate (or -1 when unknown)
      * return the amount of data on the CLIENT level, so that
        expect-100 can decide if it want to apply itself
      * set a "resume_from" offset or fail if unsupported
    - struct HTTP has become largely empty now
- rename `Client_reader_*` to `Curl_creader_*`

Closes #13026

20 months agoopenssl-quic: fix BIO leak and Windows warning
Viktor Szakats [Mon, 4 Mar 2024 17:07:40 +0000 (17:07 +0000)] 
openssl-quic: fix BIO leak and Windows warning

Caused by an accidentally duplicated line in
d6825df334def106f735ce7e0c1a2ea87bddffb0.

```
.../lib/vquic/curl_osslq.c:1095:30: warning: implicit conversion loses integer precision: 'curl_socket_t' (aka 'unsigned long long') to 'int' [-Wshorten-64-to-32]
 1095 |   bio = BIO_new_dgram(ctx->q.sockfd, BIO_NOCLOSE);
      |         ~~~~~~~~~~~~~ ~~~~~~~^~~~~~
1 warning and 2 errors generated.
```

Reviewed-by: Stefan Eissing
Closes #13043

20 months agoopenssl-quic: fix unity build, casing, indentation
Viktor Szakats [Mon, 4 Mar 2024 17:12:42 +0000 (17:12 +0000)] 
openssl-quic: fix unity build, casing, indentation

- rename static functions to avoid duplicate symbols in unity mode.
- windows -> Windows/window in error message and comment.
- fix indentation.

Reviewed-by: Stefan Eissing
Closes #13044

20 months agogen.pl: make the "manpageification" faster
Daniel Stenberg [Mon, 4 Mar 2024 14:16:11 +0000 (15:16 +0100)] 
gen.pl: make the "manpageification" faster

The function that replaces occurances of "--longoption" with "-Z,
--longoption" etc with the proper highlight applied, no longer loops
over the options.

Closes #13041

20 months agoCONTRIBUTE: update the section on documentation format
Daniel Stenberg [Mon, 4 Mar 2024 22:04:05 +0000 (23:04 +0100)] 
CONTRIBUTE: update the section on documentation format

... since most of it is markdown now.

Closes #13046

20 months agosmtp: free a temp resource
Daniel Stenberg [Mon, 4 Mar 2024 09:07:07 +0000 (10:07 +0100)] 
smtp: free a temp resource

The returned address needs to be freed.

Follow-up to e3905de8196d67b89df1602feb84c1f993211b20
Spotted by Coverity

Closes #13038

20 months ago_VARIABLES.md: improve the description
Daniel Stenberg [Mon, 4 Mar 2024 13:26:14 +0000 (14:26 +0100)] 
_VARIABLES.md: improve the description

Closes #13040

20 months agobuild(deps): bump fsfe/reuse-action from 2 to 3
dependabot[bot] [Mon, 4 Mar 2024 14:31:36 +0000 (14:31 +0000)] 
build(deps): bump fsfe/reuse-action from 2 to 3

Bumps [fsfe/reuse-action](https://github.com/fsfe/reuse-action) from 2 to 3.
- [Release notes](https://github.com/fsfe/reuse-action/releases)
- [Commits](https://github.com/fsfe/reuse-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: fsfe/reuse-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
20 months agopytest: adapt to API change
Stefan Eissing [Mon, 4 Mar 2024 09:05:52 +0000 (10:05 +0100)] 
pytest: adapt to API change

- pytest has changed the signature of the hook pytest_report_header()
  for some obscure reason and that change landed in our CI now

- remove the changed param that we never used anyway

Closes #13037

20 months agocookie: if psl fails, reject the cookie
Daniel Stenberg [Sun, 3 Mar 2024 17:41:52 +0000 (18:41 +0100)] 
cookie: if psl fails, reject the cookie

A libpsl install without data and no built-in database is now considered
bad enough to reject all cookies since they cannot be checked. It is
somewhat of a user error, but still.

Reported-by: Dan Fandrich
Closes #13033

20 months agolib: further send/upload handling polish
Stefan Eissing [Wed, 28 Feb 2024 13:51:53 +0000 (14:51 +0100)] 
lib: further send/upload handling polish

- Move all the "upload_done" handling to request.c

  - add possibility to abort sending of a request
  - add `Curl_req_done_sending()` for checks
  - transfer.c: readwrite_upload() now clean

- removing data->state.ulbuf and data->req.upload_fromhere

  - as well as data->req.upload_present
  - set data->req.upload_done on having read all from
    the client and completely flushed the send buffer

- tftp, remove setting of data->req.upload_fromhere

  - serves no purpose as `upload_present` is not set
    and the data itself is directly `sendto()` anyway

- smtp, make upload EOB conversion a client reader
- xfer_ulbuf addition

  - add xfer_ulbuf for borrowing, similar to xfer_buf
  - use in file upload
  - use in c-hyper body sending

- h1-proxy, remove init of data->state.uilbuf that is never used
- smb, add own send_buf instead of using data->state.ulbuf

Closes #13010

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 4 Mar 2024 07:19:12 +0000 (08:19 +0100)] 
RELEASE-NOTES: synced

20 months agorustls: fix two warnings related to number types
kpcyrd [Thu, 29 Feb 2024 15:01:03 +0000 (16:01 +0100)] 
rustls: fix two warnings related to number types

Reported-by: Gisle Vanem
Follow-up to #12989
Closes #13017

20 months agobufq: writing into a softlimit queue cannot be partial
Stefan Eissing [Fri, 1 Mar 2024 08:12:50 +0000 (09:12 +0100)] 
bufq: writing into a softlimit queue cannot be partial

- when unable to obtain a new chunk on a softlimit bufq,
  this is an allocation error and needs to be reported as
  such.
- writes into a soflimit bufq never must be partial success

Reported-by: Dan Fandrich
Fixes #13020
Closes #13023

20 months agoconfigure: Don't build shell completions when disabled
Dan Fandrich [Sat, 2 Mar 2024 02:27:35 +0000 (18:27 -0800)] 
configure: Don't build shell completions when disabled

With the recent changes to completion file building, the files were
built always and only installation was selectively disabled.  Now, when
they are disabled they aren't even built, avoiding a build-time error in
environments where it's not possible to run the curl binary that was
just created (e.g. if library paths were not set up correctly).

Follow-up to 0f7aba83c

Reported-by: av223119 on github
Fixes #13027
Closes #13030

20 months agocmdline-opts/_EXITCODES: sync with libcurl-errors
Jay Satiro [Thu, 29 Feb 2024 06:36:31 +0000 (01:36 -0500)] 
cmdline-opts/_EXITCODES: sync with libcurl-errors

- Add error code 100 (CURLE_TOO_LARGE) to the list of error codes that
  can be returned by the curl tool.

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

20 months agohyper: disable test1598 due to lack of trailer support
Stefan Eissing [Thu, 29 Feb 2024 10:31:55 +0000 (11:31 +0100)] 
hyper: disable test1598 due to lack of trailer support

Follow-up to 50838095

Closes #13016

20 months agoftp: Mark a const buffer as const
Dan Fandrich [Fri, 1 Mar 2024 09:07:02 +0000 (01:07 -0800)] 
ftp: Mark a const buffer as const

20 months agoappveyor: Properly skip if only CircleCI is changed
Dan Fandrich [Fri, 1 Mar 2024 09:06:28 +0000 (01:06 -0800)] 
appveyor: Properly skip if only CircleCI is changed

20 months agodocs: Update minimal binary size in INSTALL.md
Dan Fandrich [Fri, 10 Nov 2023 09:41:13 +0000 (01:41 -0800)] 
docs: Update minimal binary size in INSTALL.md

Include more options to reduce binary size.

20 months agoconfigure: Don't make shell completions without perl
Dan Fandrich [Fri, 1 Mar 2024 07:38:22 +0000 (23:38 -0800)] 
configure: Don't make shell completions without perl

The code that attempted to skip building the shell completions didn't
work properly and tried to build them even if perl wasn't available.
This step, as well as the install step, is now properly skipped without
perl.

Follow-up to 89733e2dd

Closes #13022

20 months agomisc: Fix typos in docs and lib
RainRat [Thu, 29 Feb 2024 19:55:28 +0000 (11:55 -0800)] 
misc: Fix typos in docs and lib

This fixes miscellaneous typos and duplicated words in the docs, lib
and test comments and a few user facing errorstrings.

Author: RainRat on Github
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Dan Fandrich <dan@coneharvesters.com>
Closes: #13019
20 months agoconfigure: build & install shell completions when enabled
Dan Fandrich [Thu, 8 Feb 2024 19:34:34 +0000 (11:34 -0800)] 
configure: build & install shell completions when enabled

The --with-fish-functions-dir and --with-zsh-functions-dir options
currently have no effect on a normal build because the scripts/ directory
where they're used is not built. Add scripts/ to a normal build and
change the completion options to default to off to preserve the existing
behaviour.

Closes: #12906
20 months agogithub/labeler: improve the match patterns
Dan Fandrich [Thu, 29 Feb 2024 21:04:23 +0000 (13:04 -0800)] 
github/labeler: improve the match patterns

20 months agotests: add test1598 for POST with trailers
Stefan Eissing [Wed, 28 Feb 2024 12:20:59 +0000 (13:20 +0100)] 
tests: add test1598 for POST with trailers

- test POST fields with trailers and chunked encoding

Ref: #12938
Closes #13009

20 months agocmdline-opts/_VERSION: provide %VERSION correctly
Daniel Stenberg [Wed, 28 Feb 2024 10:40:04 +0000 (11:40 +0100)] 
cmdline-opts/_VERSION: provide %VERSION correctly

... so that it does not get included verbatim in the output. Fixes a
regression shipped in 8.6.0.

Also fix a format mistake in form.md

Closes #13008

20 months agolib: Curl_read/Curl_write clarifications
Stefan Eissing [Thu, 15 Feb 2024 15:22:53 +0000 (16:22 +0100)] 
lib: Curl_read/Curl_write clarifications

- replace `Curl_read()`, `Curl_write()` and `Curl_nwrite()` to
  clarify when and at what level they operate
- send/recv of transfer related data is now done via
  `Curl_xfer_send()/Curl_xfer_recv()` which no longer has
  socket/socketindex as parameter. It decides on the transfer
  setup of `conn->sockfd` and `conn->writesockfd` on which
  connection filter chain to operate.
- send/recv on a specific connection filter chain is done via
  `Curl_conn_send()/Curl_conn_recv()` which get the socket index
  as parameter.
- rename `Curl_setup_transfer()` to `Curl_xfer_setup()` for
  naming consistency
- clarify that the special CURLE_AGAIN hangling to return
  `CURLE_OK` with length 0 only applies to `Curl_xfer_send()`
  and CURLE_AGAIN is returned by all other send() variants.
- fix a bug in websocket `curl_ws_recv()` that mixed up data
  when it arrived in more than a single chunk (to be made
  into a sperate PR, also)

Added as documented [in
CLIENT-READER.md](https://github.com/curl/curl/blob/5b1f31dfbab8aef467c419c68aa06dc738cb75d4/docs/CLIENT-READERS.md).

- old `Curl_buffer_send()` completely replaced by new `Curl_req_send()`
- old `Curl_fillreadbuffer()` replaced with `Curl_client_read()`
- HTTP chunked uploads are now formatted in a client reader added when
  needed.
- FTP line-end conversions are done in a client reader added when
  needed.
- when sending requests headers, remaining buffer space is filled with
  body data for sending in "one go". This is independent of the request
  body size. Resolves #12938 as now small and large requests have the
  same code path.

Changes done to test cases:

- test513: now fails before sending request headers as this initial
  "client read" triggers the setup fault. Behaves now the same as in
  hyper build
- test547, test555, test1620: fix the length check in the lib code to
  only fail for reads *smaller* than expected. This was a bug in the
  test code that never triggered in the old implementation.

Closes #12969

20 months agocurldown: Fix email address in Copyright
Daniel Gustafsson [Wed, 28 Feb 2024 10:28:10 +0000 (11:28 +0100)] 
curldown: Fix email address in Copyright

The curldown conversion accidentally replaced daniel@haxx.se with
just daniel.se.  This reverts back to the proper email address in
the curldown docs as well as in a few other stray places where it
was incorrect (while unrelated to curldown).

Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Closes: #12997
20 months agogetparam: make --ftp-ssl work again
Daniel Stenberg [Wed, 28 Feb 2024 07:02:49 +0000 (08:02 +0100)] 
getparam: make --ftp-ssl work again

Follow-up to 9e4e527 which accidentally broke it

Reported-by: Jordan Brown
Fixes #13006
Closes #13007

20 months agoKNOWN_BUGS: IMAPS connection fails with rustls error 13005/head
Daniel Stenberg [Tue, 27 Feb 2024 16:50:25 +0000 (17:50 +0100)] 
KNOWN_BUGS: IMAPS connection fails with rustls error

Closes #10457

20 months agoKNOWN_BUGS: FTPS upload, FileZilla, GnuTLS and close_notify
Daniel Stenberg [Tue, 27 Feb 2024 16:48:18 +0000 (17:48 +0100)] 
KNOWN_BUGS: FTPS upload, FileZilla, GnuTLS and close_notify

Closes #11383

20 months agoKNOWN_BUGS: Implicit FTPS upload timeout
Daniel Stenberg [Tue, 27 Feb 2024 16:46:19 +0000 (17:46 +0100)] 
KNOWN_BUGS: Implicit FTPS upload timeout

Closes #11720

20 months agoKNOWN_BUGS: HTTP/2 prior knowledge over proxy
Daniel Stenberg [Tue, 27 Feb 2024 16:44:55 +0000 (17:44 +0100)] 
KNOWN_BUGS: HTTP/2 prior knowledge over proxy

Closes #12641

20 months agoTODO: build HTTP/3 with OpenSSL and nghttp3 using cmake
Daniel Stenberg [Tue, 27 Feb 2024 16:43:22 +0000 (17:43 +0100)] 
TODO: build HTTP/3 with OpenSSL and nghttp3 using cmake

Closes #12988

20 months agoTODO: Select signature algorithms
Daniel Stenberg [Tue, 27 Feb 2024 16:41:40 +0000 (17:41 +0100)] 
TODO: Select signature algorithms

Closes #12982

20 months agoexamples: use present tense in comments
Daniel Stenberg [Tue, 27 Feb 2024 11:29:27 +0000 (12:29 +0100)] 
examples: use present tense in comments

remove "will" and some other word fixes

Closes #13003

20 months agodocs: more language cleanups
Daniel Stenberg [Tue, 27 Feb 2024 09:35:28 +0000 (10:35 +0100)] 
docs: more language cleanups

- present tense
- avoid bad words

Closes #13003

20 months agosetopt: Fix disabling all protocols
Daniel Gustafsson [Tue, 27 Feb 2024 14:43:56 +0000 (15:43 +0100)] 
setopt: Fix disabling all protocols

When disabling all protocols without enabling any, the resulting
set of allowed protocols remained the default set.  Clearing the
allowed set before inspecting the passed value from --proto make
the set empty even in the errorpath of no protocols enabled.

Co-authored-by: Dan Fandrich <dan@telarity.com>
Reported-by: Dan Fandrich <dan@telarity.com>
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Closes: #13004
20 months agofopen: fix narrowing conversion warning on 32-bit Android
Andreas Kiefer [Mon, 26 Feb 2024 20:08:10 +0000 (21:08 +0100)] 
fopen: fix narrowing conversion warning on 32-bit Android

This was fixed in commit 06dc599405f, but came back in commit
03cb1ff4d62.

When building for 32-bit ARM or x86 Android, `st_mode` is defined as
`unsigned int` instead of `mode_t`, resulting in a
`-Wimplicit-int-conversion` clang warning because `mode_t` is
`unsigned short`. Add a cast to silence the warning, but only for
32-bit Android builds, because other architectures and platforms are
not affected.

Ref: https://android.googlesource.com/platform/bionic/+/refs/tags/ndk-r25c/libc/include/sys/stat.h#86
Closes https://github.com/curl/curl/pull/12998

20 months agolib: Curl_read/Curl_write clarifications
Stefan Eissing [Thu, 15 Feb 2024 15:22:53 +0000 (16:22 +0100)] 
lib: Curl_read/Curl_write clarifications

- replace `Curl_read()`, `Curl_write()` and `Curl_nwrite()` to
  clarify when and at what level they operate
- send/recv of transfer related data is now done via
  `Curl_xfer_send()/Curl_xfer_recv()` which no longer has
  socket/socketindex as parameter. It decides on the transfer
  setup of `conn->sockfd` and `conn->writesockfd` on which
  connection filter chain to operate.
- send/recv on a specific connection filter chain is done via
  `Curl_conn_send()/Curl_conn_recv()` which get the socket index
  as parameter.
- rename `Curl_setup_transfer()` to `Curl_xfer_setup()` for
  naming consistency
- clarify that the special CURLE_AGAIN hangling to return
  `CURLE_OK` with length 0 only applies to `Curl_xfer_send()`
  and CURLE_AGAIN is returned by all other send() variants.
- fix a bug in websocket `curl_ws_recv()` that mixed up data
  when it arrived in more than a single chunk

The method for sending not just raw bytes, but bytes that are either
"headers" or "body". The send abstraction stack, to to bottom, now is:

* `Curl_req_send()`: has parameter to indicate amount of header bytes,
  buffers all data.
* `Curl_xfer_send()`: knows on which socket index to send, returns
  amount of bytes sent.
* `Curl_conn_send()`: called with socket index, returns amount of bytes
  sent.

In addition there is `Curl_req_flush()` for writing out all buffered
bytes.

`Curl_req_send()` is active for requests without body,
`Curl_buffer_send()` still being used for others. This is because the
special quirks need to be addressed in future parts:

* `expect-100` handling
* `Curl_fillreadbuffer()` needs to add directly to the new
  `data->req.sendbuf`
* special body handlings, like `chunked` encodings and line end
  conversions will be moved into something like a Client Reader.

In functions of the pattern `CURLcode xxx_send(..., ssize_t *written)`,
replace the `ssize_t` with a `size_t`. It makes no sense to allow for negative
values as the returned `CURLcode` already specifies error conditions. This
allows easier handling of lengths without casting.

Closes #12964

20 months agomulti: make add_handle free any multi_easy
Daniel Stenberg [Mon, 26 Feb 2024 08:50:49 +0000 (09:50 +0100)] 
multi: make add_handle free any multi_easy

If the easy handle that is being added to a multi handle has previously
been used for curl_easy_perform(), there is a private multi handle here
that we can kill off. While it flushes some caches etc for the easy
handle would it be used for an easy interface transfer again after being
used in the multi stack, this cleanup simplifies behavior and uses less
memory.

Closes #12992

20 months agodocs: use present tense
Daniel Stenberg [Tue, 27 Feb 2024 06:48:10 +0000 (07:48 +0100)] 
docs: use present tense

avoid "will", detect "will" as a bad word in the CI

Also line wrapped a bunch of paragraphs

Closes #13001

20 months agoCURLOPT_SSL_CTX_FUNCTION.md: no promises of lifetime after return
Daniel Stenberg [Mon, 26 Feb 2024 21:27:07 +0000 (22:27 +0100)] 
CURLOPT_SSL_CTX_FUNCTION.md: no promises of lifetime after return

... and cleanup other language.

Closes #12999

20 months agolib: send rework
Stefan Eissing [Wed, 14 Feb 2024 11:09:32 +0000 (12:09 +0100)] 
lib: send rework

Curl_read/Curl_write clarifications

- replace `Curl_read()`, `Curl_write()` and `Curl_nwrite()` to 1clarify
  when and at what level they operate

- send/recv of transfer related data is now done via
  `Curl_xfer_send()/Curl_xfer_recv()` which no longer has
  socket/socketindex as parameter. It decides on the transfer setup of
  `conn->sockfd` and `conn->writesockfd` on which connection filter
  chain to operate.

- send/recv on a specific connection filter chain is done via
  `Curl_conn_send()/Curl_conn_recv()` which get the socket index as
  parameter.

- rename `Curl_setup_transfer()` to `Curl_xfer_setup()` for naming
  consistency

- clarify that the special CURLE_AGAIN handling to return `CURLE_OK`
  with length 0 only applies to `Curl_xfer_send()` and CURLE_AGAIN is
  returned by all other send() variants.

SingleRequest reshuffling

- move functions into request.[ch]
- differentiate between reset and free
- add Curl_req_done() to perform last actions
- add a send `bufq` to SingleRequest for future use in keeping upload data

Closes #12963

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 26 Feb 2024 22:05:51 +0000 (23:05 +0100)] 
RELEASE-NOTES: synced

20 months agohttp_chunks: remove unused 'endptr' variable
Daniel Stenberg [Mon, 26 Feb 2024 11:27:07 +0000 (12:27 +0100)] 
http_chunks: remove unused 'endptr' variable

Closes #12996

20 months agolib: initialize output pointers to NULL before calling strto[ff,l,ul]
Louis Solofrizzo [Mon, 26 Feb 2024 11:07:22 +0000 (12:07 +0100)] 
lib: initialize output pointers to NULL before calling strto[ff,l,ul]

In order to make MSAN happy:

    ==2200945==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x596f3b3ed246 in curlx_strtoofft [...]/libcurl/src/lib/strtoofft.c:239:11
    #1 0x596f3b402156 in Curl_httpchunk_read [...]/libcurl/src/lib/http_chunks.c:149:12
    #2 0x596f3b348550 in readwrite_data [...]/libcurl/src/lib/transfer.c:607:11
    [...]

    ==2202041==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x5a3fab66a72a in Curl_parse_port [...]/libcurl/src/lib/urlapi.c:547:8
    #1 0x5a3fab650645 in parse_authority [...]/libcurl/src/lib/urlapi.c:796:12
    #2 0x5a3fab6740f6 in parseurl [...]/libcurl/src/lib/urlapi.c:1176:16
    #3 0x5a3fab664fc5 in parseurl_and_replace [...]/libcurl/src/lib/urlapi.c:1342:12
    [...]

    ==2202320==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x569076a0d6b0 in ipv4_normalize [...]/libcurl/src/lib/urlapi.c:683:12
    #1 0x5690769f2820 in parse_authority [...]/libcurl/src/lib/urlapi.c:803:10
    #2 0x569076a160f6 in parseurl [...]/libcurl/src/lib/urlapi.c:1176:16
    #3 0x569076a06fc5 in parseurl_and_replace [...]/libcurl/src/lib/urlapi.c:1342:12
    [...]

Signed-off-by: Louis Solofrizzo <lsolofrizzo@scaleway.com>
Closes #12995

20 months agolib: move client writer into own source
Stefan Eissing [Wed, 7 Feb 2024 11:05:05 +0000 (12:05 +0100)] 
lib: move client writer into own source

Refactoring of the client writer that passes the data to the
client/application's callback functions.

- split out into own source cw-out.[ch] from sendf.c

- move tempwrite and tempcount from data->state into the context of the
  client writer

- redesign the 3 tempwrite dynbufs as a linked list of dynbufs. On
  paused transfers, this allows to "record" interleaved HEADER/BODY
  chunks to be "played back" in the same order on unpausing.

- keep the overall size limit of all buffered data to DYN_PAUSE_BUFFER.
  On exceeding that, return CURLE_TOO_LARGE instead of
  CURLE_OUT_OF_MEMORY as before.

- add method to be called when a transfer is DONE to allow writing of
  any data still buffered

- when paused, record HEADER writes exactly as they come for later
  playback. HEADERs are documented to be written one-by-one.

Closes #12898

20 months agourldata: move authneg bit from conn to Curl_easy
Stefan Eissing [Fri, 16 Feb 2024 11:15:10 +0000 (12:15 +0100)] 
urldata: move authneg bit from conn to Curl_easy

- from `conn->bits.authneg` to `data->req.authneg`
- this is a property of the request about to be made
  and not a property of the connection
- in multiuse connections, transfer could step on each others
  toes here potentially.

Closes #12949

20 months agoc-hyper: add header collection writer in hyper builds
Stefan Eissing [Tue, 6 Feb 2024 13:56:05 +0000 (14:56 +0100)] 
c-hyper: add header collection writer in hyper builds

Closes #12880

20 months agohttp: move headers collecting to writer
Stefan Eissing [Tue, 6 Feb 2024 12:55:07 +0000 (13:55 +0100)] 
http: move headers collecting to writer

- add a client writer that does "push" response
  headers written to the client if the headers api
  is enabled
- remove special handling in sendf.c
- needs to be installed very early on connection
  setup to catch CONNECT response headers

Closes #12880

20 months agosendf: Curl_client_write(), make passed in buf const
Stefan Eissing [Tue, 6 Feb 2024 11:10:19 +0000 (12:10 +0100)] 
sendf: Curl_client_write(), make passed in buf const

20 months agolib: remove curl_mimepart object when CURL_DISABLE_MIME
MAntoniak [Fri, 9 Feb 2024 17:20:47 +0000 (18:20 +0100)] 
lib: remove curl_mimepart object when CURL_DISABLE_MIME

Remove curl_mimepart object from UserDefined structure when
CURL_DISABLE_MIME flag is active. Reduce size of UserDefined structure.

Also remove unreachable code: when CURL_DISABLE_MIME is set, httpreq can
never have HTTPREQ_POST_MIME value and the same goes for the
CURL_DISABLE_FORM_API flag and the HTTPREQ_POST_FORM value

Closes #12948

20 months agorustls: make curl compile with 0.12.0
kpcyrd [Sun, 25 Feb 2024 20:50:18 +0000 (21:50 +0100)] 
rustls: make curl compile with 0.12.0

Closes #12989

20 months agostrtoofft: fix the overflow check
Daniel Stenberg [Sun, 25 Feb 2024 21:52:40 +0000 (22:52 +0100)] 
strtoofft: fix the overflow check

... to not rely on wrapping, since it is an undefined behavior that is
not what always might happen. This is in our private strtoff() parser
function, used only on platforms without a native version.

Reported-by: vulnerabilityspotter on hackerone
Closes #12990

20 months agolibssh/libssh2: return error on too big range
Daniel Stenberg [Sat, 24 Feb 2024 21:38:22 +0000 (22:38 +0100)] 
libssh/libssh2: return error on too big range

If trying to get the range 0 - 2^63 and the remote file is 2^63 bytes or
larger.

Fixes #12983
Closes #12984

20 months agosetopt: fix check for CURLOPT_PROXY_TLSAUTH_TYPE value
Scott Talbert [Sat, 24 Feb 2024 03:02:09 +0000 (22:02 -0500)] 
setopt: fix check for CURLOPT_PROXY_TLSAUTH_TYPE value

Prior to this change CURLOPT_PROXY_TLSAUTH_TYPE would return
CURLE_BAD_FUNCTION_ARGUMENT on any type other than NULL. Since there is
only one type of TLS auth and it is also the default (SRP) the TLS auth
would work anyway.

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

20 months agomprintf: fix format prefix I32/I64 for windows compilers
Jay Satiro [Fri, 16 Feb 2024 21:02:19 +0000 (16:02 -0500)] 
mprintf: fix format prefix I32/I64 for windows compilers

- Support I32 & I64 (eg: %I64d) for all Win32 builds.

Prior to this change mprintf support for the I format prefix, which is a
Microsoft extension, was dependent on the compiler used.

When Borland compiler support was removed in fd7ef00f the prefix was
then no longer supported for that compiler; however since it's still
possible to build with Borland I'm restoring support for the prefix in
this way.

Reported-by: Paweł Witas
Fixes https://github.com/curl/curl/issues/12944
Closes https://github.com/curl/curl/pull/12950

20 months agocd2nroff: gen: make `\>` in input to render as plain '>' in output
Daniel Stenberg [Fri, 23 Feb 2024 11:52:59 +0000 (12:52 +0100)] 
cd2nroff: gen: make `\>` in input to render as plain '>' in output

The same (copy and pasted) fix/mistake as in gen.pl

20 months agogen: make `\>` in input to render as plain '>' in output
Daniel Stenberg [Fri, 23 Feb 2024 11:52:09 +0000 (12:52 +0100)] 
gen: make `\>` in input to render as plain '>' in output

Reported-by: Gisle Vanem
Fixes #12977
Closes #12978

20 months agoconfigure.ac: find libpsl with pkg-config
Fabrice Fontaine [Thu, 15 Feb 2024 19:59:25 +0000 (20:59 +0100)] 
configure.ac: find libpsl with pkg-config

Find libpsl with pkg-config to avoid static build failures.

Ref: http://autobuild.buildroot.org/results/1fb15e1a99472c403d0d3b1a688902f32e78d002

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Closes #12947

20 months agoBUG-BOUNTY.md: clarify that the curl security team decides
Daniel Stenberg [Thu, 22 Feb 2024 15:34:35 +0000 (16:34 +0100)] 
BUG-BOUNTY.md: clarify that the curl security team decides

Closes #12975

20 months agoTHANKS: add bug reporter from #740
Daniel Stenberg [Fri, 23 Feb 2024 09:11:11 +0000 (10:11 +0100)] 
THANKS: add bug reporter from #740

Ref: https://github.com/curl/curl/issues/740

20 months agomulti: fix multi_sock handling of select_bits 12976/head
Stefan Eissing [Thu, 22 Feb 2024 08:01:06 +0000 (09:01 +0100)] 
multi: fix multi_sock handling of select_bits

- OR the event bitmask to data->state.select_bits instead of overwriting
  them. They are cleared again on use.

Reported-by: 5533asdg on github
Fixes #12971
Closes #12972

20 months agocurlver: bump to 8.7.0 for next release
Daniel Stenberg [Thu, 22 Feb 2024 08:34:41 +0000 (09:34 +0100)] 
curlver: bump to 8.7.0 for next release

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Thu, 22 Feb 2024 07:46:04 +0000 (08:46 +0100)] 
RELEASE-NOTES: synced

20 months agowrite-out: add '%{proxy_used}'
Daniel Stenberg [Thu, 22 Feb 2024 07:38:53 +0000 (08:38 +0100)] 
write-out: add '%{proxy_used}'

Returns 1 if the previous transfer used a proxy, otherwise 0. Useful to
for example determine if a `NOPROXY` pattern matched the hostname or
not.

Extended test 970 and 972

20 months agoCURLINFO_USED_PROXY: return bool whether the proxy was used
Daniel Stenberg [Thu, 22 Feb 2024 07:38:53 +0000 (08:38 +0100)] 
CURLINFO_USED_PROXY: return bool whether the proxy was used

Adds test536 to verify

Closes #12719

20 months agosha512_256: remove the cast macro, minor language/format edits
Daniel Stenberg [Tue, 20 Feb 2024 10:48:27 +0000 (11:48 +0100)] 
sha512_256: remove the cast macro, minor language/format edits

Follow-up to cbe41d151d6a100c

Closes #12966

20 months agoDoH: add trace configuration
Stefan Eissing [Mon, 27 Nov 2023 10:30:25 +0000 (11:30 +0100)] 
DoH: add trace configuration

- refs #12397 where it is dicussed how to en-/disable verbose output
  of DoH operations
- introducing `struct curl_trc_feat` to track a curl feature for
  tracing
- adding `data->state.feat` optionally pointing to the feature a
  transfer belongs to
- adding trace functions and verbosity checks on features
- using trace feature in DoH code
- documenting `doh` as feature for `--trace-config`

Closes #12411

20 months agowebsocket: fix curl_ws_recv()
Stefan Eissing [Thu, 15 Feb 2024 15:39:40 +0000 (16:39 +0100)] 
websocket: fix curl_ws_recv()

- when data arrived in several chunks, the collection into
  the passed buffer always started at offset 0, overwriting
  the data already there.

adding test_20_07 to verify fix

- debug environment var CURL_WS_CHUNK_SIZE can be used to
  influence the buffer chunk size used for en-/decoding.

Closes #12945

20 months agodigest: support SHA-512/256
Evgeny Grin [Thu, 8 Feb 2024 09:31:12 +0000 (10:31 +0100)] 
digest: support SHA-512/256

Also fix the tests. New implementation tested with GNU libmicrohttpd.
The new numbers in tests are real SHA-512/256 numbers (not just some
random ;) numbers ).

20 months agotests: add SHA-512/256 unit test
Evgeny Grin [Wed, 7 Feb 2024 22:07:07 +0000 (23:07 +0100)] 
tests: add SHA-512/256 unit test

20 months agoSHA-512/256: implement hash algorithm
Evgeny Grin [Wed, 7 Feb 2024 22:06:28 +0000 (23:06 +0100)] 
SHA-512/256: implement hash algorithm

Closes #12897

20 months agocurl_setup.h: add curl_uint64_t internal type
Evgeny Grin [Sat, 10 Feb 2024 18:28:27 +0000 (19:28 +0100)] 
curl_setup.h: add curl_uint64_t internal type

The unsigned version of curl_off_t basically

20 months agodocs: dist curl*.1 and install without perl
Daniel Stenberg [Mon, 19 Feb 2024 08:32:07 +0000 (09:32 +0100)] 
docs: dist curl*.1 and install without perl

Drop docs/mk-ca-bundle.1 from the tarball. It can be generated at will.

Closes #12959
Fixes #12921
Reported-by: Michael Forney
20 months agoOpenSSL QUIC: adapt to v3.3.x
Stefan Eissing [Tue, 13 Feb 2024 12:59:03 +0000 (13:59 +0100)] 
OpenSSL QUIC: adapt to v3.3.x

- set our idle timeout as transport parameter
- query negotiated idle timeout for connection alive checks
- query number of available bidi streams on a connection
- use write_ex2 with SSL_WRITE_FLAG_CONCLUDE to signal
  EOF on last chunk write, so stream close does not
  require an additional QUIC packet

Closes #12933

20 months agoMANUAL.md: fix typo
Ramiro Garcia [Mon, 19 Feb 2024 18:29:50 +0000 (15:29 -0300)] 
MANUAL.md: fix typo

Closes #12965

20 months agoBINDINGS: add mcurl, the python binding
Daniel Stenberg [Mon, 19 Feb 2024 15:50:30 +0000 (16:50 +0100)] 
BINDINGS: add mcurl, the python binding

Ref: #12956
Closes #12962

20 months agomk-ca-bundle.md: cleanups and polish 12958/head
Daniel Stenberg [Mon, 19 Feb 2024 08:31:08 +0000 (09:31 +0100)] 
mk-ca-bundle.md: cleanups and polish

Closes #12958

20 months agospellcheck.yml: remove .1/.3 handling, clean all man page .md files
Daniel Stenberg [Mon, 19 Feb 2024 08:54:21 +0000 (09:54 +0100)] 
spellcheck.yml: remove .1/.3 handling, clean all man page .md files

Since we generate all .1 and .3 files from markdown now, we can limit
the spellcheck to the markdown versions only.

Closes #12960

20 months agolibcurl-docs: cleanups
Daniel Stenberg [Mon, 19 Feb 2024 09:56:14 +0000 (10:56 +0100)] 
libcurl-docs: cleanups

 CURLMOPT_SOCKETDATA.md: fix typo
 CURLMOPT_TIMERDATA.md: fix typo
 CURLOPT_COOKIELIST.m: quote strings
 CURLOPT_PREREQFUNCTION.md: quote variable names
 CURLOPT_TCP_NODELAY.md: rephrased to please spell checker
 CURLOPT_WILDCARDMATCH.md: rephrased
 libcurl-tutorial.md: use correct option name
 curl_global_init_mem.md: quote headers
 curl_easy_getinfo.md: use correct symbol names in headers
 curl_global_trace.md: quote some headers
 curl_ws_meta.md: quote struct field names
 libcurl-env.md: quote headers

20 months agocd2nroff: remove backticks from titles
Daniel Stenberg [Mon, 19 Feb 2024 09:56:38 +0000 (10:56 +0100)] 
cd2nroff: remove backticks from titles

20 months agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 19 Feb 2024 07:34:37 +0000 (08:34 +0100)] 
RELEASE-NOTES: synced

20 months agohttp_chunks: fix the accounting of consumed bytes
Stefan Eissing [Wed, 14 Feb 2024 15:27:23 +0000 (16:27 +0100)] 
http_chunks: fix the accounting of consumed bytes

Prior to this change chunks were handled correctly although in verbose
mode libcurl could incorrectly warn of "Leftovers after chunking" even
if there were none.

Reported-by: Michael Kaufmann
Fixes https://github.com/curl/curl/issues/12937
Closes https://github.com/curl/curl/pull/12939

20 months agofile: use xfer buf for file:// transfers
Stefan Eissing [Tue, 13 Feb 2024 10:39:06 +0000 (11:39 +0100)] 
file: use xfer buf for file:// transfers

- For file:// transfers use the multi handle's transfer buffer for
  up- and downloads.

Prior to this change a6c9a33 (precedes 8.6.0) changed the file://
transfers to use a smaller stack based buffer, and that caused a
significant performance decrease in Windows.

Bug: https://github.com/curl/curl/issues/12750#issuecomment-1920103086
Reported-by: edmcln@users.noreply.github.com
Closes https://github.com/curl/curl/pull/12932

20 months agoHTTP3.md: always run nghttp3 submodule init
Karthikdasari0423 [Mon, 12 Feb 2024 09:52:39 +0000 (15:22 +0530)] 
HTTP3.md: always run nghttp3 submodule init

- For consistency change all 'build nghttp3' commands to run submodule
  init after cloning, even if the branch does not have submodules.

Follow-up to 5a4b2f93 and 4f794558.

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

20 months agoCURLOPT_POSTQUOTE.md: fix typo
LeeRiva [Sun, 11 Feb 2024 21:52:12 +0000 (22:52 +0100)] 
CURLOPT_POSTQUOTE.md: fix typo

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

20 months agochecksrc.pl: fix handling .checksrc with CRLF
Evgeny Grin [Sun, 18 Feb 2024 06:36:27 +0000 (11:36 +0500)] 
checksrc.pl: fix handling .checksrc with CRLF

- When parsing .checksrc chomp the (CR)LF line ending.

Prior to this change on Windows checksrc.pl would not process the
symbols in .checksrc properly, since many git repos in Windows use auto
crlf to check out files with CRLF line endings.

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

20 months agocmake: fix install for older CMake versions
Richard Levitte [Sat, 10 Feb 2024 16:34:43 +0000 (17:34 +0100)] 
cmake: fix install for older CMake versions

- Generate the docs install list by using a foreach loop instead of
  LIST:TRANSFORM since older CMake can't handle the latter.

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

20 months agovtls: fix tls proxy peer verification
Stefan Eissing [Tue, 13 Feb 2024 10:05:21 +0000 (11:05 +0100)] 
vtls: fix tls proxy peer verification

- When verifying a proxy certificate for an ip address, use the correct
  ip family.

Prior to this change the "connection" ip family was used, which was not
necessarily the same.

Reported-by: HsiehYuho@users.noreply.github.com
Fixes https://github.com/curl/curl/issues/12831
Closes https://github.com/curl/curl/pull/12931

20 months agoCI: Bump the Circle CI base Ubuntu image to the latest 20.04
Dan Fandrich [Fri, 16 Feb 2024 00:04:40 +0000 (16:04 -0800)] 
CI: Bump the Circle CI base Ubuntu image to the latest 20.04

The previous ones are going to be removed soon, plus the new ones
include all the fixes since then.