Commit Graph

6240 Commits

Author SHA1 Message Date
Daniel Stenberg
e9b9bbac22
netrc: address several netrc parser flaws
- make sure that a match that returns a username also returns a
  password, that should be blank if no password is found

- fix handling of multiple logins for same host where the password/login
  order might be reversed.

- reject credentials provided in the .netrc if they contain ASCII control
  codes - if the used protocol does not support such (like HTTP and WS do)

Reported-by: Harry Sintonen

Add test 478, 479 and 480 to verify. Updated unit 1304.

Closes #15586
2024-11-17 11:33:56 +01:00
Daniel Stenberg
bc34ebc87b
curl.h: mark two error codes as obsolete
Not used by libcurl since many years

Closes #15538
2024-11-16 23:39:04 +01:00
Viktor Szakats
e244d50064
configure: do not echo most inherited LDFLAGS to config files
`libcurl.pc` `Libs.private` (since 8.11.0, and in `Libs` before 7.20.0)
and `curl-config` `--static-libs` (since 7.17.1, and in `Libs` between
7.7.2-7.25.0). This included all flags inherited from the environment,
in addition to those coming from dependency detections.

To avoid spilling all linker flags inherited from the environment to
the libcurl config files, this patch omits them all, except `-L`, `-F`,
`--library-path=` and `-framework` options, which are still passed.
The rationale for the exceptions is that `LIBS` is passed as-is, and
`LDFLAGS`, `LIBS` are the canonical way to pass custom libs options
to a build. `LIBS` may not work without a matching custom libpath.

This brings autotools behaviour closer to cmake, and `curl-config`
closer to `libcurl.pc`.

Follow-up to 9f56bb608e #14681
Follow-up to 4c8adc8fee
Reported-by: Peter Marko
Fixes #15533
Closes #15550
2024-11-14 09:55:45 +01:00
Dan Fandrich
e3aa2a07f9 tests: use the standard format of an IGNORED line
This is more consistent and allows Test Clutch to parse it properly.
Also, add --test-duphandle and --test-event to the runtests.pl help
text.
2024-11-12 22:23:57 -08:00
Daniel Stenberg
cbafcec50b
curl: --test-duphandle in debug builds runs "duphandled"
Using this option (only available in debug builds) makes curl always
call curl_easy_duphandle() on the handle before using it.

To help us catch curl_easy_duphandle() mistakes better.

Add a CI job using this.

Bonus: the previous runtests option -e is now also supported as
--test-event

Closes #15504
2024-11-08 13:22:47 +01:00
Daniel Stenberg
f5c616930b
duphandle: also init netrc
The netrc init was only done in the Curl_open, meaning that a duplicated
handle would not get inited properly.

Added test 2309 to verify. It does netrc auth with a duplicated handle.

Regression from 3b43a05e00

Reported-by: tranzystorekk on github
Fixes #15496
Closes #15503
2024-11-07 09:47:53 +01:00
Daniel Stenberg
9919149aef
cookie: treat cookie name case sensitively
Extend test 31 to verify

Reported-by: delogicsreal on github
Fixes #15492
Closes #15493
2024-11-06 13:09:20 +01:00
Stefan Eissing
3a35901a11
wolfssl: coexist with openssl, further work
Build wolfSSL master with

./configure --prefix=/path --enable-ip-alt-name --enable-quic
--enable-earlydata --enable-psk --enable-opensslcoexist

and configure curl with openssl + wolfssl. Normal tests run.

pytest session resumption fails, as wolfssl does not handle the
new_session callback without opensslextra right now.

Closes #15481
2024-11-04 14:48:30 +01:00
Viktor Szakats
25025419c9
pytest: include curl version string and python platform in log
For the Test Clutch matrix.

https://testclutch.curl.se/static/reports/feature-matrix.html

Assisted-by: Dan Fandrich
Closes #15470
2024-11-02 01:56:55 +01:00
Viktor Szakats
9d32724c12
certs: add missing -CAcreateserial option for LibreSSL
Also:
- display openssl path and version.
- quote a string.

Follow-up to 9b0c0d6ade #15129

Closes #15471
2024-11-01 15:36:48 +01:00
Dan Fandrich
d88db0b6b2 tests: use a set for several of the curl_props
These are used for member-of testing, so a set is more appropriate and
efficient. Also, fix a couple cases of bad exceptions.

Closes #15462
2024-10-31 20:14:44 -07:00
Viktor Szakats
329a8e9daa
unit1307: tidy up Apple OS detection
Use `__APPLE__` macro to detect Apple OS instead of relying on
the string in `CURL_OS`.

This also fixes detection with default CMake builds where `CURL_OS` is
`Darwin`. The code before this patch was expecting this substring in
lowercase.

Closes #15461
2024-10-31 09:09:01 +01:00
Viktor Szakats
fb711b5098
build: fix clang-cl builds, add CI job
- appveyor: add build-only job for clang-cl.

