Commit graph

16540 commits

Author SHA1 Message Date
Stefan Eissing
2a2104f3cf
event: fix wakeup consumption
The events on a multi wakeup socketpair were only consumed via
curl_multi_poll()/curl_multi_wait() but not in event based processing on
a curl_multi_socket() call. That led to busy loops as reported in

Fixes #21547
Reported-by: Earnestly on github
Closes #21549
2026-05-12 08:11:31 +02:00
Viktor Szakats
01f08dc4eb
gnutls: fix more nettle 4+ compatibility issues
- disable DES with nettle 4. It no longer supports it.
  ```
  lib/curl_ntlm_core.c:67:12: fatal error: 'nettle/des.h' file not found
     67 | #  include <nettle/des.h>
        |            ^~~~~~~~~~~~~~
  ```

- fix MD4 support with nettle 4.
  ```
  lib/md4.c:178:36: error: too many arguments to function call, expected 2, have 3
    178 |   md4_digest(ctx, MD4_DIGEST_SIZE, digest);
        |   ~~~~~~~~~~                       ^~~~~~
  ```

- fix unused argument compiler warning:
  ```
  lib/vtls/gtls.c:2267:39: error: unused parameter 'sha256len' [clang-diagnostic-unused-parameter,-warnings-as-errors]
  2267 |                                size_t sha256len)
       |                                       ^
  ```
  Ref: https://github.com/curl/curl/actions/runs/25710321195/job/75488970143?pr=21557

- GHA/macos: stop enabling NTLM in the GnuTLS job.
  It no longer builds due to missing DES support in nettle 4.
  ```
  lib/curl_ntlm_core.c:90:4: error: "cannot compile NTLM support without a crypto library with DES."
     90 | #  error "cannot compile NTLM support without a crypto library with DES."
        |    ^
  ```
  Ref: https://github.com/curl/curl/actions/runs/25710321195/job/75488970170?pr=21557

Follow-up to cfadbaa133 #21169

Closes #21557
2026-05-12 05:33:08 +02:00
Xi Ruoyao
cfadbaa133
gnutls: allow building with nettle 4.0
Closes #21169
2026-05-12 03:54:24 +02:00
Viktor Szakats
e8ce697973
idn: replace header guards with forward declaration
Follow-up to bc40e09f63 #21472

Closes #21551
2026-05-11 17:01:34 +02:00
amitbidlan
e0e56e9ae4
hostip: remove unused MAX_HOSTCACHE_LEN and MAX_DNS_CACHE_SIZE
These macros are leftovers from when DNS caching was moved out of
hostip.c into its own source file. Both are still defined and used in
lib/dnscache.c; the copies in lib/hostip.c are unreferenced.

Detected with clang -Wunused-macros.

Follow-up to 96d5b5c688
Closes #21550
2026-05-11 16:19:34 +02:00
Daniel Stenberg
37b2403f48
lib: drop support for CURLAUTH_DIGEST_IE
This bit was used to do Digest authentication like Internet Explorer
before version 7 (released on October 18, 2006). Presumably no one uses
this anymore and since it is hard to use and does broken auth, starting
in 8.21.0 this bit does nothing (except setting the actual Digest bit).

Closes #21486
2026-05-11 13:43:47 +02:00
Viktor Szakats
4815070794
tidy-up: sort TLS backends, distros, alphabetically
Also:
- replace stray [Rr]ustls-ffi with Rustls for consistency.
- add AWS-LC to a couple of lists where missing.

Closes #21481
2026-05-11 11:57:25 +02:00
Daniel Stenberg
6f1dfab6a2
ftp: avoid accessing EPSV response one byte past the NULL
If the response is just a single "(".

Reported-by: Andrew Nesbit
Closes #21545
2026-05-11 08:07:24 +02:00
Daniel Stenberg
ea75ccc53b
schannel_verify: avoid out of blob access
The code would previously read one byte past the provided
CURLOPT_CAINFO_BLOB if the blob ends exactly with -----BEGIN
CERTIFICATE-----

Reported-by: Andrew Nesbit
Closes #21543
2026-05-10 23:21:08 +02:00
Daniel Stenberg
b944940828
cookie: simplify strstore(), remove outdated comment
Closes #21541
2026-05-10 00:31:25 +02:00
Daniel Stenberg
b174b8b326
ECH: cleanups
- passing an unknown string to CURLOPT_ECH now returns error

  To properly allow applications to spot if they pass in a typo or
  something to libcurl.

