Commit Graph

13138 Commits

Author SHA1 Message Date
Daniel Stenberg
fff65550bc
CURLOPT_MAIL_RCPT_ALLOWFAILS: replace CURLOPT_MAIL_RCPT_ALLLOWFAILS
Deprecate the name using three Ls and prefer the name with two.

Replaces #10047
Closes #11218
2023-06-03 23:29:04 +02:00
Stefan Eissing
f4b5c88ab7
http2: better support for --limit-rate
- leave transfer loop when --limit-rate is in effect and has
  been received
- adjust stream window size to --limit-rate plus some slack
  to make the server observe the pacing we want
- add test case to confirm behaviour

Closes #11115
2023-06-02 23:06:12 +02:00
Stefan Eissing
e054a16830
curl_log: evaluate log statement only when transfer is verbose
Closes #11238
2023-06-02 23:03:45 +02:00
Daniel Stenberg
93df7134b5
libssh2: provide error message when setting host key type fails
Ref: https://curl.se/mail/archive-2023-06/0001.html

Closes #11240
2023-06-02 23:00:27 +02:00
Daniel Stenberg
10d8404301
libssh2: use custom memory functions
Because of how libssh2_userauth_keyboard_interactive_ex() works: the
libcurl callback allocates memory that is later free()d by libssh2, we
must set the custom memory functions.

Reverts 8b5f100db3

Ref: https://github.com/libssh2/libssh2/issues/1078
Closes #11235
2023-06-01 16:06:39 +02:00
Stefan Eissing
c4bd61ddff
http3: send EOF indicator early as possible
- ngtcp2 and quiche implementations relied on the DONE_SEND event
  to forward the EOF for uploads to the libraries. This often
  result in a last 0 length EOF data. Tracking the amount of
  data left to upload allows EOF indication earlier.
- refs #11205 where CloudFlare DoH servers did not like to
  receive the initial upload DATA without EOF and returned
  a 400 Bad Request

Reported-by: Sergey Fionov
Fixes #11205
Closes #11207
2023-05-26 08:37:58 +02:00
Daniel Stenberg
196f3c3484
cf-socket: restore Curl_sock_assign_addr()
Regression since it was not private. Also used by msh3.c

Follow-up to 8e85764b7b
Reported-by: Gisle Vanem
Fixes #11202
Closes #11204
2023-05-25 14:34:39 +02:00
Daniel Stenberg
be17dc9d31
libssh: when keyboard-interactive auth fails, try password
The state machine had a mistake in that it would not carry on to that
next step.

This also adds a verbose output what methods that are available from the
server and renames the macros that change to the next auth methods to
try.

Reported-by: 左潇峰
Fixes #11196
Closes #11197
2023-05-25 11:09:29 +02:00
Daniel Stenberg
6375a65433
urlapi: remove superfluous host name check
... as it is checked later more proper.

Closes #11195
2023-05-25 08:30:20 +02:00
Stefan Eissing
5c58cb0212
http2: fix EOF handling on uploads with auth negotiation
- doing a POST with `--digest` does an override on the initial request
  with `Content-Length: 0`, but the http2 filter was unaware of that
  and expected the originally request body. It did therefore not
  send a final DATA frame with EOF flag to the server.
- The fix overrides any initial notion of post size when the `done_send`
  event is triggered by the transfer loop, leading to the EOF that
  is necessary.
- refs #11194. The fault did not happen in testing, as Apache httpd
  never tries to read the request body of the initial request,
  sends the 401 reply and closes the stream. The server used in the
  reported issue however tried to read the EOF and timed out on the
  request.

Reported-by: Aleksander Mazur
Fixes #11194
Cloes #11200
2023-05-25 08:26:18 +02:00
Daniel Stenberg
8e85764b7b
lib: remove unused functions, make single-use static
Closes #11174
2023-05-23 11:08:51 +02:00
Daniel Stenberg
127eb0d83a
misc: fix spelling mistakes
Reported-by: musvaage on github
Fixes #11171
Closes #11172
2023-05-23 10:42:09 +02:00
Stefan Eissing
88332049ea
http/2: unstick uploads
- refs #11157 and #11175 where uploads get stuck or lead to RST streams
- fixes our h2 send behaviour to continue sending in the nghttp2 session
  as long as it wants to. This will empty our send buffer as long as
  the remote stream/connection window allows.