- cmake: `-pedantic-errors` enables `-Werror,-Wlanguage-extension-token`
  automatically, which makes `__int64` detection fail.
  Explictly disable this compiler warning for clang-cl to make the
  feature detection work and to accept `__int64` in the source code.

- cmake: disable `-Wlanguage-extension-token` warning for clang-cl
  to fix these when encountering `__int64`:
  ```
  lib/formdata.c(797,29): error : extension used [-Werror,-Wlanguage-extension-token]
  lib/warnless.c(117,33): error : extension used [-Werror,-Wlanguage-extension-token]
  lib/warnless.c(60,28): message : expanded from macro 'CURL_MASK_SCOFFT'
  lib/warnless.c(59,38): message : expanded from macro 'CURL_MASK_UCOFFT'
  include\curl/system.h(352,40): message : expanded from macro 'CURL_TYPEOF_CURL_OFF_T'
  ```

- make `__GNUC__` warning suppressions apply to `__clang__` too.
  Necessary for clang-cl, which defines the latter, but not the former.
  (Regular clang defines both.)

- examples: fix clang-cl compiler warning in `http2-upload.c`.
  ```
  docs\examples\http2-upload.c(56,5): error : no previous prototype for function 'my_gettimeofday' [-Werror,-Wmissing-prototypes]
  docs\examples\http2-upload.c(56,1): message : declare 'static' if the function is not intended to be used outside of this translation unit
  ```

- unit2604: add missing `#pragma GCC diagnostic pop`.
  Follow-up to e53523fef0 #14859

- unit1652: limit compiler warning suppression to GCC.
  They do not affect clang builds.
  Follow-up to 71cf0d1fca #14772

Closes #15449
2024-10-30 23:15:32 +01:00
Daniel Stenberg
0cececef0f
config: rename the OS define to CURL_OS to reduce collision risk
Reported-by: Jon Rumsey
Fixes #15455
Closes #15457
2024-10-30 14:59:54 +01:00
Viktor Szakats
bc6212004a
pytest: show curl features and protocols
For the Test Clutch matrix.

https://testclutch.curl.se/static/reports/feature-matrix.html

Closes #15452
2024-10-30 09:32:29 +01:00
Stefan Eissing
0d475da1c4
pytest: fix run against multissl curl
Changes to make a curl built with OpenSSL + GnuTLS to run successfully
in our pytests. Run

CURL_SSL_BACKEND=openssl pytest

to test a TLS backend other than the default.

Closes #15443
2024-10-29 11:13:56 +01:00
Viktor Szakats
74c7b672d9
runtests: add comment for handle64 pathsep requirement [ci skip]
Cherry-picked from #14949
2024-10-29 09:27:42 +01:00
Viktor Szakats
ef7399b8b5
runtests: pass single backslashes with Windows Perl
handle/handle64 requires a literal match with the filenames it's
listing.

Also:
- make handle64 log messages more unique to help text searches.
- update a comment with Windows Perl info.

Cherry-picked from #14949
Closes #15436
2024-10-29 09:20:37 +01:00
Stefan Eissing
701813b23f
tests/http: add --insecure tests
Add two test cases that connection using a hostname the server has no
certificate for. First, verify that the peer verification fail, as
expected. Second, provide '--insecure' to test that the connection
succeeded and returned some data.

Closes #15429
2024-10-28 13:04:28 +01:00
Stefan Eissing
0e0c8cdf89
tests/scorecard: allow remote server test
New args for scorecard.py:
* --remote ip:port to run tests against a remote server
* --start-only: to only start the servers, listing their ports

Start the server using "scorecard.py --start-only" on one machine and
then run the tests with "scorecard.py --remote ip:port" against that
machine.

Closes #15415
2024-10-28 11:41:19 +01:00
Viktor Szakats
f66af623cf
cmake: document -D and env build options
Extend `INSTALL-CMAKE` document with the list of available options,
a short description and default values.

The list may not be 100% complete.

There are no component boundaries in CMake, so the line is blurry
between curl options, CMake options, CMake Find modules options.
I included certain CMake options that seemed useful, and/or have
dedicated use withing curl's CMake source. But, all CMake built-in
options are usable, as documented upstream in CMake.

The naming of the options has a heritage and the inconsistencies with
it, including a lack of clear namespace. This may be subject to future
updates, also after figuring out which name has special meaning within
CMake and/or CMake projects out of unwritten convention or something
more tangible.

CMake allows to initialize any internal variable via `-D`. This may be
useful to pre-initialize/override feature check results. The list
doesn't contain these, and they remain officially undocumented.

Also:
- make adjustments to keep the spellchecker happy.
- retrofit description changes to the cmake sources.
- stop documenting deprecated `Find*` variables.

