Commit graph

16259 commits

Author SHA1 Message Date
Viktor Szakats
435eabeac8
badwords: rework exceptions, fix many of them
Also:
- support per-directory and per-upper-directory whitelist entries.
- convert badlist input grep tweak into the above format.
  (except for 'And' which had just a few hits.)
- fix many code exceptions, but do not enforce.
  (there also remain about 350 'will' uses in lib)
- fix badwords in example code, drop exceptions.
- badwords-all: convert to Perl.
  To make it usable from CMake.
- FAQ: reword to not use 'will'. Drop exception.

Closes #20886
2026-03-12 01:01:16 +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
Stefan Eissing
5fc7d50cec
vtls: ECH definitions cleanup
- Move ECH related defines to vtls.h
- Prefix all defines with `CURLECH_`
- Move base64.h include from vtls.h to implementations

Closes #20887
2026-03-11 23:45:29 +01:00
Stefan Eissing
f14ce01369
pingpong: cleanup timeleft handling
- Move `RESP_TIMEOUT` from urldata.h to pingpong.h as
  `PINGPONG_TIMEOUT_MS`.
- Rename `Curl_pp_state_timeout()` to `Curl_pp_state_timeleft_ms()` as
  the function returns the time left, not the timout..
- Update implementation comments and variable names

Closes #20888
2026-03-11 23:30:05 +01:00
Stefan Eissing
da7bfb89a1
connection_check, simplified
The protocol handler method `connection_check` allowed to variable
operations to trigger with variable result bits. Only the `CONNCHECK_ISDEAD`
and `CONNRESULT_DEAD` were in use. Transform the function into
`connection_is_dead` without extra parameter and a bool result.

- Remove defines for `CONNCHECK_*` and `CONNRESULT_*`
- Rename protocol function in handler comments
- Change RTSP implementation (only protocol that uses this)

Closes #20890
2026-03-11 23:28:50 +01:00
Vladimír Marek
015f1c7de4
hostip: clear the sockaddr_in6 structure before use
On Solaris this was causing intermittent issues when the private
structure member __sin6_src_id had unexpectedly some value. connect(2)
would then fail with EADDRNOTAVAIL.

Closes #20885
2026-03-11 11:33:13 +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
248dd9e55f
x509asn1: make encodeOID stop on too long input
Plus a minor fixup.

Reported-by: John Rodriguez

Closes #20871
2026-03-09 22:06:45 +01:00
Viktor Szakats
716dc8ce6c
rand: drop scan-build silencer
scan-build has been dropped in favor of clang-tidy and this false
positive no longer triggers with it.

Follow-up to ce4db9c2ef #20751
Follow-up to 02f207a76b

Closes #20860
2026-03-09 11:35:19 +01:00
Viktor Szakats
05189f5549
rand: drop impossible preprocessor branches (wincrypt)
After targeting Vista as minimum, the non-bcrypt fallback code was
impossible to reach, because on UWP wincrypt is never available.

After this patch it's more obvious that no-SSL UWP builds only support
weak random source.

Follow-up to b17ef873ae #18009

Closes #20859
2026-03-09 11:35:19 +01:00
Viktor Szakats
6a09f2ef1d
config-win32.h: merge two #if branches
Closes #20856
2026-03-09 11:35:19 +01:00
Viktor Szakats
6a6826469d
windows: determine RtlVerifyVersionInfo address on global init
Instead of the first internal call to `curlx_verify_windows_version()`.

To avoid the chance of a race, potentially resulting in initializing
this address twice. AFAICT it could not cause an issue before this
patch.

Reported by Codex Security

Follow-up to b17ef873ae #18009

Closes #20853
2026-03-09 11:35:19 +01:00
Viktor Szakats
ccba492024
tidy-up: miscellaneous
Closes #20851
2026-03-09 11:35:19 +01:00
huanghuihui0904
cbb5544c45
digest: fix memory leak in auth_create_digest_http_message()
Signed-off-by: huanghuihui0904 <625173@qq.com>