- in case the window is exhausted, the data remaining in the send buffer
  will wait for a WINDOW_UPDATE from the server. Which is a socket event
  that engages our transfer loop again
- the problem in the issue was that we did not exhaust the window, but
  left data in the sendbuffer and no further socket events did happen.
  The server was just waiting for us to send more.
- relatedly, there was an issue fixed that closing a stream with KEEP_HOLD
  set kept the transfer from shutting down - as it should have - leading
  to a timeout.

Closes #11176
2023-05-22 16:19:13 +02:00
Daniel Stenberg
954c7dfb91
sectransp.c: make the code c89 compatible
Follow-up to dd2bb48552

Reported-by: FeignClaims on github
Fixes #11155
Closes #11159
2023-05-21 14:02:11 +02:00
Emanuele Torre
eef076baa6
Revert "urlapi: respect CURLU_ALLOW_SPACE and CURLU_NO_AUTHORITY for redirects"
This reverts commit df6c2f7b54.
(It only keep the test case that checks redirection to an absolute URL
without hostname and CURLU_NO_AUTHORITY).

I originally wanted to make CURLU_ALLOW_SPACE accept spaces in the
hostname only because I thought
curl_url_set(CURLUPART_URL, CURLU_ALLOW_SPACE) was already accepting
them, and they were only not being accepted in the hostname when
curl_url_set(CURLUPART_URL) was used for a redirection.

That is not actually the case, urlapi never accepted hostnames with
spaces, and a hostname with a space in it never makes sense.
I probably misread the output of my original test when I they were
normally accepted when using CURLU_ALLOW_SPACE, and not redirecting.

Some other URL parsers seems to allow space in the host part of the URL,
e.g. both python3's urllib.parse module, and Chromium's javascript URL
object allow spaces (chromium percent escapes the spaces with %20),
(they also both ignore TABs, and other whitespace characters), but those
URLs with spaces in the hostname are useless, neither python3's requests
module nor Chromium's window.location can actually use them.

There is no reason to add support for URLs with spaces in the host,
since it was not a inconsistency bug; let's revert that patch before it
makes it into release. Sorry about that.

I also reverted the extra check for CURLU_NO_AUTHORITY since that does
not seem to be necessary, CURLU_NO_AUTHORITY already worked for
redirects.

Closes #11169
2023-05-21 13:59:04 +02:00
Stefan Eissing
0cab1359a1
http2: upload improvements
Make send buffer smaller to have progress and "upload done" reporting
closer to reality. Fix handling of send "drain" condition to no longer
trigger once the transfer loop reports it is done sending. Also do not
trigger the send "drain" on RST streams.

Background:
- a upload stall was reported in #11157 that timed out
- test_07_33a reproduces a problem with such a stall if the
  server 404s the request and RSTs the stream.
- test_07_33b verifies a successful PUT, using the parameters
  from #11157 and checks success

Ref: #11157
Closes #11165
2023-05-20 23:07:45 +02:00
Stefan Eissing
1886eef7fa
http2: increase stream window size to 10 MB
Reported-by: pandada8 on github

Fixes #11162
Closes #11167
2023-05-20 23:05:07 +02:00
Daniel Stenberg
54ce13d3ff
lib: rename struct 'http_req' to 'httpreq'
Because FreeBSD 14 kidnapped the name.
Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271526

Fixes #11163
Closes #11164
2023-05-20 23:03:01 +02:00
Stefan Eissing
7ab94d7d57
ngtcp2: proper handling of uint64_t when adjusting send buffer
Fixes #11149
Closes #11153
2023-05-19 16:23:19 +02:00
Stefan Eissing
e0ddfc8e05
ngtcp2: fix compiler warning about possible null-deref
- compiler analyzer did not include the call context for this
  static function where the condition had already been checked.
- eleminating the problem by making stream a call parameter

Fixes #11147
Closes #11151
2023-05-19 16:19:56 +02:00
Antoine Pitrou
d65321f939
select: avoid returning an error on EINTR from select() or poll()
This was already done for the poll() and select() calls
made directly from Curl_poll(), but was missed in
Curl_wait_ms(), which is called when there are no fds
to wait on.

