Commit Graph

5875 Commits

Author SHA1 Message Date
Viktor Szakats
25cbc2f79a
tests: make the unit test result type CURLcode
Before this patch, the result code was a mixture of `int` and
`CURLcode`.

Also adjust casts and fix a couple of minor issues found along the way.

Cherry-picked from #13489
Closes #13600
2024-05-12 18:53:07 +02:00
Daniel Stenberg
0e37b42dc9
url: make parse_login_details use memdup0
Also make the user and password arguments mandatory, since all code
paths in libcurl used them anyway.

Adapted unit test case 1620 to the new rules.

Closes #13584
2024-05-10 22:53:12 +02:00
Stefan Eissing
bc6e3e6049
h3/ngtcp2: improve error handling
- identify ngtcp2 and nghttp3 error codes that are fatal
- close quic connection on fatal errors
- refuse further filter operations once connection is closed
- confusion about the nghttp3 API. We should close the QUIC stream on
  cancel and not use the nghttp3 calls intended to be invoked when the
  QUIC stream was closed by the peer.

Closes #13562
2024-05-10 09:29:19 +02:00
Stefan Eissing
3ecba2decd
unit2604: use alloc instead of overlong string const
Closes #13563
2024-05-08 23:30:43 +02:00
MAntoniak
1ea7dce08d
mbedtls: support TLS 1.3
Closes #13539
2024-05-08 11:11:45 +02:00
Daniel Stenberg
cd3463d99e
curl_path: make Curl_get_pathname use dynbuf
... instead of malloc and memcpy

- unit test 2604 verifies Curl_get_pathname()

Closes #13550
2024-05-08 10:10:12 +02:00
Daniel Stenberg
c294f9cb56
lib: make protocol handlers store scheme name lowercase
- saves a lowercase operation when the "[scheme]_proxy" name is
  generated
- appears less "shouting"
- update test 970, 972, 1438 and 1536

Closes #13553
2024-05-08 09:39:30 +02:00
Daniel Gustafsson
46d7214ca9 tls: Remove EXAMPLEs from deprecated options
CURLOPT_EGDSOCKET and CURLOPT_RANDOM_FILE are both completely dead
so remove their example sections since the code there is useless.
There is still a way to inject a random file for OpenSSL older than
1.1.0 but it's not what the example showed (and it's not even done
with this option) so we refrain from documenting it here.

Closes: #13540
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2024-05-06 20:55:27 +02:00
Daniel Gustafsson
26dd9f0c8c tests: Only require EXAMPLE for non-deprecated options
Manpages which document deprecated CURLOPT_ or CURLINFO_ are not
required to have an EXAMPLE section since they might effectively
be dead no-ops which we don't want to trick users into believing
they can use by copying example code.

Closes: #13540
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2024-05-06 20:55:00 +02:00
Daniel Gustafsson
96852a130a tests: Mark tftpd timer function as noreturn
This avoids the below compiler warning:

tftpd.c:280:1: warning: function 'timer' could be declared with
    attribute 'noreturn' [-Wmissing-noreturn]

Closes: #13534
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2024-05-06 09:51:16 +02:00
Jan Venekamp
6e4b7abfd3
bearssl: use common code for cipher suite lookup
Take advantage of the Curl_cipher_suite_walk_str() and
Curl_cipher_suite_get_str() functions introduced in commit fba9afeb.

This also fixes CURLOPT_SSL_CIPHER_LIST not working at all for bearssl
due to commit ff74cef5.

Closes #13464
2024-05-02 13:17:02 +02:00
Stefan Eissing
b06619d0a3
tests: add SNI and peer name checks
- connect to DNS names with trailing dot
- connect to DNS names with double trailing dot
- rustls, always give `peer->hostname` and let it
  figure out SNI itself
- add SNI tests for ip address and localhost
- document in code and TODO that QUIC with ngtcp2+wolfssl
  does not do proper peer verification of the certificate
- mbedtls, skip tests with ip address verification as not
  supported by the library

