Commit graph

16519 commits

Author SHA1 Message Date
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
Daniel Stenberg
4bc34a5416
doh: fix #ifdef name
Spotted by Copilot

Closes #21431
2026-04-24 08:56:35 +02:00
Daniel Stenberg
5c756684ba
hostip: init the curl_jmpenv_lock appropriately
A zero-initialized static value is not guaranteed to be a valid mutex on
all POSIX implementations

Spotted by Codex Security

Closes #21432
2026-04-24 08:30:33 +02:00
Daniel Stenberg
eea9ce45a4
urldata.h: fix typo and lingering backtick
Spotted by Copilot

Closes #21430
2026-04-24 08:18:57 +02:00
Daniel Stenberg
961a13e366
rustls: fix memory leak on repeated SSLKEYLOGFILE fails
Before this fix, Curl_tls_keylog_open() assigned the environment
variable result to a global keylog_file_name without freeing any prior
allocation. If the file cannot be opened (e.g., permission error)
keylog_file_fp stays NULL, so subsequent calls to Curl_tls_keylog_open
will overwrite keylog_file_name and leak the previous allocation.

Spotted by Codex Security

Closes #21427
2026-04-23 22:58:39 +02:00
Stefan Eissing
69f3a36bcb
doh: remove conn->bits.doh
Since we have a new struct instance for each async operation now and
async operation may happen in parallel, remove the connection bit
indicating doh is in progress.

Closes #21422
2026-04-23 17:23:54 +02:00
Stefan Eissing
00cac453c7
multi: enhance pending handles fairness
When trying to connect a pending transfer, remember the `mid` that was
last reactivated and start looking for future pending handles from the
last one forward through the pending bitset.

Background: when many pending handles exist, iterating the bitset always
from the start may become unfair to transfers that were assigned higher
`mid` values.

Fixes #21396
Reported-by: Juan Belón
Closes #21412
2026-04-23 15:55:07 +02:00
Viktor Szakats
d6372e60e5
vtls: fix comment typos and tidy up a type
Pointed out by GitHub Code Quality

Closes #21421
2026-04-23 12:31:11 +02:00
Yedaya Katsman
7100e8d45a
vtls: log when key logging is enabled.
If built with LibreSSL, also warn that it only works for TLS <= 1.2

Inspired-by: Viktor Szakats
Closes #19814
2026-04-23 08:13:59 +02:00
Daniel Stenberg
4c078fd115
urlapi: simplify urlget_url
- unify the query and fragment separator logic
- read the bitflags directly instead of via a temp variable
- narrow the scope of a few variables

Closes #21417
2026-04-23 07:40:56 +02:00
Viktor Szakats
bfc0cb42fb
asyn-thrdd: drop redundant result check
Pointed out by GitHub Code Quality

Closes #21415
2026-04-22 18:24:25 +02:00
Daniel Stenberg
0f2b020c03
asyn-thrdd: minor without-IPv6 fixes
Pointed out by Copilot

Closes #21413
2026-04-22 15:30:33 +02:00
Stefan Eissing
ad1fcd6111
async-ares: fix query counter handling
When starting an c-ares query, the provided callback may be invoked
right away, leading to a decrement of `queries_ongoing`. Increment
the counter *before* call c-ares. Otherwise, the `async->done` bit
is not properly set.

Closes #21399
2026-04-21 15:58:06 +02:00
Daniel Stenberg
4f7e323b29
mprintf: OR the flags
As 'flags' may already have been set to something when
parse_conversion() is called, make sure to only OR the new flags.

Follow-up to 4e0bfd8cf7

Closes #21398
2026-04-21 15:21:10 +02:00
Viktor Szakats
8eb3cb75a3
misc: fix code quality findings
- httpsrr: drop redundant checks.
  Follow-up to 809dda3a37 #21354
- httpsrr.h: drop obsolete comment.
  Follow-up to 2b3dfb4ad4 #21175
- ws: drop redundant check in `curl_ws_start_frame()`.
  Follow-up to 37cecfc7b9 #17683
- ws: fix typo in comment.
- tool_operate: fix VMS build. (broken since 2019-07-20, v7.66.0)
  Follow-up to b889408500 #3804

Pointed out by Copilot Code Quality

Closes #21393
2026-04-21 14:35:55 +02:00
Daniel Stenberg
2e3607034d
parsedate: refactor
- introduce 'struct when' to hold the parser result
- initwhen() initializes a 'struct when'
- datestring() parses strings
- datenum() parses numbers
- datecheck() does some final checks
- tzadjust() adds the time zone offset
- convert math to 64 bit, squeeze into time_t only in the last step,
  mktimet() does the time_t storing

Closes #21394
2026-04-21 14:22:07 +02:00
Viktor Szakats
5ff7f77310
wolfssl: fix -Wmissing-prototypes
Seen with unity, H3, wolfssl with `HAVE_EX_DATA`.

Fixing:
```
lib/vtls/wolfssl.c:412:10: error: no previous prototype for function 'Curl_wssl_cache_session' [-Wmissing-prototypes]
  412 | CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf,
      |          ^
lib/vtls/wolfssl.c:412:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
  412 | CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf,
      | ^
      | static
1 error generated.
```

Follow-up to cc5c1553fb #19852

Closes #21392
2026-04-21 10:09:58 +02:00
Daniel Stenberg
4e0bfd8cf7
mprintf: simplify parsefmt
- split out parse_flags() and parse_conversion() to reduce complexity
  from 57 to 30.

Closes #21391
2026-04-21 08:33:28 +02:00
Daniel Stenberg
0838297ad1
lib: minor comment typos
Closes #21388
2026-04-20 23:48:37 +02:00
Stefan Eissing
809dda3a37
Happy Eyeballs: add resolution time delay
HEv3 describes conditions on when first connect attempts shall be
started.
https://www.ietf.org/archive/id/draft-ietf-happy-happyeyeballs-v3-01.html
Chapter 4.2

libcurl now waits 50ms for AAAA and HTTPS results (when requested) to
return before continuing with the connect.

Added HTTPS-RR to the "was resolved" information info message. Changed
logging of HTTPS-RR to a one-liner with RFC 9460 like formatting. This
way the user can see if/what was resolved and used in connecting.

Closes #21354
2026-04-20 23:47:49 +02:00
Viktor Szakats
70a159527c
build: link bcrypt.lib via vcxproj files
And drop pragma from `rand.c`.

Closes #21386
2026-04-20 16:29:25 +02:00
Daniel Stenberg
db13c08c58
lib: fix typos in comments
Closes #21385
2026-04-20 14:56:31 +02:00