Fixes #11135
Closes #11143
2023-05-19 16:16:26 +02:00
Daniel Stenberg
5b4bcc6ede
vquic.c: make recvfrom_packets static, avoid compiler warning
warning: no previous prototype for 'recvfrom_packets'

Reported-by: Keitagit-kun on github
Fixes #11146
Closes #11148
2023-05-19 16:15:22 +02:00
Daniel Stenberg
92772e6d39
urlapi: allow numerical parts in the host name
It can only be an IPv4 address if all parts are all digits and no more than
four parts, otherwise it is a host name. Even slightly wrong IPv4 will now be
passed through as a host name.

Regression from 17a15d8846 shipped in 8.1.0

Extended test 1560 accordingly.

Reported-by: Pavel Kalyugin
Fixes #11129
Closes #11131
2023-05-19 16:01:26 +02:00
Emilio Cobos Álvarez
77c9a9845b
http2: double http request parser max line length
This works around #11138, by doubling the limit, and should be a
relatively safe fix.

Ideally the buffer would grow as needed and there would be no need for a
limit? But that might be follow-up material.

Fixes #11138
Closes #11139
2023-05-19 01:09:36 +02:00
Deal(一线灵)
446061e6cb
cmake: repair cross compiling
It cannot *run* code for testing purposes when cross-compiling.

Closes #11130
2023-05-18 21:13:12 +02:00
Stefan Eissing
408eb87bb3
cf-socket: completely remove the disabled USE_RECV_BEFORE_SEND_WORKAROUND
Closes #11118
2023-05-18 20:55:16 +02:00
Emanuele Torre
df6c2f7b54
urlapi: respect CURLU_ALLOW_SPACE and CURLU_NO_AUTHORITY for redirects
curl_url_set(uh, CURLUPART_URL, redirurl, flags)  was not respecing
CURLU_ALLOW_SPACE and CURLU_NO_AUTHORITY in the host part of redirurl
when redirecting to an absolute URL.

Closes #11136
2023-05-18 20:52:59 +02:00
Colin Cross
e743425bc6
hostip: move easy_lock.h include above curl_memory.h
Similar to #9561, move easy_lock.h above curl_memory.h to fix building
against musl libc.

Closes #11140
2023-05-18 20:50:22 +02:00
Emanuele Torre
f198d33e8d
checksrc: disallow spaces before labels
Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
  line
* 1 was indented with the indentation level of the following line minus
  three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134
2023-05-18 20:45:04 +02:00
Daniel Stenberg
d334b02924
cookie: update the comment on cookie length and size limits
To refer to the proper cookie RFC and the upcoming RFC refresh.

Closes #11127
2023-05-18 20:43:25 +02:00
Daniel Stenberg
f1e5d8a731
url: provide better error message when URLs fail to parse
By providing the URL API error message into the error message.

Ref: #11129
Closes #11137
2023-05-18 20:42:17 +02:00
Daniel Stenberg
f446258f02
hostip: include easy_lock.h before using GLOBAL_INIT_IS_THREADSAFE
Since that header file is the only place that define can be defined.

Reported-by: Marc Deslauriers

Follow-up to 13718030ad

Closes #11121
2023-05-17 08:03:10 +02:00
Daniel Silverstone
e915b6904c
ssh: Add support for libssh2 read timeout
Hook the new (1.11.0 or newer) libssh2 support for setting a read timeout
into the SERVER_RESPONSE_TIMEOUT option.  With this done, clients can use
the standard curl response timeout setting to also control the time that
libssh2 will wait for packets from a slow server.  This is necessary to
enable use of very slow SFTP servers.

Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>

Closes #10965
2023-05-15 13:20:47 +02:00
Marcel Raad
2a154560c0
md(4|5): don't use deprecated iOS functions
They are marked as deprecated in iOS 13.0, which might result in
warnings-as-errors.

Also, use `*_MIN_REQUIRED` instead of `*_MIN_ALLOWED`, which seems to
be what's currently used.

Bug: https://github.com/curl/curl/issues/11098
Closes https://github.com/curl/curl/pull/11102
2023-05-13 09:57:54 +02:00
Marcel Raad
e587598534
md4: only build when used
Its only usage in curl_ntlm_core.c is guarded by `USE_CURL_NTLM_CORE`,
so let's use this here too.

