Commit Graph

3236 Commits

Author SHA1 Message Date
Daniel Stenberg
e5087ac9fc
http: on 303, switch to GET
... unless it is a POST and the user explicitly asked to keep doing
POST.

Add test1983/1984: verify --follow with 303 and PUT + custom GET

Fixes #20715
Reported-by: Dan Arnfield
Closes #21280
2026-04-10 09:39:39 +02:00
Stefan Eissing
a28540787c
asyn-ares: connect async
Make separate queries for A and AAAA records. Hand out A/AAAA/HTTPS
information before all queries are complete.

Closes #21205
2026-04-09 09:32:12 +02:00
Viktor Szakats
acda4eae5e
runtests: allow configuring SSH host/client key algorithm
via env `CURL_TEST_SSH_KEYALGO`, `rsa` (default), `ecdsa`, `ed25519`.

To ease debugging and testing and to make these code paths more
universal.

Closes #21223
2026-04-05 11:19:42 +02:00
Daniel Stenberg
d2110e7fcf
docs: CURLOPT_LOGIN_OPTIONS is a login property
Test case 1982 verifies this

Closes #21215
2026-04-04 12:37:39 +02:00
Samuel Henrique
f4eddde9dc
test 766: flag as timing-dependent
We have noticed this test as failing when run in parallel in Fedora and
Amazon Linux:
389f140954

Debian did not have issues but given there are other FTP tests flagged
as timing-dependent, it makes sense to flag this one too if we notice
failures in other OSes.

Closes #21155
2026-04-03 17:07:36 +02:00
Daniel Stenberg
e65ba1bd34
hsts: make the HSTS read callback handle name dupes
Now the logic for handling name duplicates and picking the longest
expiry and strictest subdomain is the same for the callback as for when
reading from file.

Also strip trailing dots from the hostname added by the callback.

A minor side-effect is that the hostname provided by the callback can
now enable subdomains by starting the name with a dot, but we discourage
using such hostnames in documentation.

Amended test 1915 to verify.

Closes #21201
2026-04-02 18:01:20 +02:00
Daniel Stenberg
93e80c75b4
hsts: accept 10K entries in the list
Up from 1K.

Reduces the risk that someone could flush the list by tricking a user to
do many transfers to new hostnames.

Document the limit.

Follow-up to 03a792b186

Closes #21200
2026-04-02 10:22:35 +02:00
Daniel Stenberg
03a792b186
HSTS: cap the list at 1,000 entries
Avoid never-ending growth.

When adding more entries, it now deletes the first entry in the list,
which is the oldest added entry still held in memory. I decided to avoid
a Least Recently Used concept as I suspect with a list with this many
entries most entries have not been used, and we don't save the timestamp
of recent use anyway.

The net effect might (no matter what) be that the removed entry might
feel a bit "random" in the eyes of the user.

Verify with test 1674

Ref #21183
Closes #21190
2026-04-01 14:38:41 +02:00
Daniel Stenberg
0805ec043e
altsvc: cap the list at 5,000 entries
Avoid never-ending growth.

When adding more entries, it now deletes the first entry in the list,
which is the oldest added entry still held in memory. I decided to avoid
a Least Recently Used concept as I suspect with a list with this many
entries most entries have not been used, and we don't save the timestamp
of recent use anyway.

The net effect might (no matter what) be that the removed entry might
feel a bit "random" in the eyes of the user.

Verify with test 1669.

Reported-by: Geeknik Labs
Fixes #21183
Closes #21189
2026-04-01 12:05:47 +02:00
Daniel Stenberg
11609c3d45
alt-svc: skip expired entries read from file
Extend test 1654 to verify

Closes #21187
2026-04-01 10:56:11 +02:00
Daniel Stenberg
4478a10f0d
hsts: skip expired HSTS entries read from file
Extend test 780 to verify

Closes #21186
2026-04-01 10:49:26 +02:00
Daniel Stenberg
8e8bdd3604
cookie: fix rejection when tabs in value
A previous refactor changed the TAB check so that the octet could be
accepted in the 'path', which would cause an invalid line in the saved
cookie file so not possible to read the cookie back. Not terrible
because the path cannot contain a raw tab anyway so it would never match
anyway.

Add test 1685 to verify

Reported-by: Izan on hackerone

Closes #21185
2026-04-01 10:45:05 +02:00
Daniel Stenberg
8e89646a3d
tool_operhlp: iterate through all slashes to find name
If there is no trailing file name for -O or --remote-name-all, continue
searching until there is no more to search. A URL ending with multiple
slashes would previously make it do wrong.

Add test 1639 and 1644 to verify.

Follow-up to e26eefd9ce

Reported-by: James Fuller