Closes #13486
2024-04-29 08:20:35 +02:00
Stefan Eissing
c8e0cd1de8
http3: quiche+ngtcp2 improvements
- quiche: error transfers that try to receive on a closed
  or draining connection
- ngtcp2: use callback for extending max bidi streams. This
  allows more precise calculation of MAX_CONCURRENT as we
  only can start a new stream when the server acknowledges
  the close - not when we locally have closed it.
- remove a fprintf() from h2-download client to avoid excess
  log files on tests timing out.

Closes #13475
2024-04-26 14:03:05 +02:00
Stefan Eissing
fb22459dc1
vtls: TLS session storage overhaul
- add session with destructor callback
- remove vtls `session_free` method
- let `Curl_ssl_addsessionid()` take ownership
  of session object, freeing it also on failures
- change tls backend use
- test_17, add tests for SSL session resumption

Closes #13386
2024-04-26 13:58:36 +02:00
Stefan Eissing
2d2c27e5a3
multi: multi_wait improvements
- only call `multi_getsock()` once for all transfers
 - realloc pollset array on demand
 - fold repeated sockets

Closes #13150
2024-04-25 23:31:59 +02:00
Stefan Eissing
886899143f
content_encoding: ignore duplicate chunked encoding
- ignore duplicate "chunked" transfer-encodings from
  a server to accomodate for broken implementations
- add test1482 and test1483

Reported-by: Mel Zuser
Fixes #13451
Closes #13461
2024-04-25 17:50:16 +02:00
Jan Venekamp
fba9afebba
mbedTLS: implement CURLOPT_SSL_CIPHER_LIST option
Use a lookup list to set the cipher suites, allowing the
ciphers to be set by either openssl or IANA names.

To keep the binary size of the lookup list down we compress
each entry in the cipher list down to 2 + 6 bytes using the
C preprocessor.

Closes #13442
2024-04-24 14:30:37 +02:00
Dan Fandrich
7237ee2c3d tests: fix feature case in test1481
This test was being skipped everywhere because the feature never
matched.

Closes #13445
2024-04-23 08:46:17 -07:00
Gusted
00bef95946
tool_operate: don't truncate the etag save file by default
This fixes a regression of 75d79a4486. The
code in tool-operate truncated the etag save file, under the assumption
that the file would be written with a new etag value. However since
75d79a4486 that might not be the case
anymore and could result in the file being truncated when --etag-compare
and --etag-save was used and that the etag value matched with what the
server responded. Instead the truncation should not be done when a new
etag value should be written.

Test 3204 was added to verify that the file with the etag value doesn't
change the contents when used by --etag-compare and --etage-save and
that value matches with what the server returns on a non 2xx response.

Closes #13432
2024-04-23 11:33:20 +02:00
Abdullah Alyan
f8011ffa1e
tests: enable test 1117 for hyper
Closes #13436
2024-04-22 13:30:14 +02:00
Daniel Stenberg
fe17c162d0
urlapi: allow setting port number zero
Also set and check errno when strtoul() parsing numbers for better error
checking.

Updated test 1560

Closes #13427
2024-04-19 23:54:21 +02:00
Daniel Stenberg
d54b0adbad
test2406: verify -f with HTTP/2 2024-04-19 23:45:16 +02:00
Stefan Eissing
5c59f91427
http2 + ngtcp2: pass CURLcode errors from callbacks
- errors returned by Curl_xfer_write_resp() and the header variant are
  not errors in the protocol. The result needs to be returned on the
  next recv() from the protocol filter.

- make xfer write errors for response data cause the stream to be
  cancelled

- added pytest test_02_14 and test_02_15 to verify that also for
  parallel processing

Reported-by: Laramie Leavitt
Fixes #13411
Closes #13424
2024-04-19 23:45:16 +02:00
Daniel Stenberg
a032e97f2b
http: reject HTTP major version switch mid connection
A connection that has seen an HTTP major version now refuses any other
major HTTP version in future responses. Previously, a HTTP/1.x
connection would just silently accept HTTP/2 or HTTP/3 in the status
lines as long as it had support for those built-in. It would then just
lead to confusion and badness.