- CURLECH_DISABLE is now a plain zero internally, not a dedicated bit which
  simplifies checks for when ECH is enabled

- Dropped the CURLECH_CLA_CFG bit, and just check STRING_ECH_CONFIG

- Turn grease/enable/hard into three different numerical values, no bitmask
  needed

- Convert the struct field 'tls_ech' from an int to a byte.

Closes #21532
2026-05-08 13:09:45 +02:00
Daniel Stenberg
cda0268593
x509asn1: fix operator order in do_pubkey
Check the range before reading data, as it would otherwise read one byte
too many.

Reported-by: Andrew Nesbit
Closes #21533
2026-05-08 10:27:25 +02:00
Daniel Stenberg
9249aad4c2
ldap: fix minor leak on write callback error
The 'ber' pointer could remain allocated in the exit path if the write
callback returned error for one of the Curl_client_write() calls.

Reported-by: Andrew Nesbit
Closes #21530
2026-05-07 22:57:38 +02:00
Daniel Stenberg
df315692d7
ftp: simplify ftp_done
Closes #21520
2026-05-07 14:53:55 +02:00
Stefan Eissing
a86efdd7ca
url: fix connection reuse for starttls protocols
When a connection is tested for reuse in a transfer that *may* upgrade
to TLS (commonly via STARTTLS), the SSL configuration must match the
existing connection.

Reported-by: Andrew Nesbit
Closes #21522
2026-05-07 14:37:25 +02:00
Stefan Eissing
ef3b7903aa
ftp: remove bits.ftp_use_control_ssl
It's not needed since we can check the connection for SSL use.

Closes #21521
2026-05-07 14:03:48 +02:00
Stefan Eissing
fdd27a538c
auth: cleanups
- rename `req->proxyuserpwd` to `req->hd_proxy_auth`
- rename `req->userpwd` to `req->hd_auth`
- rename parameter `proxytunnel` to `is_connect` for Curl_http_output_auth()
- move path+query concatenation into Curl_http_output_auth(), saving an alloc when no auth is in play
- rename `H1_HD_USER_AUTH` into `H1_HD_AUTH`

Closes #21513
2026-05-07 14:03:00 +02:00
Stefan Eissing
71a5725563
ftp: remove 2 Curl_resolv_blocking() calls
They are no longer needed with the new peers and dns filter.
Connection setup will take care of the resoling and connecting.

Closes #21512
2026-05-07 14:02:13 +02:00
Daniel Stenberg
3e9817cd1b
url: remove ssh_config_matches
The CURLOPT_SSH_HOST_PUBLIC_KEY_* options are documented to verify the
host at connect time and not for connection reuse. Once the SSH host has
been deemed okay, it remains okay as long as the connection survives.

In addition: this function currently always returned TRUE since the
pointers have been NULLed in the SSH backend code before this function
is called.

Follow-up to c31fcf2dec

Reported-by: Andrew Nesbit
Closes #21519
2026-05-07 10:04:51 +02:00
Daniel Stenberg
a946fbb5e6
setopt: gate a few proxy TLS options by checking backend support
The same way the corresponding non-proxy options are checked.

Closes #21514
2026-05-07 07:58:26 +02:00
Daniel Stenberg
67bf021e97
mbedtls: null terminate the private key blob
Unfortunately, mbedtls_pk_parse_key() requires the data to be
null-terminated if the data is PEM encoded (even when provided the exact
length), so this function needs to make a copy that has one.

Reported-by: Elise Vance
Closes #21515
2026-05-07 07:57:56 +02:00
Stefan Eissing
455bebc2c7
peer: fix compare of hostname for uds
Unix domain socket paths need to be compared case-senstive, in contrast
to DNS hostnames.

Follow-up to bc40e09f63

Pointed out by Codex Security

Closes #21511
2026-05-06 10:14:17 +02:00
Daniel Stenberg
e0df43b9d3
protocol: introduce typedef for the do_more() function
Instead of using magic values -1, 0 and -1 using enum.

