Commit Graph

2807 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
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
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
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
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
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
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
Dan Fandrich
954177b9da tool_xattr: create the user.creator xattr attribute
This indicates that the file was created by curl which can help a user
determine the origin of a file. Like the other attributes, this is only
enabled with the --xattr option.

Closes #15237
2024-10-11 10:13:37 -07:00
Daniel Stenberg
5ee43bb82e
tests: 780 - 783, new HSTS tests
test780: verify updated HSTS data in response header

test781: HSTS update expiry, with parent includeSubDomains domain
present

test782: HSTS update expiry, with two includeSubDomains domains present

test783: HSTS update expiry, removing includesubdomains in update
2024-10-09 13:48:14 +02:00
Daniel Stenberg
a94973805d
hsts: improve subdomain handling
- on load, only replace existing HSTS entries if there is a full host
  match

- on matching, prefer a full host match and secondary the longest tail
  subdomain match

Closes #15210
2024-10-09 13:48:08 +02:00
Daniel Stenberg
80dac51af8
test1915: remove wrong comment 2024-10-08 09:35:56 +02:00
Daniel Stenberg
39697dead3
tests: remove debug requirement on 38 tests
For all tests using -O that were previously relying on a debug build and
the CURL_TESTDIR environment variable, use the plain --output-dir option
instead so that they can run proper in non-debug builds.

Closes #15114
2024-10-02 08:13:55 +02:00
Daniel Stenberg
b0c82239c2
tool: support --show-headers AND --remote-header-name
By keeping the headers in memory until we know the target file name,
then output them all.

Previously this option combination would cause an error.

Add test 1310 and 1492 to verify. Adjusted test 1460 to work in the new
conditions.

Closes #15110
2024-10-02 08:04:33 +02:00
Viktor Szakats
ca9106c1e9
tests: replace %PWD with %SSH_PWD in SCP/SFTP tests
Cherry-picked from #14949
Closes #15103
2024-10-01 16:04:51 +02:00
Viktor Szakats
68c358619f
tests: replace hard-coded /dev/null with variable
- add variable for the null device filename and use that in Perl code.
- initialize this variable with `NUL` on native Windows.
- add `%DEV_NULL` variable and use it in tests.

Fixes `The system cannot find the path specified.` messages seen when
running `runtests.pl` with native Windows Perl.

Also adjust code to not break mcedit syntax highlighting.

Cherry-picked from #14949
Closes #15098
2024-10-01 12:07:19 +02:00
Viktor Szakats
31a29fc6bd
tests: add and use %PERL variable to refer to the Perl binary
To ensure Perl invocations within tests call the same Perl binary used
for running the tests, as specified or auto-detected via `PERL` env
(autotools) or `PERL_EXECUTABLE` setting (cmake). Instead of the first
`perl` executable found in `PATH`.)

Cherry-picked from #14949
Closes #15097
2024-10-01 12:04:50 +02:00
Viktor Szakats
f6cb707b6a
tests: replace %PWD with %FILE_PWD for file://
Before this patch not all tests used `%FILE_PWD` with the `file://`
protocol.

Keep `%PWD` for test1145, to keep it fail on Windows like the test
expects.

Cherry-picked from #14949

Closes #15090
2024-09-30 23:48:00 +02:00
Stefan Eissing
6f2a1666a1
tests: use '-4' where needed
Our test servers run either on ipv4 *or* on ipv6, as requested.
A test case using 'localhost' or '*.local' in the url needs to
run with the specific version of the server started.

Otherwise, curl's "happy eyeball"ing will connect to another
server that may be running due to parallel testing or for some
other reasons.

Note that port reuse here depends on the OS strategy and it
seems netbsd is especially likely to hit this.

Closes #15060
2024-09-26 23:36:09 +02:00
Stefan Eissing
e61c5eb417
tests: check http/2 and http/3 server responsiveness
Check responsiveness of http/3 server when running.

Also, a test case with http/2 or http/3 server requirement
now implicitly drags in a 'http' server and we need no longer
mention that in testdata.

Closes #15058
2024-09-26 23:34:16 +02:00
Stefan Eissing
ef400f4f38
test190: replace %FTPTIME2 with a fixed value
The variable FTPTIME2 may, on a loaded test server, become so
large that the timeout does not happen before the fixed 60 seconds
the server waits.