Closes #21165
2026-03-31 07:43:47 +02:00
Daniel Stenberg
9f7295fb23
test445: fix error code, remove SMB use
The test should now expect error 7. SMB is now opt-in, so not used in as
many builds anymore.

Follow-up to a186ecf4bf

Closes #21160
2026-03-30 18:50:44 +02:00
Stefan Eissing
335dc0e3c5
cf-dns: connection filter for DNS queries
New connection filter `cf-dns` that manages DNS queries. If hands
out addresses and HTTPS-RR records to anyone interested. Used by
HTTPS and IP happy eyeballing.

Information may become available *before* the libcurl "dns entry"
is complete, e.g. all queries have been answered. The cf-ip-happy
filter uses this information to start connection attempts as soon
as the first address is available.

The multi MSTATE_RESOLVING was removed. A new connection always
goes to MSTATE_CONNECTING. The connectdata bit `dns_resolved`
indicates when DNS information is complete. This is used for
error reporting and starting the progress meter.

Removed dns entries `data->state.dns[i]`, as the `cf-dns` filter
now keeps the reference now.

Many minor tweaks for making this work and pass address information
around safely.

Closes #21027
2026-03-30 13:28:38 +02:00
Daniel Stenberg
860c57dffd
test1619: download into %LOGDIR
Otherwise it will end up in tests/ which is not wanted.

Follow-up to d63432d1f8

Reported-by: Stefan Eissing

Closes #21114
2026-03-27 09:33:54 +01:00
Daniel Stenberg
d63432d1f8
tool_cb_hdr: only truncate etags output when regular file
When sending the output to stdout it cannot truncate.

Add test1619 to verify --etag-save to stdout

Spotted by Codex Security

Closes #21103
2026-03-26 23:39:28 +01:00
Daniel Stenberg
e1fdbdd16f
hsts: when a dupe host adds subdomains, use that
Otherwise a weaker earlier entry is allowed to override a later more
restrictive one.

Add test 1638 to verify.

Closes #21108
2026-03-26 23:27:24 +01:00
Viktor Szakats
20914e3753
perl: harden external command invocations
In `adddocsref.pl`, `checksrc-all.pl`, `singleuse.pl` and tests 307, 1013,
1022, 1275, 1707, 1708, 1710.

Closes #21097
2026-03-26 14:20:07 +01:00
Stefan Eissing
a186ecf4bf
proxy: chunked response, error code
Add test1715 to check proper handling of chunked transfer
encoding in CONNECT responses. Change proxy error code from
56 (RECV_ERROR) for everything to 7 (COULDNT_CONNECT) when
the server response could be read successfully, but establishing
the connection is not possible (http status code wrong).

Adapt several test expectations from 56 to 7.

Closes #21084
2026-03-25 12:16:21 +01:00
Stefan Eissing
39036c9021
async-thrdd: use thread queue for resolving
Use a thread queue and pool for asnyc threaded DNS resolves.
Add pytest test_21_* for verification.

Add `CURLMOPT_RESOLVE_THREADS_MAX` to allow applications to
resize the thread pool used.

Add `CURLMOPT_QUICK_EXIT` to allow applications to skip thread
joins when cleaning up a multi handle. Multi handles in
`curl_easy_perform()` inherit this from `CURLOPT_QUICK_EXIT`.

Add several debug environment variables for testing.

Closes #20936
2026-03-25 12:14:21 +01:00
Stefan Eissing
6f9f4b3cb7
lib: add thread pool and queue
- new source files for thread pool and queue
- test cases 3217 and 3218 for them
- internal documentation

Closes #20916
2026-03-23 23:03:58 +01:00
Daniel Stenberg
664db28d29
test2405: require wakeup
To get the correct file descriptor count

Reported-by: Marcel Raad
Fixes #21069
Closes #21074
2026-03-23 23:01:01 +01:00
Daniel Stenberg
07d109b7c6
test1714: verify telnet download with --max-filesize
(disabled on Windows because of hangs)

Closes #21023
2026-03-23 14:32:46 +01:00
Daniel Stenberg
9820e5dfac
tool_operate: fix memory-leak on failed uploads
Add test case 1673 to do repeated upload failures and verify there is no
leak. This proved a previous leak and now it verifies the fix.

Reported-by: James Fuller
Closes #21062
2026-03-22 23:58:02 +01:00
Daniel Stenberg
77ed315096
progress: count amount of data "delivered" to application
... and apply the CURLOPT_MAXFILESIZE limit (if set) on that as well.
This effectively protects the user against "zip bombs".

Test case 1618 verifies using a 14 byte brotli payload that otherwise
explodes to 102400 zero bytes.

Closes #20787
2026-03-21 23:21:55 +01:00
Daniel Stenberg
fa13f373b2
netrc: skip malformed macdef lines
When skipping macdef lines inside netrc files, ignore it completely and
do not tokenize or bail out on bad quotes.