Closes #20862
2026-03-09 09:24:01 +01:00
Stefan Eissing
e090be9f73
smb: free the path in the request struct properly
Closes #20854
2026-03-08 22:43:03 +01:00
Viktor Szakats
64d4f5c4b6
system_win32: replace manual init code with curlx_now_init() call
The code actual init code remains identical after this patch. To make it
clearer where this initialization is called from, and to dedupe code.

Follow-up to b17ef873ae #18009

Closes #20852
2026-03-08 18:17:11 +01:00
dbalsom
9a674ee6f7
docs: replace instances of the vague qualifier 'quite'
in documentation and comments

Closes #20841
2026-03-07 23:52:50 +01:00
Daniel Stenberg
13f48dfb52
docs: avoid starting sentences with However,
An unnecessary filling word

Closes #20834
2026-03-07 23:49:11 +01:00
Daniel Stenberg
6b552e60a9
quiche: use PRIu64 for outputting the stream id
The 'id' struct field in 'struct h3_stream_ctx' is a uint64_t type so
should be output with PRIu64 - and it makes sense to be consistent.

Note that the field with the same name in the ngtcp2 version of this
struct is a *signed* 64-bit variable.

Reported by Codex Security

Closes #20849
2026-03-07 23:47:56 +01:00
Daniel Stenberg
08d6497005
cf-socket: ignore SOCK_CLOEXEC etc for socktype equality checks
As the SOCK_CLOEXEC and SOCK_NONBLOCK get ORed to the socktype, this
introduces the cf_socktype() function to use when checking for the
specific socket type: DGRAM or STREAM. The function filters off the
non-type related bits to enable the comparison.

Follow-up to 05367694ec

Closes #20808
2026-03-07 13:36:00 +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
1495489c41
docs: drop basically
Another filler word

Closes #20835
2026-03-07 10:58:36 +01:00
Stefan Eissing
704e7a85f3
mqtt: fix EOF handling
In mqtt_recv_atleast(), recognize an EOF as error.

Fixes #20815
Reported-by: Max Dymond
Closes #20830
2026-03-06 22:53:54 +01:00
Stefan Eissing
5f13a7645e
proxy-auth: additional tests
Also eliminate the special handling for socks proxy match.

Closes #20837
2026-03-06 22:52:39 +01:00
Daniel Stenberg
e47b6e657a
socketpair: clear 'err' when retrying due to EINTR
If the first write was interrupted by a signal and a subsequent write
succeeds, the function would still erroneously return EINTR.

Found by Codex Security
Closes #20809
2026-03-06 22:50:29 +01:00
Daniel Stenberg
27c3e0839a
content_encoding: return 'identity' if none other exists
This fixes a regression and accidental changed behavior shipped in
8.18.0 (via 6b9c75e219).

When the setopt is set to "" and curl is built without support for a
single compression algorithm, it used to use "identity" but recently did
not.

Spotted by Codex Security
Closes #20805
2026-03-06 22:48:16 +01:00
Stefan Eissing
3c007d6351
openssl+ech: workaround for insecure handshakes
OpenSSL 4.0.0-dev supports ECH with one flaw. If peer verification
is not enabled, it will report SSL_ECH_STATUS_BAD_NAME on the ECH
status.

Provide a workaround in libcurl that checks the inner name used in
ECH was the peer's hostname, both verify peer and host are disabled
and then accept the BAD_NAME without failing the connect.

Fixes #20655
Reported-by: Dexter Gerig
Closes #20821
2026-03-06 22:42:40 +01:00
Stefan Eissing
b803dc9f20
async-ares: blocking resolve timeout handling, better
Perform the actual timeout calculation in the blocking resolv
loop each time in the same way, keeping the logic simpler.

The previous version calculated the timeout once, and then
reduced it by the elapsed time spent in polling/processing.
This is unnecessarily complicated.

Closes #20819
2026-03-06 22:41:56 +01:00
Stefan Eissing
bfb79de206
urldata: byebye conn->hostname_resolve
The strdup() of the hostname to resolve is unnecessary as the sync
resolve code does not keep the string and the async code makes copies
already.

Remove the member from `connectdata`.