Closes #21509
2026-05-06 08:16:33 +02:00
Daniel Stenberg
2c81cf620e
multi: make multi_runsingle use sub functions for states
The state machine now calls dedicated sub functions for each state, to
reduce the size and complexity.

Closes #21506
2026-05-05 17:54:54 +02:00
Daniel Stenberg
481c9d46f1
hostip: convert Curl_resolv_unix to static resolv_unix
It was only used within this file

Closes #21508
2026-05-05 17:49:12 +02:00
Daniel Stenberg
2cb6ba672d
hsts: rename Curl_hsts() to hsts_check() and make it static
It is no longer used outside of hsts.c

Closes #21507
2026-05-05 17:46:51 +02:00
Daniel Stenberg
f97f01f592
socks_gssapi: simplify Curl_SOCKS5_gssapi_negotiate
Also: pass in NULL when 'conf_state' is not wanted for gss_wrap() and
gss_unwrap()

Closes #21502
2026-05-05 16:24:40 +02:00
Stefan Eissing
bc40e09f63
lib: introduce Curl_peer
`struct Curl_peer` keeps information about a communication endpoint
together. It will replace `conn->host` and `conn->conn_to_host` and
proxyinfo host. It will also become part of `struct ssl_peer`.

It has a reference counter, so an instance can be shared between
connections and filters.

Elminiates `conn->host` and `conn->connect_to_host`, used in the
proxyinfo structures. Passed to DNS resolution and socks filters, etc.

Pass peer to http proxy and socks tunnel filters. Use peer in dns filter
and resolving. Make `Curl_peer` a member in the `struct ssl_peer`.

Add `docs/internals/PEERS.md` for documentation.

Closes #21472
2026-05-05 16:22:11 +02:00
Daniel Stenberg
9c9a4f3eab
thrdqueue.h: minor language polish in comments 2026-05-05 14:34:27 +02:00
Daniel Stenberg
484f724a30
thrdqueue.h: forward declare curl_thrdq unconditionally
This allows the unit tests to have a prototype involving such a struct
pointer - even when the build is done without threaded resolver.

Follow-up to 117d50b4bf

Closes #21503
2026-05-05 14:17:20 +02:00
Daniel Stenberg
117d50b4bf
thrdqueue: make thrdq_await_done only for unit tests
It is not used for anything else, so drop Curl_ and make it conditional
accordingly.

Closes #21499
2026-05-05 08:55:49 +02:00
Daniel Stenberg
1ff399c3f7
gtls: fix some typos
Also make gtls_get_ietf_proto() static

Found by Copilot

Closes #21498
2026-05-05 08:46:26 +02:00
Daniel Stenberg
cb9cfee9b0
lib: two minor typos
Spotted by Copilot

Closes #21496
2026-05-04 19:53:49 +02:00
Daniel Stenberg
46e9c65c8f
socks_gssapi: tiny Curl_SOCKS5_gssapi_negotiate cleanups
- use 'result' instead of 'code' for CURLcode variable
- use aprintf() instead of malloc + snprintf

Closes #21493
2026-05-04 16:18:46 +02:00
Daniel Stenberg
f69ba0408e
mime: simplify Curl_mime_prepare_headers
Make add_content_disposition() a sub function for that single purpose.

Closes #21490
2026-05-04 11:20:22 +02:00
Daniel Stenberg
1963b2382c
gtls: simplify Curl_gtls_verifyserver
Move peer certificate verification logic into gtls_verify_cert()

Closes #21488
2026-05-04 10:35:40 +02:00
Daniel Stenberg
f59733be23
setopt: changing the proxy port is also a proxy change
Test 1589 verifies.

Closes #21485
2026-05-04 00:14:06 +02:00
Daniel Stenberg
3f9baa890e
url: simplify parseurlandfillconn
Introduce two helper functions:

- hsts_upgrade()
- setup_hostname()

Closes #21479
2026-05-01 11:53:28 +02:00
Stefan Eissing
c29278cc83
asyn-thrdd: fix result processing without wakeup socketpair
When building curl 8.20.0 with socketpair disabled, there is no
wakeup socket and the resolve results are not processed.

This fix performs result processing in the absence of a wakeup
socket before checking the resolve result.