Verify in test 1672

Follow-up to 3b43a05e00

Spotted by Codex Security
Closes #21049
2026-03-21 23:20:49 +01:00
Daniel Stenberg
6026d76fdf
test1668: unit test the FTP 213 time response parser
Should make it harder to introduce regressions.

Closes #21051
2026-03-21 23:10:32 +01:00
Daniel Stenberg
ceae02db04
rtmp: drop support
- librtmp has no test cases, makes no proper releases and has not had a
  single commit within the last year

- librtmp parses the URL itself and requires non-compliant URLs for this

- we have no RTMP tests

- RTMP was used by 2.2% of curl users (self-identified in the 2025
  survey)

Closes #20673
2026-03-21 14:56:06 +01:00
Stefan Eissing
82009c4220
share: concurrency handling, easy updates
Replace the `volatile int dirty` with a reference counter
protected by a mutex when available.

Solve the problem of when to call application's lock function
by adding a volatile flag that indicates a share has been added
to easy handles in its lifetime. That flag ever goes from
FALSE to TRUE, so volatile might work (in the absence of a mutex).

(The problem is that the lock/unlock functions need 2-3
`curl_share_setopt()` invocations to become usable and there
is no way of telling if the third will ever happen. Calling
the lock function before the 3rd setopt may crash the
application.)

When removing a share from an easy handle (or replacing it with
another share), detach the easy connection on a share with a
connection pool.

When cleaning up a share, allow this even if it is still used in
easy handles. It will be destroyed when the reference count
drops to 0.

Closes #20870
2026-03-21 14:42:49 +01:00
Daniel Stenberg
322db3efc0
ftp: make the MDTM date parser stricter (again)
A previous refactor made the parser more lenient and this takes it back
to making sure only ascii digits are accepted.

Added test 1684 to verify

Follow-up to 304b5183fd

Pointed out by Codex Security

Closes #21041
2026-03-21 12:25:14 +01:00
Daniel Stenberg
f2ba8f0613
protcol.h: fix the CURLPROTO_MASK
It had an 'f' too few. Also provide CURLPROTO_WS* unconditionally
internally, so that code can depend on them in all builds.

Follow-up to cd5ca80f00

Spotted by Codex Security

Test case 3219 added to catch this next time.

Closes #21031
2026-03-20 17:24:01 +01:00
Daniel Stenberg
14782b36fe
x509asn1: fixed and adapted for ASN1tostr unit testing
- move defines to header file
- make bit2str require < 8 unused bits
- make bool strings stricter
- make UTime2str show + or - for custom time zones
- removed unused 'type' argument to ASN1tostr() function
- fix int2str for negative values. All values below 10000 are now shown
  in decimal properly, also possibly negative values.

Add unit test 1667 to verify ASN1tostr

Closes #21013
2026-03-20 13:03:40 +01:00
Daniel Stenberg
756725a32b
tool_operate: drop the scheme-guessing in the -G handling
Prior to this, -G would override the scheme set with --proto-default and
revert back to guessing the scheme based on the hostname.

Add test 2008 to verify the fix

Spotted by Codex Security

Closes #20992
2026-03-20 11:57:10 +01:00
Daniel Stenberg
98d8e82c74
lib: move all UNITTEST prototypes to C files
- make extract-unit-protos handle multi-line prototypes - but they need
  to be above the implementation

- Prototypes for static functions we use in unit tests should not be in
  header files. We generate lib/unitprotos.h for this purpose

- Removed some function wrappers written for unit tests and make them
  use UNITTEST function directly.

- Renamed time2str() in the tool to timebuf() since we have the same
  name in lib/ and in unit tests they can both be used non-static in a
  build.

This reverts commit f95fadd116.

Follow-up to #21010

Closes #21014
2026-03-20 07:47:57 +01:00
Daniel Stenberg
673e14cd33
x509asn1: improve encodeOID
- return error on zero length input
- return error on OOM or doing too large output
- fix full 32-bit number support
- fix the broken handling of the first and second numbers
- support up to 32-bit minus 80 for the second number
- a field with a leading 0x80 is now considered an error, since it only
  works as padding and is then no longer the shortest possible version

Add unit tests in 1666

Bonus: removed the last argument to OID2str() as it was always set TRUE.

Closes #21003
2026-03-19 13:55:34 +01:00
Ercan Ermis
c3f04e76ae
ftp: reject PWD responses containing control characters
A malicious or compromised FTP server could include control characters
(e.g. bare \r, or bytes 0x01-0x1f/0x7f) inside the quoted directory path
of its 257 PWD response. That string is stored verbatim as
ftpc->entrypath and later sent unescaped in a CWD command on connection
reuse via Curl_pp_sendf(), which performs no sanitization before
appending \r\n.