Closes #15056
2024-09-26 23:33:18 +02:00
Dan Fandrich
8e9a8dd978 tests: add file: tests with existing files
Windows sometimes has issues when opening the same file twice, so these
test two situations where that could potentially occur.

Reported-by: ralfjunker on github
Ref: #15043
Closes #15045
2024-09-26 10:10:36 -07:00
Daniel Stenberg
dd0405c909
test518: restore valgrind disable
Follow-up to c91c37b6e8

The test does not work well when run with valgrind

Closes #15062
2024-09-26 17:02:09 +02:00
Stefan Eissing
17a7e12e1b
test2502: add libtest debug tracing
Closes #15053
2024-09-26 16:57:13 +02:00
Stefan Eissing
21fb30b5d1
test1035: convert host name back to utf8 as should be
Follow-up to 0b70b23ef4

Closes #15050
2024-09-26 16:54:03 +02:00
Daniel Stenberg
0b70b23ef4
tests: add codeset-utf8 as a feature
To avoid having to use <precheck> for tests that require UTF-8 support.

Closes #15039
2024-09-26 08:44:59 +02:00
Daniel Stenberg
5fb1b64fdd
tests: introduce %CLIENT6IP-NB
This is the %CLIENT6IP variable - but without outmost brackets since
some commmand lines need the address without the brackets. With this
variable we can run three more tests without prechecks.

Closes #15039
2024-09-26 08:44:55 +02:00
Daniel Stenberg
7aa2b4e01f
tests: make precheck for HTTP on 127.0.0.1 into a feature
It can now be required easily in <features> instead of having perl code
in a <precheck>.

Closes #15039
2024-09-26 08:44:45 +02:00
Daniel Stenberg
56183c1d6f
tests: postcheck is now in verify
Also introduce 'notexists' for verifying that directory entries do not
exist after a test. Now an explicit supported feature instead of using
"funny" perl in postcheck.

Closes #15046
2024-09-26 08:43:24 +02:00
Gabriel Marin
b7c9166c4c
test1185: Updated test data with NOSPACEC rule
Closes #14990
2024-09-25 08:01:58 +02:00
Daniel Stenberg
b4f7ec71ce
tool_operate: let --create-dirs work for --dump-header as well
Add test 3011 to verify

Proposed-by: Montg0mery on github
Fixes #14941
Closes #14965
2024-09-22 21:27:29 +02:00
Viktor Szakats
d83b528a80
tidy-up: spelling
C89, Schannel, Secure Transport, contractions.

Cherry-picked from #14692
Closes #14996
2024-09-22 09:51:15 +02:00
Daniel Stenberg
c91c37b6e8
tests: remove all valgrind disble instructions
Closes #14983
2024-09-20 22:48:30 +02:00
Dan Fandrich
22ba044f08 tests: Fix keyword for test1411 2024-09-19 11:07:51 -07:00
Daniel Stenberg
e666a678bd
checksrc: check for spaces around '?', '>' and '<'
Closes #14921
2024-09-19 14:59:12 +02:00
Daniel Stenberg
0cfc7fcca1
tool_cb_wrt: use "curl_response" if no file name in URL
Use the same fallback for content-disposition cases as for regular -O

Add test692: verify -JO with URL without a file name

Reported-by: Brian Inglis
Fixes #14939
Closes #14940
2024-09-17 13:39:51 +02:00
Viktor Szakats
e53523fef0
CI: move Azure jobs to GHA, fix fallouts, sshserver, runtests tweaks
CI:

- GHA/windows: enable OpenSSH server, SysInternals `handle`, `impacket`.
  Skip `impacket` on MSYS2 due to install failure.
  Skip OpenSSH server for old/standalone mingw-w64 (building curl
  without SSH there.)
- GHA/windows: make test tool installs a separate step.
- GHA/cygwin: enable OpenSSH server.
  Skip `impacket`: it's compiling for 7 minutes then breaks.
  Skip `stunnel` due to sluggish test run performance.
  (This update is unrelated to Azure jobs.)