Closes #20833
2026-03-06 22:40:29 +01:00
Max Dymond
70ec11358c socks: ensure DNS is freed in failure cases.
In several error cases in socks.c the DNS struct is not freed, which
leads to memory leaks.

Found by: OSS-Fuzz: 447858136

Closes #20813
2026-03-04 17:33:06 +00:00
Daniel Stenberg
ad58e07b54
curl.h: remove CURLPROTO_MQTTS from the public header
- the value collided with the internal one used for WebSocket
- we add all new ones as internal bits
- bump to 64-bit internal type
- introduce new define for setting all protocols (CURLPROTO_64ALL)

Reported by Codex Security

Closes #20798
2026-03-03 23:14:34 +01:00
Daniel Stenberg
7577ed7e86
schannel: fix UAF in client cert store thumbprint handling
Follow-up to 10bb489b22

Found by Codex Security
Closes #20801
2026-03-03 22:14:26 +01:00
Daniel Stenberg
d9c2c64337
openssl: adapt to OpenSSL master adding const to more APIs
Closes #20797
2026-03-03 17:42:34 +01:00
Daniel Stenberg
3d708e239b
urlapi: use U_CURLU_URLDECODE when toggling it off unsigned
In this use case 'unsigned value &= ~DEFINE;

As otherwise the right side is treated as signed, which annoyingly
triggers UBSan. The U_* defines are local versions of the public define,
only typecast to unsigned.

Reported-by: xmoezzz on github
Fixes #20753
Closes #20769
2026-03-03 16:02:50 +01:00
Daniel Stenberg
b4dba346cd
stop using the word 'just'
Everywhere. In documentation and code comments.

It is almost never a good word and almost always a filler that should be
avoided.

Closes #20793
2026-03-03 15:30:22 +01:00
Daniel Díaz
3aa63896ae
mbedtls: guard TLS 1.3 + session tickets usage inside ifdef
If TLS 1.3 is not supported, the call to
`mbedtls_ssl_conf_tls13_enable_signal_new_session_tickets()` fails
during compilation:
```
curl-8.18.0/lib/vtls/mbedtls.c: In function 'mbed_connect_step1':
curl-8.18.0/lib/vtls/mbedtls.c:809:3: error: implicit declaration of function 'mbedtls_ssl_conf_tls13_enable_signal_new_session_tickets' [-Werror=implicit-function-declaration]
   mbedtls_ssl_conf_tls13_enable_signal_new_session_tickets(&backend->config,
   ^
curl-8.18.0/lib/vtls/mbedtls.c:809:3: warning: nested extern declaration of 'mbedtls_ssl_conf_tls13_enable_signal_new_session_tickets' [-Wnested-externs]
```

Protect this call inside the `#ifdef` block by making sure that support
for TLS 1.3 is defined.

Closes #20789
2026-03-03 00:28:35 +01:00
Viktor Szakats
d557c06b52
build: drop unused snprintf() feature check on Windows
Follow-up to 64f28b8f88 #20765

Closes #20790
2026-03-02 22:40:29 +01:00
Viktor Szakats
30ec220a68
mprintf: silence clang-tidy readability-suspicious-call-argument
Follow-up to 64f28b8f88 #20765

Closes #20791
2026-03-02 22:21:21 +01:00
Viktor Szakats
64f28b8f88
curlx: add local snprintf() helper that always nul-terminates (Windows)
Make the helper use `vsnprintf()` internally on all supported Windows
toolchains (dropping `_snprintf()` and `snprintf()`), ensure to
nul-terminate. Omit the return value to avoid complexity.

Use the helper from `mprintf.c` / `out_double()`, from tests/server code
and the tests/server-specific build of `curlx_inet_ntop()`,
`curlx_strerror()` functions. In the single call (in tests) where the
returned length was used previously, determine it with `strlen()`.

Refs:
https://github.com/libssh2/libssh2/blob/libssh2-1.11.1/src/misc.c#L57-L79
https://learn.microsoft.com/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l
https://learn.microsoft.com/cpp/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l

Assisted-by: Jay Satiro
Follow-up to fa8bd1cc09 #20761
Follow-up to 8ab468c8aa #15997