Indirectly Spotted by CodeSonar which identified a duplicate assignment
in this function.

Add test 471 to verify

Closes #13421
2024-04-19 13:34:00 +02:00
Stefan Eissing
3e16c97fe9
tests: check caddy server version to match test expectations
- new caddy servers no longer return 200 on POSTs, but 405
  as they should

Closes #13405
2024-04-18 16:10:42 +02:00
Daniel Stenberg
3eac21d86b
urlapi: add CURLU_GET_EMPTY for empty queries and fragments
By default the API inhibits empty queries and fragments extracted.
Unless this new flag is set.

This also makes the behavior more consistent: without it set, zero
length queries and fragments are considered not present in the URL. With
the flag set, they are returned as a zero length strings if they were in
fact present in the URL.

This applies when extracting the individual query and fragment
components and for the full URL.

Closes #13396
2024-04-18 10:37:28 +02:00
Daniel Stenberg
4dc414c3ec
lib1560: test with leading zeroes and more IPv4 versions
Inspired by WHATWG URL Spec test inputs

Closes #13400
2024-04-17 22:45:24 +02:00
Daniel Stenberg
c37b694e46
urlapi: fix relative redirects to fragment-only
Using the URL API for a redirect URL when the redirected-to string
starts with a hash, ie is only a fragment, the API would produce the
wrong final URL.

Adjusted test 1560 to test for several new redirect cases.

Closes #13394
2024-04-17 22:41:47 +02:00
Stefan Eissing
c6655f7029
http/2, http/3: decouple stream state from easy handle
- add `Curl_hash_offt` as hashmap between a `curl_off_t` and
  an object. Use this in h2+h3 connection filters to associate
  `data->id` with the internal stream state.
- changed implementations of all affected connection filters
- removed `h2_ctx*` and `h3_ctx*` from `struct HTTP` and thus
  the easy handle
- solves the problem of attaching "foreign protocol" easy handles
  during connection shutdown

Test 1616 verifies the new hash functions.

Closes #13204
2024-04-17 14:24:09 +02:00
Dan Fandrich
5b94eced85 tests: Fix uninitialized value warning
The check for an option must be predicated on options existing at all.

Follow-up to f7cc9e91
2024-04-16 19:53:22 -07:00
MonkeybreadSoftware
add22feeef
idn: add native AppleIDN (icucore) support for macOS/iOS
I implemented the IDN functions for macOS and iOS using Unicode
libraries coming with macOS and iOS.

Builds and runs here on macOS 14.2.1. Also verified to load and
run on older macOS version 10.13.

Build requires macOS SDK 13 or equivalent.

Set `-DUSE_APPLE_IDN=ON` CMake option to enable it.
With autotools and other build tools, set these manual options:
```
CPPFLAGS=-DUSE_APPLE_IDN
LIBS=-licucore
```

Completes TODO 1.6.

TODO: add autotools option and feature-detection.

Refs: #5330 #5371
Co-authored-by: Viktor Szakats
Closes #13246
2024-04-17 00:24:09 +02:00
Stefan Eissing
08d10d2a00
http3: extend download abort tests, fixes in ngtcp2
- fix flow handling in ngtcp2 to ACK data on streams
  we abort ourself.
- extend test_02_23* cases to also run for h3
- skip test_02_23* for OpenSSL QUIC as it gets stalled
  on progressing the connection

Closes #13374
2024-04-16 23:48:22 +02:00
Daniel Stenberg
f7cc9e9177
tests: add -q as first option when invoking curl for tests
To reduce the risk that the user running the tests has a .curlrc present
that messes things up.

Support 'option="no-q"' for the <command> tag to switch it off on demand.
Use this new feature in test 433 and 436.

Ref: #13284
Closes #13387
2024-04-16 23:40:23 +02:00
Viktor Szakats
57af812e5f
tests: fix shellcheck issues in ech_tests.sh
Add double-quotes where missing.