Ref: https://github.com/curl/curl/issues/11098
Closes https://github.com/curl/curl/pull/11102
2023-05-13 09:57:35 +02:00
Shohei Maeda
ac5ad52142
url: fix null dispname for --connect-to option
Closes #11106
2023-05-12 17:52:07 +02:00
Daniel Stenberg
cd1c611b24
headers: clear (possibly) lingering pointer in init
The "prevhead" pointer is used for the headers storage but was not
cleared correctly in init, which made it possible to act up when a
handle is reused.

Reported-by: Steve Herrell
Fixes #11101
Closes #11103
2023-05-12 17:48:20 +02:00
Daniel Stenberg
10998e3b89
ngtcp2: use 0.15.0
- nghttp3 0.11.0
- nghttp2 1.53.0

Adapt to new API calls

Closes #11031
2023-05-12 17:25:38 +02:00
Jay Satiro
2cc1c93f45 openssl: fix indent 2023-05-10 14:03:30 -04:00
Daniel Stenberg
8e6abece40
hostip: use time_t for storing oldest DNS entry
Theoretically, the oldest time could overflow an int. In practice that
won't happen, but let's do this to please analyzers.

Follow-up to 9ed7d56e04

Pointed out by Coverity.
Closes #11094
2023-05-09 17:56:19 +02:00
Daniel Stenberg
f7170a8f2e
http: free the url before storing a new copy
To avoid a memory-leak.

Reported-by: Hiroki Kurosawa

Closes #11093
2023-05-09 09:47:30 +02:00
Daniel Stenberg
8e21b1a05f
libssh2: free fingerprint better
Reported-by: Wei Chong Tan
Closes #11088
2023-05-08 16:47:03 +02:00
Daniel Stenberg
9ed7d56e04
hostip: enforce a maximum DNS cache size independent of timeout value
To reduce the damage an application can cause if using -1 or other
ridiculous timeout values and letting the cache live long times.

The maximum number of entries in the DNS cache is now totally
arbitrarily and hard-coded set to 29999.

Closes #11084
2023-05-08 14:55:26 +02:00
Daniel Stenberg
f62557276a
hostip: store dns timeout as 'int'
... because it set and held as an 'int' elsewhere and can never be
larger.
2023-05-08 14:55:19 +02:00
Daniel Stenberg
fb7886b9c9
transfer: refuse POSTFIELDS + RESUME_FROM combo
The code assumes that such a resume is wanting to continue an upload
using the read callback, and since POSTFIELDS is done without callback
libcurl will just misbehave.

This combo will make the transfer fail with CURLE_BAD_FUNCTION_ARGUMENT
with an explanation in the error message.

Reported-by: Smackd0wn on github
Fixes #11081
Closes #11083
2023-05-08 14:10:34 +02:00
François Michel
89f6fafedb
quiche: disable pacing while pacing is not actually performed
Closes #11068
2023-05-03 13:59:17 +02:00
Daniel Stenberg
d8df0d6db7
easy_cleanup: require a "good" handle to act
By insisting that the passed in handle is "good" (the magic number is
intact), this can limit the potential damage if a bad pointer is passed
in. Like when this function is called twice on the same handle pointer.

Ref: #10964
Closes #11061
2023-05-02 13:24:30 +02:00
Andreas Falkenhahn
b8d7746e3c amiga: Fix CA certificate paths for AmiSSL and MorphOS
AmiSSL stores certificates in `AmiSSL:Certs` and MorphOS stores them in
`MOSSYS:Data/SSL/curl-ca-bundle.crt`.

Closes https://github.com/curl/curl/pull/11059
2023-05-01 14:08:55 -04:00
Daniel Stenberg
b637166092
http2: (void)-mark when we explicitly ignore the return code
When h2_progress_egress() is called. Pointed out by Coverity.

Closes #11057
2023-04-30 11:26:07 +02:00
Daniel Stenberg
9ce7eee070
checksrc: find bad indentation in conditions without open brace
If the previous line starts with if/while/for AND ends with a closed
parenthesis and there's an equal number of open and closed parentheses
on that line, verify that this line is indented $indent more steps, if
not a cpp line.

Also adjust the fall-out from this fix.

Closes #11054
2023-04-28 23:11:00 +02:00