Closes #20765
2026-03-02 21:30:36 +01:00
Viktor Szakats
b83ade783d
multi: fix unreachable code compiler warning
```
lib/multi.c:305:5: error: code will never be executed [clang-diagnostic-unreachable-code]
  305 |     goto error;
      |     ^~~~~~~~~~
```

Cherry-picked from #20774

Closes #20788
2026-03-02 16:01:21 +01:00
Viktor Szakats
a5c6a4067a
clang-tidy: fix readability-suspicious-call-argument
Also:
- curlx/strerr: avoid a false positive by dropping an interim variable.
- enable this check.

Ref: #20627 (initial attempt)

Closes #20777
2026-03-02 15:28:25 +01:00
Viktor Szakats
7a77884a66
clang-tidy: enable clang-analyzer-* checks explicitly, fix fallout
v22.1.0 disabled them by default.

Fix fallout:
- http: check NULL to silence false positives in `HD_VAL()`.

Ref: https://releases.llvm.org/22.1.0/tools/clang/tools/extra/docs/ReleaseNotes.html#improvements-to-clang-tidy

Follow-up to da6fbb12a6 #20779
Follow-up to ce4db9c2ef #20751

Closes #20778
2026-03-02 14:01:09 +01:00
Viktor Szakats
da6fbb12a6
http1: fix potential NULL dereference in Curl_h1_req_parse_read()
Reported by clang-tidy v22 with `clang-analyzer-*` explicitly enabled:

```
lib/http1.c:89:31: error: Subtraction of a non-null pointer
 (from variable 'line_end') and a null pointer (via field 'line')
 results in undefined behavior [clang-analyzer-core.NullPointerArithm]
   89 |   parser->line_len = line_end - parser->line + 1;
      |                               ^
```
Ref: https://github.com/curl/curl/actions/runs/22534731241/job/65279952830?pr=20778#step:11:85

Ref: #20778

Closes #20779
2026-03-02 13:45:14 +01:00
Viktor Szakats
35bbb2e830
clang-tidy: fix issues found with build-fuzzing
- curl_sha512_256: add missing, drop redundant, parentheses.
- doh: drop redundant returns.
- url: add missing parentheses.
- vtls: fix unused const variables.
- tests/unit: fix missing header with clang-tidy and !threaded-resolver.
  Follow-up to 57ff2d6c91 #20106

Closes #20774
2026-03-01 00:04:18 +01:00
Viktor Szakats
bcc8144b89
clang-tidy: silence more minor issues found by v22
Also one found manually in lib/curl_sha512_256.c.

Follow-up to 7a08c5d820 #20762

Closes #20770
2026-02-28 13:16:54 +01:00
Florian Imdahl
006f561f6e
docs: some nitpicks
- replaced double spaces with single space where applicable
- replaced "favourite" with "favorite"
- added language identifiers to code blocks in markdown files
- added extra line after code blocks and after headings in markdown
  files

Cloes #20748
2026-02-27 23:05:37 +01:00
Viktor Szakats
7a08c5d820
ldap: silence clang-tidy v22 warning
Closes #20762
2026-02-27 15:57:48 +01:00
Viktor Szakats
fa8bd1cc09
mprintf: use _snprintf() when compiled with VS2013 and older
To support floats and doubles when using these old compilers.

Before this patch, these tests most likely failed with them:
```
FAIL 557: 'curl_mprintf() testing' printf, unittest
FAIL 566: 'HTTP GET with CURLINFO_CONTENT_LENGTH_DOWNLOAD and 0 bytes transfer' HTTP, HTTP GET
FAIL 599: 'HTTP GET with progress callback and redirects changing content sizes' HTTP, HTTP POST, chunked Transfer-Encoding
FAIL 1148: 'progress-bar' HTTP, progressbar
```

Also:
- mention `_snprintf()` in the `_CRT_SECURE_NO_WARNINGS` comment.

Follow-up to 7de35515d9 #20218

Closes #20761
2026-02-27 15:57:48 +01:00
Daniel Stenberg
61bcd1105a
cfilter: move a debug-only check into ifdef DEBUGBUILD
Pointed out by CodeSonar

Closes #20756
2026-02-27 08:21:15 +01:00