Reported-by: Daniel Stenberg
Fixes https://github.com/curl/curl/discussions/14885
Closes #15388
2024-10-24 23:06:40 +02:00
Stefan Eissing
8cb2d5f48a
quic: use the session cache with wolfSSL as well
Use session cache for QUIC when built with quictls or wolfSSL.

Add test_017_10 for verifying QUIC TLS session reuse when built with
quictls, gnutls or wolfssl.

Closes #15358
2024-10-24 14:55:23 +02:00
Stefan Eissing
358eae42a4
bearssl: improved session handling, test exceptions
Add length to session saves, making it clear that we are storing a byte
blob and allowing memcmp() on sameness check.

Remove some pytest skips for bearssl to see if they now work properly in
CI.

Closes #15395
2024-10-24 14:40:01 +02:00
Stefan Eissing
30f66c8ba4
mbedtls: handle session as blobs
Use mbedtls_ssl_session_load() and mbedtls_ssl_session_save() to convert
TLS sessions to byte blobs for the session cache.

Fix a skip message to better indicate why the test is skipped for
mbedtls.

Closes #15398
2024-10-24 14:37:59 +02:00
ArtSin
0325e1b9b2
mprintf: treat %o as unsigned, add tests for %o, %x, %X
`%x` and `%X` were already treated as unsigned, but `%o` was not, even
though it was used with unsigned numbers.

Closes #15348
2024-10-24 10:17:24 +02:00
Viktor Szakats
53fdc5faf3
runtests: use deterministic sort for TESTINFO lines
Sort TESTINFO lines by description within the number of skipped test.
It makes the list of skipped test groups easier to diff/compare between
jobs and runs.

Closes #15374
2024-10-23 10:42:30 +02:00
Daniel Stenberg
0e18bd3940
mk-lib1521: fix the long return code check
It worked mostly by accident since it checked the variable from the
previous setopt invoke.

Closes #15372
2024-10-23 00:41:05 +02:00
Yedaya Katsman
acd134cfe1 tests: Fix FILEFORMAT <file name=""> directive
Follow-up to dcc52095

Closes #15371
2024-10-22 13:41:02 -07:00
Viktor Szakats
b6219cd932
GHA/linux: merge torture jobs into the main workflow
They complete in 4 and 7 minutes, and do not hold back the main Linux
workflow.

Also:
- bump default parallelism for `test-torture` target to `-j20`
  (was: `-j2`).
- drop redundant package install from `rustls` jobs.

Closes #15360
2024-10-22 20:20:42 +02:00
Viktor Szakats
9126eb5a8a
cmake: replace CURL_*_DIR with {PROJECT,CMAKE_CURRENT}_*_DIR
It reduces the number of synonym variables in the code.
Makes it easier to grok and grep.

- replace `CURL_SOURCE_DIR`
  with `PROJECT_SOURCE_DIR`.

- replace `CURL_BINARY_DIR`
  with `PROJECT_BINARY_DIR` or `CMAKE_CURRENT_BINARY_DIR`.

- replace a single use of `CMAKE_BINARY_DIR`
  with `PROJECT_BINARY_DIR`.

- replace `CMAKE_CURRENT_*_DIR`
  with `PROJECT_*_DIR` where it makes the code more uniform.

- quote an argument (formatting).

Closes #15331
2024-10-22 19:13:08 +02:00
Stefan Eissing
943df95ae7
CI: run with standard mod_http2
We used to include a special mod_h2 in our CI that supports the
directive H2MaxDataFrameLen for test_02_20. Since then, ubuntu-lastest
includes a more recent apache httpd. Let's see if we can live without
the special.

Closes #15353
2024-10-22 15:31:46 +02:00
Daniel Stenberg
5ea61a0b54
hsts: support "implied LWS" properly around max-age
Adjust test 780 to verify.

Reported-by: newfunction
Closes #15330
2024-10-18 11:42:42 +02:00
Stefan Eissing
fe2a72029e
http2: auto reset stream on server eos
When a server signals EOS from its side and the curl upload is
unfinished and the server has not given a positive HTTP status response,
auto RST the stream to signal that the upload is incomplete and that the
whole transfer can be stopped.

Fixes the case where the server responds with 413 on an upload but does
not RST the stream from its side, as httpd and others do.

Reported-by: jkamp-aws on github
Fixes #15316
Closes #15325
2024-10-17 23:03:41 +02:00
Daniel Stenberg
2ae8d9b579
libtests: generate the lib1521 atomically
By renaming from a temporary file name to the .c once completed. This
avoids the risk that the checksrc job tries to verify the file before it
is complete, in parallel build setups.

Reported-by: Dan Frandrich
Fixes #15258
Closes #15327
2024-10-17 23:00:24 +02:00
Stefan Eissing
b42eb27c1f
openssl: improve retries on shutdown
Once SSL_shutdown() has been called, OpenSSL does not really seem to
like it when it is called again and the other side has some finally data
to deliver.

