Commit Graph

3208 Commits

Author SHA1 Message Date
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
Daniel Stenberg
11c14b5ca5
urlapi: verify the last letter of a scheme when set explictly
A logic error made the function not check the last character, which thus
could make it accept invalid schemes.

Added test 1965 to verify

Reported-by: Otis Cui Lei

Closes #20893
2026-03-11 23:48:53 +01:00
Daniel Stenberg
53a3b2114a
libssh2: fix error handling on quote errors
Previously it lacked the actual return. libssh.c uses the same function
name.

Verified by test 2007.

Reported-by: m777m0 on hackerone

Follow-up to 578706adde

Closes #20883
2026-03-11 09:44:21 +01:00
Felipe Mesquita
f25124338c
badwords: avoid 'simply'
It's mostly a filler word. I've read through each use of it in the code
base and did minor rephrasings when "simply" carried some meaning. The
overwhelming majority of cases, removing it improved the text
significantly. Inspired by #20793.

Closes #20822
2026-03-10 19:34:06 +01:00
Daniel Stenberg
1f8cfa049d
test1850: verify the SMB request path use for two transfers 2026-03-08 22:43:03 +01:00
Daniel Stenberg
b351fd1b9a
test1849: reuse a proxy with different credentials
Closes #20842
2026-03-07 13:59:30 +01:00
Daniel Stenberg
e3d7401a32
http: only send bearer if auth is allowed
Verify with test 2006

Closes #20843
2026-03-07 11:00:16 +01:00
Daniel Stenberg
933c34e873
tool_operate: reset the URL --url-query between --next
Pointed out by Codex Security

Verify in test 1624
Closes #20802
2026-03-06 22:46:37 +01:00
Daniel Stenberg
d680789069
test1637: verify --fail and --retry with 502 response code
It should exit with 22 after the second retry.

Ref: #20771
Cloes #20780
2026-03-01 22:43:21 +01:00
Daniel Stenberg
8e3a2a64d1
tool: improve config error messaging
- make sure that errors for specific options in config files identify
  the file, line number and shows the error about the correct option

- improve some error message wording

- add warning for leading single quote of arguments in config files
  (verified in test 1712)

- adjust test error outputs accordingly

test1712 introduces mode=warn

Use the mode="warn" attribute if the output curl warning output, as it
then makes the check without newlines and the prefix to better handle
that the lines may wrap at different points depending on the lengths of
the lines and terminal width.

Fixes #20598
Closes #20666
2026-02-22 14:56:07 +01:00
Daniel Stenberg
950c7bb174
digest: escape double quotes and backslashes in realm and nonce
change test 907 to use quote in realm to verify

Fixes #20482
Reported-by: cooldadpresident on github
Closes #20545
2026-02-09 08:50:32 +01:00
Daniel Stenberg
afe9fdd1eb
tests: convert base64 data to %b64[]
To make it easier to read, understand and edit tests - and grep them.

Closes #20547
2026-02-09 08:42:49 +01:00
jhauga
161be30854
curl: add -I and -i to -h important
Closes #20483
2026-02-05 17:20:29 +01:00
Daniel Stenberg
94349aa932
mqtt: verify Remaining Length for CONNACK and PUBACK
Verified in test 1132

Closes #20513
2026-02-04 15:43:13 +01:00
Christian Schmitz
e788d9d2c7
imap: fix custom listing
Add test 1847 and 1848.

Fixes #20356
Closes #20360
2026-01-28 11:37:26 +01:00
Viktor Szakats
2f8c9812b1
tool: rename curl handle and result variable in --libcurl-generated code
To match documentation, examples and curl source code:
- `hnd` -> `curl`
- `ret` -> `result`

Closes #20437
2026-01-26 13:21:46 +01:00
Daniel Stenberg
fa6a46473e
tool_cb_hdr: with -J, use the redirect name as a backup
The -J / --remote-header-name logic now records the file name part used
in the redirects so that it can use the last one as a name if no
Content-Disposition header arrives.