- GHA/linux: migrate Linux jobs from Azure CI.
- GHA/linux: migrate scanbuild job from Azure CI.
- GHA/linux: enable libssh2 in a job. Also enable valgrind.
- CI/windows: enable SSPI in two jobs.
- CI/windows: disable zlib in one more job.
- CI/windows: improve `if` condition checking GnuTLS.
- CI/windows: ignore SFTP/SCP tests as necessary.
  - universally ignore SCP tests, they fail everywhere.
  - ignore test 612.
  - ignore test 613 616 618 with MSYS2 mingw-w64.
  - ignore test 614 with libssh.
  - ignore all SFTP with MSYS2 native.
  - ignore all SFTP with vcpkg with `libssh2[core,zlib]`.
  - ignore a couple of SFTP tests with MSYS2 mingw-w64.
  (This matches settings on Azure CI.)
- GHA/windows: ignore failing 1451 'Basic SMB request' test for
  old mingw-w64 7.3.0 (but not for 9.5.0!):
  ```
  2024-09-11 21:45:59,738 ERROR smbComNegotiate: b'NT LM 0.12\x00' is not in list
  [...]
  curl: (7) Could not connect to server
  [...]
  FAIL 1451: 'Basic SMB request' SMB
  ```
  Ref: https://github.com/curl/curl/actions/runs/10816280746/job/30007130770#step:13:3546
- CI/Azure: delete, now moved to GHA.

sshserver:

- sshserver: fix permissions for SSH host key on Windows, allowing sshd
  to launch.
- sshserver: fix initializing config paths with Cygwin/MSYS2 sshd.
- sshserver: fix initializing config paths in parallel builds.
- sshserver: delete redundant `DenyUsers`. This also opens the way
  to allow multiple usernames.
- sshserver: fix `AllowUsers` for GHA/windows, by allowing the
  domainless username again.
  Follow-up to 3ee7c676ec #5721
- sshserver: fix `Deprecated option` warnings in `sshd_config`:
  ```
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 7: Deprecated option AuthorizedKeysFile2
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 25: Deprecated option KeyRegenerationInterval
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 35: Deprecated option RhostsRSAAuthentication
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 36: Deprecated option RSAAuthentication
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 37: Deprecated option ServerKeyBits
  D:/a/curl/curl/bld/tests/log/2/server/curl_sshd_config line 41: Deprecated option UseLogin
  ```
- sshserver: fix `Deprecated option` warnings in `ssh_config` with
  Cygwin/MSYS2.
- sshserver: fix dumping config files due to the filenames missing their
  full paths.
- sshserver: add workaround to make `logmsg` messages visible.
  Before this patch they only went to a file and never shown.

runtests:

- runtests: log details when these Windows commands are called:
  `handle`, `taskkill`, `tasklist`.
- runtests: add documentation links to Windows tools:
  `handle`, `taskkill`, `tasklist`, `icacls`.
- runtests: add `-t` (kill whole tree) option to `taskkill` in
  `servers.pm`, syncing it with the other `taskkill` call.
  Follow-up to bc72a78a11 #14488
- runtests: show warning if Sysinternals `handle` tool is missing.
- runtests: drop Windows XP Home compatibility `tskill` call.
  The call was made on all Windows versions. It's possibly overkill to
  do this, because XP Home is probably rarely used for running curl
  tests these days. In case it's needed, it'd be better to put it under
  an explicit option.
- runtests: show Perl version and path.

Fix/silence fallouts:

- unit2603: fix building with disabled HTTP support.
- unit2604: silence `-Woverlength-strings` warnings in C89 mode.
- test437, test1614: fix to pass with no-IPv6 builds.

Closes #14859
2024-09-16 10:00:17 +02:00
Daniel Stenberg
aef384a7df
http: make max-filesize check not count ignored bodies
Add test 477 to verify

Reported-by: MasterInQuestion on github
Fixes #14899
Closes #14900
2024-09-14 22:51:57 +02:00
Daniel Stenberg
7eda757d99
FTP: partly revert eeb7c12807
Since ASCII transfers on FTP means sending CRLF line endings, we should
still keep converting them to LF-only on platforms where text files
typically do not use CRLF.

This also DOES NOT convert existing CRLF line endings on ASCII uploads
but only does stand-alone LF => CRLF.

Regression from eeb7c12807 shipped in 8.10.0