Closes #21476
2026-05-01 11:30:51 +02:00
Viktor Szakats
91232fc2a2
tidy-up: miscellaneous
- sha256: fix backend priority in comment.
- URLs: link to IETF URLs to the HTML document, to match others.
- VERSIONS.md: use unified date format for recent entries too.
  Ref: ce5d32032f
- GHA/labeler.yml: alpha-sort file masks in a label block.
- tests/server/mqttd: fix call arg list in a disabled function.
- tests/server/mqttd: fix comment.

Closes #21473
2026-04-30 20:22:23 +02:00
Raymond Steen
2bb5c9b555
mqtt: validate PINGRESP and DISCONNECT have remaining_length == 0
Per MQTT 3.1.1 sections 3.13.1 and 3.14.1, PINGRESP and DISCONNECT fixed
headers must have remaining_length set to zero. The previous code
dispatched to mqtt->nextstate based on the queued state alone without
validating remaining_length for these no-payload packet types, allowing
a malicious broker to send a PINGRESP with non-zero remaining_length
whose trailing bytes would be interpreted as the payload of whatever
message type was queued (CONNACK, SUBACK, etc.).

The exploitation path turned out to be narrow — curl sends data to the
server the user chose to talk to — but the spec violation and the
resulting protocol-state error are real. Reject the malformed packets
with CURLE_WEIRD_SERVER_REPLY before state dispatch.

Reported-by: Raymond Steen <raymond@vortiqxconsilium.com>
Found by VORTIQ-X VXF Framework
Bug: https://hackerone.com/reports/3702718

Signed-off-by: Raymond Steen <raymond@vortiqxconsilium.com>
Closes #21465
2026-04-30 14:14:44 +02:00
Viktor Szakats
032ea65ff2
tidy-up: whitespace
Closes #21456
2026-04-27 13:34:27 +02:00
Daniel Stenberg
c1cfdf59ac
setopt: clear proxy auth properties when switching
Verify with test 1588

Closes #21453
2026-04-27 10:27:01 +02:00
Stefan Eissing
51905671e0
sectrust: fail on missing OCSP stapling
When using Apple SecTrust, requiring the server to send
an OCSP response and does not, fail correctly.

Reported-by: Carlos Carrillo
Closes #21444
2026-04-25 16:04:06 +02:00
Viktor Szakats
b5ee935f75
connect: fix typo on error message [ci skip]
Pointed out by GitHub Code Quality
2026-04-24 22:29:02 +02:00
Stefan Eissing
bfcc1c6eb4
setup connection filter: mark as setup
Add CF_TYPE_SETUP to the setup connection filter so that it is
removed and destroyed after the connection has been established.

Closes #21437
2026-04-24 17:50:44 +02:00
Stefan Eissing
4840fe3f8a
socks filter: pass operation parameters
Pass all operations parameters to a SOCKS filter at creation
time, not relying on "global" connectdata values.

Eliminate modifications to `conn->ip_version` when local resolving
for SOCKS4.

Do not retrieve the socket for GSSAPI blocking calls from connectdata,
but from the filters "below" the SOCKS one.

Closes #21436
2026-04-24 17:50:10 +02:00
Daniel Stenberg
7d295145eb
mbedtls: remove failf() call with first argument as NULL
failf() needs an easy handle to work. This change removes the call since
there is normnally nowhere to show the output if init fails.

Bonus: improve language in an infof() call

Spotted by Copilot

Closes #21441
2026-04-24 17:47:30 +02:00
Daniel Stenberg
d19a039472
mbedtls: cleanup more without care for 'initialized'
Several mbedTLS resources (entropy/CTR-DRBG, CA/client certs, keys, CRL)
are initialized and may allocate memory before initialized is set, and
must still be cleaned up.

Follow-up to 1c4813c769

Caught by Codex Security
Closes #21440
2026-04-24 17:01:01 +02:00
Stefan Eissing
b6e0ecb3f2
resolve: pass bool for proxy resolves
So that CURLcode failure is correct and not figured out later via
`conn->bits.proxy`. Add the flag to the async struct.

`for_proxy` is figured out by the caller of Curl_resolv() when it
figures out which host/proxy name it wants the addresses for.

Remove CONN_IS_PROXIED macro as no longer needed.

Closes #21423
2026-04-24 13:10:59 +02:00