Commit Graph

31599 Commits

Author SHA1 Message Date
Daniel Stenberg
aaab6cb0c4
cmdline-opts/gen.pl: error on initital blank line
After the "---" separator, there should be no blank line and this script
now errors out if one is detected.

Ref: #12696
Closes #12698
2024-01-14 18:12:14 +01:00
Daniel Stenberg
e186ca6534
cf-h1-proxy: no CURLOPT_USERAGENT in CONNECT with hyper
Follow-up to 693cd16793 which was incomplete

Ref #12680
Closes #12697
2024-01-14 18:11:15 +01:00
Daniel Stenberg
beb2283746
curl_multi_fdset.3: remove mention of null pointer support
... since this funtion has not supported null pointer fd_set arguments since
at least 2006. (That's when I stopped my git blame journey)

Fixes #12691
Reported-by: sfan5 on github
Closes #12692
2024-01-14 14:53:38 +01:00
Mark Huang
3167dab0d5
docs/cmdline: remove unnecessary line breaks
Closes #12696
2024-01-14 14:45:23 +01:00
Daniel Stenberg
adfffc39a3
transfer: remove warning: Value stored to 'blen' is never read
Detected by scan-build

Follow-up from 1cd2f0072f

Closes #12693
2024-01-14 14:33:46 +01:00
Stefan Eissing
d7b6ce64ce
lib: replace readwrite with write_resp
This clarifies the handling of server responses by folding the code for
the complicated protocols into their protocol handlers. This concerns
mainly HTTP and its bastard sibling RTSP.

The terms "read" and "write" are often used without clear context if
they refer to the connect or the client/application side of a
transfer. This PR uses "read/write" for operations on the client side
and "send/receive" for the connection, e.g. server side. If this is
considered useful, we can revisit renaming of further methods in another
PR.

Curl's protocol handler `readwrite()` method been changed:

```diff
-  CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn,
-                        const char *buf, size_t blen,
-                        size_t *pconsumed, bool *readmore);
+  CURLcode (*write_resp)(struct Curl_easy *data, const char *buf, size_t blen,
+                         bool is_eos, bool *done);
```

The name was changed to clarify that this writes reponse data to the
client side. The parameter changes are:

* `conn` removed as it always operates on `data->conn`
* `pconsumed` removed as the method needs to handle all data on success
* `readmore` removed as no longer necessary
* `is_eos` as indicator that this is the last call for the transfer
  response (end-of-stream).
* `done` TRUE on return iff the transfer response is to be treated as
  finished

This change affects many files only because of updated comments in
handlers that provide no implementation. The real change is that the
HTTP protocol handlers now provide an implementation.

The HTTP protocol handlers `write_resp()` implementation will get passed
**all** raw data of a server response for the transfer. The HTTP/1.x
formatted status and headers, as well as the undecoded response
body. `Curl_http_write_resp_hds()` is used internally to parse the
response headers and pass them on. This method is public as the RTSP
protocol handler also uses it.

HTTP/1.1 "chunked" transport encoding is now part of the general
*content encoding* writer stack, just like other encodings. A new flag
`CLIENTWRITE_EOS` was added for the last client write. This allows
writers to verify that they are in a valid end state. The chunked
decoder will check if it indeed has seen the last chunk.

The general response handling in `transfer.c:466` happens in function
`readwrite_data()`. This mainly operates now like:

```
static CURLcode readwrite_data(data, ...)
{
  do {
    Curl_xfer_recv_resp(data, buf)
    ...
    Curl_xfer_write_resp(data, buf)
    ...
  } while(interested);
  ...
}
```

All the response data handling is implemented in
`Curl_xfer_write_resp()`. It calls the protocol handler's `write_resp()`
implementation if available, or does the default behaviour.

All raw response data needs to pass through this function. Which also
means that anyone in possession of such data may call
`Curl_xfer_write_resp()`.

Closes #12480
2024-01-13 17:23:42 +01:00
Daniel Stenberg
d587ab422d
RELEASE-NOTES: synced 2024-01-13 17:02:45 +01:00
Daniel Stenberg
9582f20d8a
TODO: TFTP doesn't convert LF to CRLF for mode=netascii
Closes #12655
Closes #12690
2024-01-13 16:26:17 +01:00
Daniel Stenberg
9729560a6f
gen: do italics/bold for a range of letters, not just single word
Previously it would match only on a sequence of non-space, which made it
miss to highlight for example "public suffix list".

Updated the recent cookie.d edit from 5da57193b7 to use bold instead
of italics.

Closes #12689
2024-01-13 16:25:20 +01:00
Daniel Stenberg
5da57193b7
docs: describe and highlight super cookies
Reported-by: Yadhu Krishna M

Closes #12687
2024-01-12 23:55:20 +01:00
Daniel Stenberg
b3f02e1d92
configure: when enabling QUIC, check that TLS supports QUIC
Most importantly perhaps is when using OpenSSL that the used
build/flavor has the QUIC API: the vanilla OpenSSL does not, only
BoringSSL, libressl, AWS-LC and quictls do.

Ref: 5d044ad948 (r136780413)

Closes #12683
2024-01-12 09:47:42 +01:00
Stefan Eissing
5d044ad948
vquic: extract TLS setup into own source
- separate ngtcp2 specific parts out
- provide callback during init to allow ngtcp2 to apply its defaults

Closes #12678
2024-01-11 10:43:00 +01:00
Sergey Markelov
98543fc2cf
multi: remove total timer reset in file_do() while fetching file://
The total timer is properly reset in MSTATE_INIT.  MSTATE_CONNECT starts
with resetting the timer that is a start point for further multi states.
If file://, MSTATE_DO calls file_do() that should not reset the total
timer.  Otherwise, the total time is always less than the pre-transfer
and the start transfer times.

Closes #12682
2024-01-11 08:51:29 +01:00
Daniel Stenberg
693cd16793
http_proxy: a blank CURLOPT_USERAGENT should not be used in CONNECT
Extended test 80 to verify this.

Reported-by: Stefan Eissing
Fixes #12680
Closes #12681
2024-01-11 08:49:21 +01:00
Daniel Stenberg
dd0f680fc0
sectransp: do verify_cert without memdup for blobs
Since the information is then already stored in memory, this can avoid
an extra set of malloc + free calls.

Closes #12679
2024-01-10 23:22:52 +01:00
Daniel Stenberg
24ae4a07f3
hsts: remove assert for zero length domain
A zero length domain can happen if the HSTS parser is given invalid
input data which is not unheard of and is done by the fuzzer.

Follow-up from cfe7902111

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65661

Closes #12676
2024-01-10 13:58:14 +01:00
Daniel Stenberg
a9e128d569
headers: make sure the trailing newline is not stored
extended test1940 to verify blank header fields too

Bug: https://curl.se/mail/lib-2024-01/0019.html
Reported-by: Dmitry Karpov
Closes #12675
2024-01-10 13:57:08 +01:00
Daniel Stenberg
77c3c1a8fb
curl_easy_header.3: tiny language fix
Closes #12672
2024-01-10 09:42:49 +01:00
Daniel Stenberg
5d75bcd2ea
examples/range.c: add
Closes #12671
2024-01-10 09:33:08 +01:00
Daniel Stenberg
1404bcdeae
examples/netrc.c: add
Closes #12671
2024-01-10 09:33:06 +01:00
Daniel Stenberg
dd09f88f13
examples/ipv6.c: new example showing IPv6-only internet transfer
Closes #12671
2024-01-10 09:33:03 +01:00
Daniel Stenberg
ebbc6243d7
examples/address-scope.c: renamed from ipv6.c
It shows address scope use really

Closes #12671
2024-01-10 09:32:54 +01:00
Stefan Eissing
48d86999af
multi: pollset adjust, init with FIRSTSOCKET during connect
- `conn->sockfd` is set by `Curl_setup_transfer()`, but that
  is called *after* the connection has been established
- use `conn->sock[FIRSTSOCKET]` instead

Follow-up to a0f94800d5
Closes #12664
2024-01-09 17:41:13 +01:00
Daniel Stenberg
6d9bf0db7e
WEBSOCKET.md: remove dead link 2024-01-09 16:00:29 +01:00
Daniel Stenberg
e2fbe56610
CI: spellcheck/appveyor: invoke configure --without-libpsl
Follow-up to 2998874bb6
2024-01-09 16:00:29 +01:00
Daniel Stenberg
89bb115e4a
cmdline/docs/*.d: switch to using ## instead of .IP
To make the editing easier. To write and to read.

Closes #12667
2024-01-09 16:00:23 +01:00
Daniel Stenberg
a859e29a60
gen.pl: support ## for doing .IP in table-like lists
Warn on use of .RS/.IP/.RE

Closes #12667
2024-01-09 16:00:16 +01:00
Jay Satiro
0ad13e0618 cookie.d: Document use of empty string to enable cookie engine
- Explain that --cookie "" can be used to enable the cookie engine
  without reading any initial cookies.

As is documented in CURLOPT_COOKIEFILE.

Ref: https://curl.se/libcurl/c/CURLOPT_COOKIEFILE.html

Bug: https://github.com/curl/curl/issues/12643#issuecomment-1879844420
Reported-by: janko-js@users.noreply.github.com

Closes https://github.com/curl/curl/pull/12646
2024-01-09 03:40:47 -05:00
Daniel Stenberg
ac4dbc9cb5
setopt: use memdup0 when cloning COPYPOSTFIELDS
Closes #12651
2024-01-09 09:23:15 +01:00
Daniel Stenberg
2959f45b7d
telnet: use dynbuf instad of malloc for escape buffer
Previously, send_telnet_data() would malloc + free a buffer every time
for escaping IAC codes. Now, it reuses a dynbuf for this purpose.

Closes #12652
2024-01-09 09:21:01 +01:00
Daniel Stenberg
d18811b52b
CI: install libpsl or configure --without-libpsl in builds
As a follow-up to the stricted libpsl check in configure
2024-01-09 09:10:58 +01:00
Daniel Stenberg
2998874bb6
configure: make libpsl detection failure cause error
To force users to explictily disable it if they really don't want it
used and make it harder to accidentally miss it.

--without-libpsl is the option to use if PSL is not wanted.

Closes #12661
2024-01-09 09:09:51 +01:00
Daniel Stenberg
912d80c680
RELEASE-NOTES: synced 2024-01-08 23:00:21 +01:00
Daniel Stenberg
a3abc81a48
pop3: replace calloc + memcpy with memdup0
... and make sure to return error on out of memory.

Closes #12650
2024-01-08 22:55:39 +01:00
Daniel Stenberg
cfe7902111
lib: add debug log outputs for CURLE_BAD_FUNCTION_ARGUMENT
Closes #12658
2024-01-08 22:48:24 +01:00
Daniel Stenberg
8e0323b4b5
mime: use memdup0 instead of malloc + memcpy
Closes #12649
2024-01-08 22:40:43 +01:00
Daniel Stenberg
fb414370ac
tool_getparam: move the --rate logic into set_rate() 2024-01-08 22:39:18 +01:00
Daniel Stenberg
9e4e527735
tool_getparam: switch to an enum for every option
To make the big switch much easier to read/understand and to make it
easier to add new options.
2024-01-08 22:39:11 +01:00
Daniel Stenberg
1f4433dad4
tool_getparam: build post data using dynbuf (more) 2024-01-08 22:38:22 +01:00
Daniel Stenberg
1dba44b2f1
tool_getparam: replace malloc + copy by dynbuf for --data 2024-01-08 22:38:22 +01:00
Daniel Stenberg
f37840a46e
tool_getparam: make data_urlencode avoid direct malloc
use aprintf() instead
2024-01-08 22:38:22 +01:00
Daniel Stenberg
3870d03b5d
tool_getparam: move the --url-query logic into url_query()
This function is not doing post at all so it was always weirdly placed.
2024-01-08 22:38:22 +01:00
Daniel Stenberg
8aecfad9e6
tool_getparam: move the --data logic into set_data() 2024-01-08 22:38:22 +01:00
Daniel Stenberg
f6e97effb6
tool_getparam: unify the cmdline switch() into a single one
- easier to follow, easier to modify, easier to extend, possibly slightly
  faster

- each case now has the long option as a comment
2024-01-08 22:38:22 +01:00
Daniel Stenberg
07dd60c05b
tool_getparam: bsearch cmdline options
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
2024-01-08 22:38:22 +01:00
Gabe
57cc70e559
COPYING: update copyright year
Closes #12654
2024-01-08 18:40:06 +01:00
Stefan Eissing
d0cb2c7a1f
url: init conn->sockfd and writesockfd to CURL_SOCKET_BAD
Also add more tracing to test 19

Follow-up to a0f9480

Fixes #12657
Closes #12659
2024-01-08 16:51:13 +01:00
Daniel Stenberg
e556470c23
connect: remove margin from eyeballer alloc
Presumably leftovers from debugging

Closes #12647
2024-01-08 09:30:45 +01:00
Daniel Stenberg
1058483615
ftp: only consider entry path if it has a length
Follow-up from 8edcfedc1a

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65631

Avoids a NULL pointer deref.

Closes #12648
2024-01-07 16:34:55 +01:00
Stefan Eissing
a0f94800d5
transfer: adjust_pollset improvements
- let `multi_getsock()` initialize the pollset in what the
  transfer state requires in regards to SEND/RECV
- change connection filters `adjust_pollset()` implementation
  to react on the presence of POLLIN/-OUT in the pollset and
  no longer check CURL_WANT_SEND/CURL_WANT_RECV
- cf-socket will no longer add POLLIN on its own
- http2 and http/3 filters will only do adjustments if the
  passed pollset wants to POLLIN/OUT for the transfer on
  the socket. This is similar to the HTTP/2 proxy filter
  and works in stacked filters.

Closes #12640
2024-01-07 14:36:25 +01:00