Reported-by: finkjsc on github
Fixes #14873
Closes #14875
2024-09-14 17:23:04 +02:00
Stefan Eissing
e70c22b622
tests: tweak lock file handling and timers
- when server are killed by a test case, do not wait for the server lock
  file to go away. These tests are mostly about client timeouts and the
  server will hang until killed.
- when killing a server successfully, check for a remaining lock file,
  log its existence and remove it.
- lower the delay timings on SLOWDOWN by half
- add SLOWDOWNDATA server command to only slow down the FTP data bytes,
  not the control ones.
- lower some timeout values

Closes #14835
2024-09-13 09:46:25 +02:00
Viktor Szakats
805bbf7c55
NTLM_WB: delete remains in tests, docs updates
Also update more docs to reflect the removal of NTLM_WB.

Follow-up to 50def7c881 #13249
Closes #14832
2024-09-10 14:13:36 +02:00
Stefan Eissing
435dd8aa6e
doh: cleanups
Mostly cleanup on identifiers of DoH code.
Always use 'Curl_doh_cleanup()' for releasing resources.

More concise and telling names (ymmv):

* prefix all static functions with 'doh_' for unity builds
* doh_encode -> doh_req_encode
* doh_decode -> doh_resp_decode
* struct dohdata -> struct doh_probes
* probe's 'serverdoh' -> 'resp_body'
* probe's 'dohbuffer' -> 'req_body'
* probe's 'headers' -> 'req_hds'
* 'dohprobe()' -> doh_run_probe()'
* 'DOH_PROBE_SLOTS' -> 'DOH_SLOT_COUNT'
* 'DOH_PROBE_SLOT_IPADDR_V4' -> 'DOH_SLOT_IPV4'
* 'DOH_PROBE_SLOT_IPADDR_V6' -> 'DOH_SLOT_IPV6'
* 'DOH_PROBE_SLOT_HTTPS' -> 'DOH_SLOT_HTTPS_RR'

Closes #14783
2024-09-06 08:58:52 +02:00
Daniel Stenberg
0d1504b205
libcurl.def: move from / into lib
It is meant for the library, it belongs in lib/

Closes #14796
2024-09-05 17:05:40 +02:00
Aki
a2bcec0ee0
openssl: fix the data race when sharing an SSL session between threads
The SSL_Session object is mutated during connection inside openssl,
and it might not be thread-safe. Besides, according to documentation
of openssl:

```
SSL_SESSION objects keep internal link information about the session
cache list, when being inserted into one SSL_CTX object's session
cache. One SSL_SESSION object, regardless of its reference count,
must therefore only be used with one SSL_CTX object (and the SSL
objects created from this SSL_CTX object).
```
If I understand correctly, it is not safe to share it even in a
single thread.

Instead, serialize the SSL_SESSION before adding it to the cache,
and deserialize it after retrieving it from the cache, so that no
concurrent write to the same object is infeasible.

Also
 - add a ci test for thread sanitizer
 - add a test for sharing ssl sessions concurrently
 - avoid redefining memory functions when not building libcurl, but
   including the soruce in libtest
 - increase the concurrent connections limit in sws

Notice that there are fix for a global data race for openssl which
is not yet release. The fix is cherry pick for the ci test with
thread sanitizer.
d8def79838

Closes #14751
2024-09-02 23:35:44 +02:00
Stefan Eissing
4cd10ee28b
POP3: fix multi-line responses
Some POP3 commands are multi-line, e.g. have responses terminated by a
last line with '.', but some are not. Define the known command
properties and fix response handling.

Add test case for STAT.

Fixes #14677
Reported-by: ralfjunker on github
Closes #14707
2024-08-30 15:38:25 +02:00
Daniel Stenberg
23e6391c1d
managen: in man output, remove the leading space from examples
Leave that rendering decision to the display tool.

Closes #14735
2024-08-30 10:09:48 +02:00
Daniel Stenberg
c280010d8b
managen: fix superfluous leading blank line in quoted sections
When a markdown quoted section using 4-space indentation was converted
to nroff, managen previously caused a newline to appear after the
leading .nf. This fix makes sure that newline is inserted *before* .nf
as intended.

This is perhaps most notable in the HTML version of rendered manpages if
the quoted sections use different colors or similar.

Closes #14732
2024-08-30 00:21:22 +02:00
Daniel Stenberg
4becbb4af7
test1050: mark as FTP 2024-08-29 20:24:37 +02:00