Instead SSL_read() needs to be used solely, once the close notify has
been sent from curl's side.

Closes #15321
2024-10-17 16:11:06 +02:00
Daniel Stenberg
193f1b4841
DISABLED: disable test 1060 with hyper
... as it has started to fail and nobody wants to debug this.

Closes #15319
2024-10-17 13:26:00 +02:00
Stefan Eissing
c97cd82821
tests/http: fix ubuntu GnuTLS CI failures
Override the system default config in test_17_09, since we want to check
all TLS versions. Provide own, empty config file to gnutls, so that any
system wide file has no effect.

The latest ubunu image in GH CI disables TLS 1.0 and 1.1
system wide for GnuTLS. Good intentions.

Closes #15310
2024-10-17 13:25:15 +02:00
Daniel Stenberg
beeeb85a78
tests: update some HTTP/2 over HTTPS tests
- improve descriptions
- require http/2, not h2c, since they are done over HTTPS

Closes #15317
2024-10-17 12:55:05 +02:00
Dan Fandrich
41c980bb0d tests: capture stdin to get the vsftpd version number
vsftpd 3.0 at least writes its version number to stdin (!) instead of
stderr. This works due for backwards compatibility reasons in UNIX, so
we must check stdin for anything written there to reliably parse the
version string.

Closes #15278
2024-10-16 09:21:40 -07:00
Viktor Szakats
3040971d12
GHA: silence proselint warnings and an error
Fix new issues found by `proselint`.

Also:
- silence this technical warning:
  ```
  :0: DeprecationWarning: /home/runner/.proselintrc was found instead of a JSON file. Rename to /home/runner/.proselintrc.json.
  ```
- fix an input filename.
  `proselints` fails now if an input file is missing.

Reported-by: Jay Satiro
Bug: https://github.com/curl/curl/pull/15291#issuecomment-2410505100
Closes #15293
2024-10-15 16:44:17 +02:00
Daniel Stenberg
8403e5a701
tests: fix callback signatures to please UndefinedBehaviorSanitizer
Make test applications use the correct prototypes for callbacks.

Closes #15289
2024-10-15 14:33:47 +02:00
Daniel Stenberg
ad1c49bc0e
lib: remove function pointer typecasts for hmac/sha256/md5
Make sure we use functions with the correct prototype.

Closes #15289
2024-10-15 14:32:39 +02:00
Daniel Stenberg
e33cf006e9
server/mqttd: fix two memory leaks
Closes #15290
2024-10-14 12:47:21 +02:00
Daniel Stenberg
9bee39bfed
url: use same credentials on redirect
Previously it could lose the username and only use the password.

Added test 998 and 999 to verify.

Reported-by: Tobias Bora
Fixes #15262
Closes #15282
2024-10-13 23:18:42 +02:00
Daniel Stenberg
eb77297ccc
lib: move curl_path.[ch] into vssh/
As this contains code only used by SSH backends.

Closes #15284
2024-10-13 23:16:18 +02:00
Stefan Eissing
3455d360ce
mbedTLS: fix handling of TLSv1.3 sessions
For TLSv1.3, if supported, observer special return code to retrieve
newly arrived session from mbedTLS.

Adjust test expectations now that TLSv1.3 session resumption works in
mbedTLS >= 3.6.0.

Based on #14135 by @ad-chaos
Closes #15245
2024-10-13 23:13:04 +02:00
Stefan Eissing
513904c264
wolfSSL: fix handling of TLSv1.3 sessions
Register a callback to get notified of new SSL sessions by wolfSSL.
Remove the explicit session retrieval after handshake, since this does
not work for TLSv1.3.

Adjust test expectations now that TLSv1.3 session resumption works
in wolfSSL.

Closes #15243
2024-10-13 23:11:39 +02:00
Viktor Szakats
75dfb7b649
pytest: include buildinfo.txt in the output
If present.

It aims to provide TextClutch the same build information that
`runtests.pl` already is providing.

Ref: https://testclutch.curl.se/static/reports/feature-matrix.html
Ref: #15256
Follow-up to 1fdea16846 #14802
Closes #15279
2024-10-13 11:34:26 +02:00
Dan Fandrich
a3601cf571 tests: allow pytests to run in out-of-tree builds
Some of the files it needs are in the build directory but the code did
not make a distinction.

Closes #15257
2024-10-12 10:47:57 -07:00
Stefan Eissing
fe8399f066
gnutls: use session cache for QUIC
Add session reuse for QUIC transfers using GnuTLS. This does not include
support for TLS early data, yet.

Fix check of early data support in common GnuTLS init code to not access
the filter context, as the struct varies between TCP and QUIC
connections.

Closes #15265
2024-10-11 23:37:47 +02:00