Add tests to verify:

1641: -J with a redirect and extract the CD contents in the second
response

1642: -J with a redirect but no Content-Disposition, use the name from
the Location: header

1643: -J with two redirects, using the last file name and also use
queries and fragments to verify them stripped off

Closes #20430
2026-01-26 12:53:03 +01:00
Viktor Szakats
814b54d83e
tidy-up: miscellaneous
- whitespace, indent, comments, clang-format.
- openssl: move feature guards within function blocks.
- tunit: drop redundant blocks.

Closes #20361
2026-01-20 12:37:56 +01:00
Daniel Stenberg
6d6899c2f0
tool: support fractions for --limit-rate and --max-filesize
Allow 2.5k or 3.7M etc. Add mention in documentation.

Verify in test case 1623.

Closes #20266
2026-01-17 23:25:26 +01:00
Daniel Stenberg
6c31df453b
mqtt: initial support for MQTTS
Closes #19418
2026-01-17 22:43:36 +01:00
calm329
de69e67793
imap: skip literals inside quoted strings
Fixes #20320
Closes #20322
2026-01-15 22:38:15 +01:00
Viktor Szakats
ac6264366f
tidy-up: miscellaneous
- tool_bname: scope an include.
- `endif` comments.
- Markdown fixes.
- comment tidy-ups.
- whitespace, newlines, indent.

Closes #20309
2026-01-15 13:06:13 +01:00
Viktor Szakats
62ba3604dc
checksrc: do not apply BANNEDFUNC to struct member functions
Omit this warning, when `close()` is banned:
```
./lib/vtls/vtls.c:947:13: warning: use of close is banned (BANNEDFUNC)
   Curl_ssl->close(cf, data);
             ^
```
Ref: https://github.com/curl/curl/actions/runs/21012427938/job/60410334312?pr=20212#step:3:6

Ref: #20212

Closes #20323
2026-01-15 02:06:06 +01:00
Daniel Stenberg
134fb66121
digest: handle quotes in the path
- The 'uri' component needs to be escaped as well
- Rewrote the quote function to use dynbuf
- Build the digest at least partly with dynbuf
- Use goto as a general error mechanism
- Make test 64 use a double quote in the URL

Closes #20295
2026-01-14 09:57:00 +01:00
Viktor Szakats
4651d4c76b
badwords: catch and fix more variants of NN-bit
Closes #20304
2026-01-14 02:35:00 +01:00
Daniel Stenberg
f057ed05be
checksrc: warn for leading spaces before the preprocessor hash
Fix the 40+ fallouts

Closes #20282
2026-01-13 09:52:26 +01:00
Jay Satiro
3652127e81 tool_cb_hdr: suppress header output when --out-null
This change brings --out-null more in line with the documentation which
says --out-null is expected to behave like a portable -o /dev/null.

Prior to this change curl did not suppress the header output from --head
when --out-null was used to suppress output.

Assisted-by: Daniel Stenberg
Reported-by: Andrew Kvalheim

Ref: https://curl.se/docs/manpage.html#--out-null

Fixes https://github.com/curl/curl/discussions/20235
Closes https://github.com/curl/curl/pull/20256
2026-01-12 15:36:44 -05:00
Daniel Stenberg
31fbbb322e
altsvc: only accept 17 byte dates from files
Since the date format is fixed there is no need to accept more data.

Update test355 to verify reject of too long date in alt-svc file

This test case was originally supposed to verify alt-svc loading from a
file but never did because it was done incorrectly.

Now it verifies that a too long date in the input file makes curl
disregard the entry.

Closes #20259
2026-01-12 13:49:57 +01:00
Daniel Stenberg
5f612acaa1
urlapi: split parts of parseurl() into sub functions
- parse_file
- parse_scheme
- guess_scheme
- handle_fragment
- handle_query
- handle_path

Closes #20205
2026-01-07 14:31:08 +01:00