Follow-up to a362962b72 #11922
Closes #13382
2024-04-16 19:47:13 +02:00
Viktor Szakats
5d3016adf7
dist: add ECH files to tarball
Also sort `EXTRA_DIST` list in `tests/Makefile.am` and make it diffable.

Follow-up to a362962b72 #11922
Closes #13381
2024-04-16 19:47:13 +02:00
Stefan Eissing
270a25c011
cw-out: improved error handling
- remember error encountered in invoking write callback and always fail
  afterwards without further invokes

- check behaviour in test_02_17 with h2-pausing client

Reported-by: Pavel Kropachev
Fixes #13337
Closes #13340
2024-04-16 15:52:10 +02:00
Viktor Szakats
f81f60206d
tidy-up: whitespace [ci skip] 2024-04-16 09:53:39 +02:00
Stephen Farrell
a362962b72
TLS: add support for ECH (Encrypted Client Hello)
An EXPERIMENTAL feature used with CURLOPT_ECH and --ech.

Closes #11922
2024-04-16 08:10:53 +02:00
Viktor Szakats
e411c98f70
build: prefer USE_IPV6 macro internally (was: ENABLE_IPV6)
Before this patch, two macros were used to guard IPv6 features in curl
sources: `ENABLE_IPV6` and `USE_IPV6`. This patch makes the source use
the latter for consistency with other similar switches.

`-DENABLE_IPV6` remains accepted for compatibility as a synonym for
`-DUSE_IPV6`, when passed to the compiler.

`ENABLE_IPV6` also remains the name of the CMake and `Makefile.vc`
options to control this feature.

Closes #13349
2024-04-13 08:33:26 +00:00
Stefan Eissing
8482ce53dd
CURLINFO_REQUEST_SIZE: fixed, add tests for transfer infos reported
- tests for 'size_request' and other stats reported, for
  presence and consistency

Reported-by: Jonatan Vela
Fixes #13269
Closes #13275
2024-04-12 13:20:09 +02:00
Viktor Szakats
0a4419ae4c
dist: add files missing from release tarball
Closes #13346
2024-04-11 15:52:08 +00:00
RainRat
1087937992
misc: fix typos
Closes #13344
2024-04-11 15:44:22 +02:00
Colin Leroy-Mira
bfe54b0e88
file: add support for getting basic directory listings
Not supported on Windows (yet)

Closes #13137
2024-04-11 12:37:12 +02:00
Stefan Eissing
c296abd42d
llist: add Curl_llist_append()
- use for better readability in all places where the "insert_next"
  actually performs an append to the list
- add some tests in unit1300

Closes #13336
2024-04-11 09:00:51 +02:00
Dmitry Karpov
02beac6bb6
lib: add curl_multi_waitfds
New function call, similar to curl_multi_fdset()

Closes #13135
2024-04-09 16:53:40 +02:00
Stefan Eissing
28c5ddf13a
tests: stabilitze test_02_23*
- h2-download now always opens the output file on first write callback
  invocation, if it will pause the transfer or not.
- Checks on output files then does not depend on the amount of data curl
  has collected for the first write.

Closes #13323
2024-04-09 13:27:21 +02:00
Stefan Eissing
3210101088
tls: use shared init code for TCP+QUIC
Closes #13172
2024-04-09 09:08:05 +02:00
Jan Macku
6b24f099fc
doc: pytest --repeat -> --count
Pytest doesn't have a `--repeat` option, but it does have a `--count`
option.

```
--count=COUNT         Number of times to repeat each test
```

Closes #13218
2024-04-09 08:44:09 +02:00
Stefan Eissing
1302aa6b50
http2: emit RST when client write fails
- When the writing of response data fails, reset the stream
  and do not return a callback error to nghttp2. That would
  be a fatal error for the connection and harm other requests.
- add test cases for various abort scenarios

Reported-by: Konstantin Kuzov
Fixes #13292
Closes #13298
2024-04-08 15:49:52 +02:00
Daniel Stenberg
50def7c881
NTLM_WB: drop support
The feature has not worked for months and has been marked as DEPRECATED
for six+ months.

Closes #13249
2024-04-08 13:58:58 +02:00