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.
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
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.
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.
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
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
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
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.
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
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`
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 ).
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
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
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.
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.
Jay Satiro [Fri, 9 Feb 2024 09:08:35 +0000 (04:08 -0500)]
transfer: improve Windows SO_SNDBUF update limit
- Change the 1 second SO_SNDBUF update limit from per transfer to per
connection.
Prior to this change many transfers over the same connection could cause
many SO_SNDBUF updates made to that connection per second, which was
unnecessary.
Jay Satiro [Fri, 9 Feb 2024 08:41:30 +0000 (03:41 -0500)]
schannel: fix hang on unexpected server close
- Treat TLS connection close (either due to a close_notify from the
server or just closed due to receiving 0) as pending data.
This is because in some cases schannel_recv knows the connection is
closed but has to return actual pending data so it can't return 0 or an
error to indicate no more data. In this case schannel_recv must be
called again, which only happens if readwrite_data sees that there is
still pending data.
Prior to this change if the total size of the body that libcurl expected
to receive from the server was unknown then it was possible under some
network conditions that libcurl would hang waiting to receive more data,
when in fact a close_notify alert indicating no more data would be sent
was already processed.
Dan Fandrich [Thu, 4 Jan 2024 18:32:04 +0000 (10:32 -0800)]
Revert "CI: run Circle macOS builds on x86 for now"
This reverts commit 2683de3078eadc86d9b182e7417f4ee75a247e2c.
ARM resources are now available in Circle CI, so run these builds on ARM
again. This platform needs explicit paths set to libpsl and its
dependency icu4c.
Stefan Eissing [Fri, 9 Feb 2024 12:10:08 +0000 (13:10 +0100)]
ftp: fix socket wait activity in ftp_domore_getsock
- when waiting on the data connection, always add the control socket to
the pollset on state STOP or let the pingpong add the socket according
to its needs.
Stefan Eissing [Fri, 26 Jan 2024 11:05:08 +0000 (12:05 +0100)]
multi: add xfer_buf to multi handle
- can be borrowed by transfer during recv-write operation
- needs to be released before borrowing again
- adjustis size to `data->set.buffer_size`
- used in transfer.c readwrite_data()
Stefan Eissing [Tue, 6 Feb 2024 10:56:35 +0000 (11:56 +0100)]
ftp: do lineend conversions in client writer
- remove the ftp special handling from sendf.c
- let ftp_do() add a client writer that does
the linened conversions
- change the lineend conversion to no longer
modify the passed buffer, but write smaller
chunks to the next cwriter instead. The
inefficiency of this will be mitigated once
we add output buffering for all client writes.
Daniel Stenberg [Wed, 7 Feb 2024 13:06:56 +0000 (14:06 +0100)]
lib582: remove code causing warning that is never run
The previous realloc code in this code could trigger a compiler warning,
but since that code path cannot happen in normal circumstances it now
instead exits with an error message there.
Stefan Eissing [Thu, 1 Feb 2024 17:15:50 +0000 (18:15 +0100)]
vtls: revert "receive max buffer" + add test case
- add test_05_04 for requests using http/1.0, http/1.1 and h2 against an
Apache resource that does an unclean TLS shutdown.
- revert special workarund in openssl.c for suppressing shutdown errors
on multiplexed connections
- vlts.c restore to its state before 9a90c9dd64d2f03601833a70786d485851bd1b53
Daniel Stenberg [Mon, 5 Feb 2024 16:04:28 +0000 (17:04 +0100)]
tests: support setting/using blank content env variables
- test450: remove --config from the keywords
- test2080: change return code
- test428: add --config as a keyword
- test428: disable on Windows due to CI problems
Daniel Stenberg [Tue, 6 Feb 2024 09:15:52 +0000 (10:15 +0100)]
lib: convert Curl_get_line to use dynbuf
Create the line in a dynbuf. Aborts the reading of the file on
errors. Avoids having to always allocate maximum amount from the
start. Avoids direct malloc.
Daniel Stenberg [Mon, 5 Feb 2024 23:09:11 +0000 (18:09 -0500)]
tool_operate: change precedence of server Retry-After time
- When calculating the retry time, no longer allow a server's requested
Retry-After time to take precedence over a longer retry time (either
default algorithmic or user-specified).
Prior to this change the server's Retry-After time took precedence over
curl's retry time in all cases, but that's not always practical for
short Retry-After times depending on how busy the server is.
Stefan Eissing [Thu, 1 Feb 2024 09:51:45 +0000 (10:51 +0100)]
https-proxy: use IP address and cert with ip in alt names
- improve info logging when peer verification fails to indicate
if DNS name or ip address has been tried to match
- add test case for contacting https proxy with ip address
- add pytest env check on loaded credentials and re-issue
when they are no longer valid
- disable proxy ip address test for bearssl, since not supported there
Peter Krefting [Fri, 2 Feb 2024 22:22:32 +0000 (23:22 +0100)]
version: allow building with ancient libpsl
The psl_check_version_number() API was added in libpsl 0.11.0. CentOS 7
ships with version 0.7.0 which lacks this API. Revert to using the older
versioning API if we detect an old libpsl version.
Daniel Stenberg [Mon, 5 Feb 2024 22:23:56 +0000 (23:23 +0100)]
docs: make curldown do angle brackets like markdown
Make sure we use \< and \> in markdown all over so that it renders
correctly, on GitHub and elsewhere. cd2nroff now outputs a warning if it
finds an unescaled angle bracket.