Reject the entire path if any control character is encountered during
extraction so that tainted data never reaches a subsequent FTP command.

Add test case 3217 and 3218 to verify. Adjusted test 1152 accordingly.

Closes #20949
2026-03-18 11:24:41 +01:00
Daniel Stenberg
a327a5bded
netrc: refactor into smaller sub functions
Fixes #20950 - test 685 is extended for this
Closes #20932
2026-03-17 16:51:38 +01:00
Stefan Eissing
adda11330b
transfer: enhance secure check
Introduce `Curl_xfer_is_secure(data)` that returns TRUE for transfers
that happen(ed) over a end-to-end secured connection, e.g. SSL.

Add test1586 to verify behaviour for http: transfers via a https: proxy.

Reported-by: lg_oled77c5pua on hackerone

Closes #20951
2026-03-17 15:56:02 +01:00
Daniel Stenberg
f4c0590b1c
tool_ipfs: accept IPFS gateway URL without set port number
Follow-up to: 56129718b8

Test 1851 added to verify

Pointed out by Codex Security

Closes #20957
2026-03-17 15:51:43 +01:00
Daniel Stenberg
b98981e16b
url: don't assume all transfers have hostnames
Follow-up from 412cd2577a

Add test 1659 to verify --connect-to when doing file:// transfers.

Reported-by: James Fuller
Closes #20948
2026-03-17 10:26:35 +01:00
Daniel Stenberg
3e8df37885
digest: pass in the user name quoted (as well)
For cases where the user puts a double quote or backspace in the user
name.

Adjusted test 907 to verify

Reported-by: am-perip on hackerone

Closes #20940
2026-03-16 22:43:14 +01:00
Daniel Stenberg
29cb750fc2
tool_cb_wrt: fix no-clobber error handling
When saving a file with --no-clobber, make sure the existing file name
remains set when creating the name fails. In a retry scenario, it comes
back and uses that variable again.

Add test 3036 to verify.

Reported-by: James Fuller
Closes #20939
2026-03-16 15:31:44 +01:00
Viktor Szakats
e76968e20d
curl_get_line: fix potential infinite loop when filename is a directory
Fix potential inifinite loop reading file content with `Curl_get_line()`
when a filename passed via these options are pointing to a directory
entry (on non-Windows):

- `--alt-svc` / `CURLOPT_ALTSVC`
- `-b` / `--cookie` / `CURLOPT_COOKIEFILE`
- `--hsts` / `CURLOPT_HSTS`
- `--netrc-file` / `CURLOPT_NETRC_FILE`

Fix by checking for this condition and silently skipping such filename
without attempting to read content. Add test 1713 to verify.

Mention in cookie documentation as an accepted case, also show a verbose
message when a directory is detected. Extend test 46 to verify if such
failure lets the logic continue to the next cookie file.

Reported-and-based-on-patch-by: Richard Tollerton
Fixes #20823
Closes #20826 (originally-based-on)
Follow-up to 769ccb4d42 #19140

Closes #20873
2026-03-16 11:54:43 +01:00
Stefan Eissing
412cd2577a
urldata: connection bit ipv6_ip is wrong
Eliminate `conn->bits.ipv6_ip`

The bit was only correct for the first transfer using a connection. Use
`data->state.up.hostname` instead in places that need the URL hostname
in its original form.

Fix parseurlandfillconn() to not modify `data->state.up.hostname` before
copying the connection's hostname, but modify the copy instead, leaving
the URL hostname intact.

Closes #20919
2026-03-14 23:17:40 +01:00
Daniel Stenberg
d20fa5cd39
test459: switch to mode="warn" for stderr check
In a -j192 build, this output used a three-digit number for the output,
thus wrapping differently and causing it to error.

Reported-by: Carlos Henrique Lima Melara

Closes #20910
2026-03-12 16:55:07 +01:00
Daniel Stenberg
143279faf4
test1627: Curl_get_scheme unit test
Closes #20904
2026-03-12 14:22:38 +01:00
Daniel Stenberg
9148862c26
test1626: Curl_copy_header_value unit test
Closes #20903
2026-03-12 13:59:59 +01:00
Daniel Stenberg
ed7bfcd17d
test1625: unit test for Curl_compareheader
Follow-up to 2938cb72e5

Closes #20901
2026-03-12 10:30:14 +01:00
Daniel Stenberg
2938cb72e5
http: fix Curl_compareheader for multi value headers
Follow-up to 04289c62de. Regression shipped in 8.13.0.

- a logic error made it not loop and thus only match if the searched string
  was first

- it no longer matches a substring

Adjusted test 1 to use multiple values in the Connection: response
header. Adjusted test 1542 to have a "Connection: close-not" which
should not match.

Reported-by: Henrique Pereira

Closes #20894
2026-03-12 07:52:58 +01:00