Commit graph

16464 commits

Author SHA1 Message Date
Stefan Eissing
70281e39be
haproxy: use correct ip version on client supplied address
When a user supplies an IP address to use for the HAPROXY protocol,
the IP version reported must be deduced from the address and has
no relation to the IP version used for the upstream connection.

Add test3220 to verify.

Fixes #21340
Reported-by: Fiona Klute
Closes #21341
2026-04-17 10:01:49 +02:00
Viktor Szakats
021a87cf81
vtls_scache: rename CURLcode variable to result
Closes #21346
2026-04-16 22:57:17 +02:00
Stefan Eissing
a973377cd7
dnsd: implement HTTPS-RR with alpn pref and no-default-alpn
Support HTTPS records in dnsd that have ALPN preferences.

Add pytest test_22_* to verify that HTTPS record ALPN
preferencces take effect if the HTTPS resolve arrives in time.

Fix HTTPS eyeballing use of timeouts for second attempt. Also,
make an initial HTTP/1.1 attempt switch off HTTP/2.

Closes #21329
2026-04-16 22:53:20 +02:00
Stefan Eissing
1bf1f8ed6a
pytest_05_09: increase reliability
Test has been flaky due to not waiting for the test server to be
listening. On slow CI systems, the started thread is late and the curl
command gets a refused connection.

Closes #21337
2026-04-16 22:52:13 +02:00
Daniel Stenberg
885b553545
lib: rename more CURLcode variables to 'result'
Closes #21348
2026-04-16 22:50:52 +02:00
Daniel Stenberg
b4024bf808
http: clear credentials better on redirect
Verify with test 2506: netrc with redirect using proxy

Updated test 998 which was wrong.

Reported-by: Muhamad Arga Reksapati

Closes #21345
2026-04-16 21:51:41 +02:00
Stefan Eissing
32a513e180
urlapi: same origin tests
Add new internal `curl_url_same_origin()` to check if a href has the
same origin as a base URL. Add test cases in test1675 and use this in
http2 push handling.

Closes #21328
2026-04-16 15:00:43 +02:00
Viktor Szakats
ce7174555d
build: adjust/add casts to fix -Wformat-signedness
Also adjust a mask in `mqttd.c`.

Follow-up to 548c16a824 #21335
Cherry-picked from #20848

Closes #21339
2026-04-16 11:38:14 +02:00
Daniel Stenberg
7e450cb80a
libssh2: allocate libssh2-friendly memory in kbd_callback
The function libssh2_userauth_keyboard_interactive_ex() calls the
callback and is documented to call free() on the memory returned to
libssh2 from the callback. libcurl can therefore not use the regular
curlx_strdup() for this, as that is not compatible in debug builds or
when curl_global_init_mem() is used.

Fixes #21336
Closes #21338
2026-04-16 10:35:32 +02:00
Viktor Szakats
548c16a824
build: fix -Wformat-signedness by adjusting printf masks
- sync printf masks with the passed value.
- fix a couple of casts.

Cherry-picked from #20848

Closes #21335
2026-04-16 10:32:50 +02:00
Daniel Stenberg
7fd35f4c34
unittests: cleanups
- make sure all UNITTEST prototypes mark in which unit test they are used,
  with "@unittest" markup

- make sure all UNITTEST functions do not use Curl_ prefix, as that is a
  prefix we use for global private functions and these functions are static
  and therefore not global and the prefix is wrong

- drop UNITTEST for functions not used in unit tests

- make the extract-unit-protos script highlight the above issues if found

- extract-unit-protos now also outputs the unit test number for all the
  generated protos in lib/unitprotos.h to aid readers. It also adds the source
  file and line number where the proto originates from.

- extract-unit-protos now exits with a non-zero value if any of the above
  warnings are triggered

- cf-dns: Curl_cf_dns_result => static cf_dns_result
- hostip: Curl_ipv6works => static ipv6works
- url: remove Curl_setup_conn() - not used anymore
- connect: Curl_timeleft_now_ms => UNITTEST timeleft_now_ms

Closes #21330
2026-04-15 23:32:38 +02:00
Daniel Stenberg
fa057ea3de
transfer: clear the old autoreferer
Verify in test 2505

Closes #21322
2026-04-15 10:15:25 +02:00
Daniel Stenberg
c60d90cd65
urlapi: make parse_file() return zero data on error
This fixes the torture failures in 1675

Also, make it allocate the scheme *after* the path has been verified, so
that it is avoided in the common error cases.

Fixes #21326
Closes #21324
2026-04-15 10:14:09 +02:00
Daniel Stenberg
3a19987a87
urldata: move cookiehost to struct SingleRequest
To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Verify with libtest 2504: a custom Host *disabled* on reused handle

Closes #21312
2026-04-14 16:59:11 +02:00
Stefan Eissing
86f1e5b3f6
test dnsd: implement delayed responses
Add "Delay-A: ms", "Delay-AAAA: ms" and "Delay-HTTPS: ms" to the test
dnsd config and implement delayed response handling.

Add test_21_09 and test_21_10 to check that delayed responses connect
using the undelayed address family.

Closes #21299
2026-04-14 16:49:07 +02:00
Stefan Eissing
bcd94e2750
socks: use dns filter for resolving
Use a dns connection filter to resolve hostnames where their addresses
are locally resolved and forwarded to the SOCKS proxy.

This makes all improvements, like in #21295 for example, also apply
to socks connections. Curl_resolv() is now only called from a DNS
filter.

(ftp still calls Curl_resolv_blocking() in two places, one of which
 may be replaceable with a DNS filter as well to remove the block, tbd)

Closes #21297
2026-04-14 16:48:20 +02:00
Daniel Stenberg
188c2f166a
http: clear the proxy credentials as well on port or scheme change
Add tests 2009-2011 to verify switching between proxies with credentials
when the switch is driven by a redirect

Reported-by: Dwij Mehta

Closes #21304
2026-04-14 16:14:51 +02:00
Daniel Stenberg
9ceb3ff46a
urlapi: stop extracting hostname from file:// URLs on Windows
There is no reason we should treat this part different on Windows. Noe
anything except blank, localhost or 127.0.0.1 cause error there as well.

Also: fix query handling in urlencode_str

Closes #21296
2026-04-14 12:09:48 +02:00
Daniel Stenberg
0b4ebebb06
test1675: unit tests for URL API helper functions
- ipv4_normalize
- urlencode_str
- ipv6_parse
- parse_file

urlapi: make the string URL encoder normalize to uppercase
percent-encoding

Closes #21296
2026-04-14 12:09:38 +02:00
Daniel Stenberg
99ead4e0f0
request: cleanup the auth headers on soft rest as well
To avoid the risk them lingering around.

Follow-up to 3512b673dd

Closes #21311
2026-04-14 11:24:21 +02:00
Daniel Stenberg
def4d8986e
http: use header_has_value() instead of duplicate code
Closes #21302
2026-04-14 10:16:43 +02:00
Viktor Szakats
df6014894b
clang-tidy: enable more checks, fix fallouts
- enable three checks:
  - bugprone-invalid-enum-default-initialization
  - bugprone-sizeof-expression
  - readability-inconsistent-declaration-parameter-name (strict)
- fix remaining discrepancies with arg names in prototypes
  and implementation, in strict mode.
- document reason for some checks tested but not enabled.

Closes #20794
2026-04-14 02:20:16 +02:00
Viktor Szakats
e0dd6eb4a4
tidy-up: miscellaneous
- examples: sync debug output printf masks.
- INSTALL-CMAKE.md: tidy up section for some options.
- curl_sha512_256: delete comment suggesting an optimization.
- vtls/keylog: scope a variable.
- vtls/openssl: make a source code URL a permalink.
- vtls/schannel: drop redundant parentheses.
- test1119.pl: robustify `$1` -> `$s`.
- sync arg names in comments to match the code.
- tidy up and minor fixes to comments.
- fix formatting/indenting/comment/newline/include nits.
- move `UNITTEST` protos next to definitions, sync their argument names.
- make variables static.
- add parentheses to Perl `open()` calls.
- drop unnecessary double quotes in Perl.
- clang-format.

Closes #21000
2026-04-14 01:08:32 +02:00
Daniel Stenberg
3512b673dd
lib: move request specific allocations to the request struct
To make it clearer that they are ephemeral.

Closes #21301
2026-04-13 23:23:34 +02:00
Daniel Stenberg
7a349b5eed
setopt: fix typos in comments
Closes #21303
2026-04-13 23:12:05 +02:00
Stefan Eissing
40d57c9f58
hostip: resolve user supplied ip addresses
When a user supplied an ip address in a URL as hostname, use that even
when address family restrictions like -4 or -6 are set.

Add test_10_15/16 to verify with a local proxy server.

Fixes #21146
Reported-by: Terrance Wong

How:
- cf-dns: on see the hostname is an ip(v6) address, add the respective
  A/AAAA to the dns query bits
- cf-dns/hostip: only hand out addrinfos for a family if that family
  is part of the DNS queries. That prevents for example ipv6 addresses
  to show up from dns cache entries
- change cf-ip-happy to no longer check for "ip_version" and instead
  use all addresses that cf-dns hands out

Closes #21295
2026-04-13 19:52:30 +02:00
Daniel Stenberg
ec445fc595
setopt: move CURLOPT_CURLU
To fix cast from 'char *' to 'CURLU *' (aka 'struct Curl_URL *')
increases required alignment from 1 to 8

Follow-up to 3407bee8c8

Closes #21298
2026-04-13 14:34:16 +02:00
Jay Satiro
70bb0db767 schannel: increase renegotiation timeout to 60 seconds
Prior to this change the timeout was 7 seconds but that is too short for
enhanced-security users that have to fill out an interactive prompt on
Schannel renegotiation (PIN, smart card, etc).

Reported-by: Tim Omta

Fixes https://github.com/curl/curl/issues/21270
Closes https://github.com/curl/curl/pull/21291
2026-04-13 02:12:16 -04:00
Stefan Eissing
afdd8f1290
http: fix auth_used and auth_avail
Fix http auth to set the `picked` auth when sending the corresponding
headers. Fix reporting Digest as avail.

Fixes #21274
Reported-by: sergio-nsk on github
Closes #21284
2026-04-11 17:33:03 +02:00
Daniel Stenberg
3e40ccb875
getinfo: repair CURLINFO_TLS_SESSION
This should return a SSL_CTX pointer but it was accidentally broken.

Verify with test 1587

Follow-up to 2db8ae480f

Spotted by Codex Security

Closes #21290
2026-04-11 16:56:22 +02:00
kpcyrd
ce05754c7c
rustls: handle EOF during initial handshake
Closes #21242
2026-04-10 15:58:31 +02:00
Viktor Szakats
6e40c3ed48
vquic: fix variable name in fallback code
Could not cause an issue in practice.

Closes #21281
2026-04-10 12:10:23 +02:00
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
ef49d42a2c
cfilters: CF_TYPE_SETUP connection filter
Connection filters can now carry the flag CF_TYPE_SETUP, indicating that
they are only needed during connection setup, e.g. connect.

Once the connection is fully established, those filter are removed
again. This frees resources and also makes the filter (call) chains
shorter.

Closes #21269
2026-04-09 14:10:28 +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
Stefan Eissing
d99df64405
h3: HTTPS-RR use in HTTP/3
When HTTPS-RR is needed for the HTTP/3 handshake, delay the connect
until it arrives. Relevant only for TLS backends that support ECH, for
now.

Closes #21253
2026-04-09 09:30:52 +02:00
Stefan Eissing
567803db79
dns: https-eyeballing async
Make cf-https-connect work async correctly:
- only start first baller when at least one A/AAAA address
  is available
- select first connect attempt after that with HTTPS-RR info
  there or not.
- select second connect attempt only when HTTPS-RR is resolved
  (may have resolved to "not known") and select possible ALPN
  from things known by then. May not select any second attempt
  when first already covers everything.

This means when the HTTPS-RR is known at/before the first address
is resolved, everything behaves as before. When the HTTPS-RR is
late, a first connection attempt will have been started. Any
ALPN preference from the HTTPS-RR that is not already ongoing will
then start the second attempt.

For HTTPS-RRs that recommend 2 or more ALPNs, the first will always
be attempted: either it is already ongong or it will be the ALPN
for the second attempt. The 2nd ALPN recommendation from HTTPS-RR
*may* be honored or not, depending on what is already selected.

The difference in behaviour between early/late HTTPS-RR resolve
cannot be helped - unless we do not perform any attempts before
it arrives. Trade offs.

Closes #21267
2026-04-08 23:15:39 +02:00
Daniel Stenberg
698eee1b95
vtls_scache: include cert_blob independently of verifypeer
The making of the TLS session cache key should use the cert blob
independently of verifypeer on/off.

Follow-up to fa0ccd9f1f

Spotted by Codex Security

Closes #21222
2026-04-08 15:18:45 +02:00
Daniel Stenberg
283db12e05
parsedate: bsearch the time zones
There are 69 entries, bsearch is faster than linear search for random
access.

This now also makes the matching case sensitive (zone names always in
uppercase). No docs said otherwise and all tests assumed uppercase.

Extended test 517

Closes #21266
2026-04-08 12:00:59 +02:00
Daniel Stenberg
59c8de7897
mbedtls: fix ECJPAKE matching
It did not require a full-length match, so empty or prefix tokens map to
ECJPAKE would silently add that cipher to the configured list.

Follow-up to fba9afebba

Reported by Codex Security

Closes #21264
2026-04-08 11:27:31 +02:00
Viktor Szakats
b2a767dbce
gtls: fail for large files in load_file()
Used for issuer certs. Limit the size at `CURL_MAX_INPUT_LENGTH`, 8MB.

Bug: https://github.com/curl/curl/pull/21256#discussion_r3045854654

Closes #21257
2026-04-07 20:04:44 +02:00
Viktor Szakats
d3dc5dbc87
clang-tidy: avoid assigments in if expressions
Also enable check in clang-tidy.

Cherry-picked from #20794

Closes #21256
2026-04-07 16:57:46 +02:00
Daniel Stenberg
3536730f33
parsedate: clarify time2epoch and add more variations to test 517
Polish the time2epoch function to become a little more readable.

Corrected the military time zones: they were going in the wrong
direction.

Add more curl_getdate() input varations to test 517

Closes #21251
2026-04-07 16:32:22 +02:00
Stefan Eissing
db9b6fa82e
cf-ip-happy: limit concurrent attempts
Introduce a limit on the concurrent connect attempts of 6:

- document this in CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS
- close the oldest attempt before opening a new one that would
  exceed the limit
- closing failed attempts early to avoid sockets use beyong their
  usefulness
- add tests for limits in unit2600

These changes are externally visible as file descriptors will be
reassigned where we previously kept the old one around and started a
new socket, allocating always a new descriptor.

Closes #21252
2026-04-07 16:26:25 +02:00
Daniel Stenberg
b168fc79ff
libssh: split myssh_statemach_act into sub functions and rename
Follow-up to bd3b2a626a

- rename it to myssh_statemachine

- remove the use of ternary operators in the switch

- fix the error handling for if 'sshp' actually ever is NULL

Closes #21250
2026-04-07 15:59:04 +02:00
Daniel Stenberg
a20989b82c
libssh2: split ssh_statemachine into more sub functions
The pieces of the state machine that were not separate functions before, now
are.

Also removed the use of ternary operators in the function calls.

Follow-up to f0bf43e209

Closes #21249
2026-04-07 14:50:42 +02:00
Daniel Stenberg
74a169575d
protocol: disable connection reuse for SMB(S)
Connections should only be reused when using the same "share" (and
perhaps some additional conditions), but instead of fixing this flaw,
this change completely disables connection reuse for SMB. This protocol
is about to get dropped soon anyway.

Reported-by: Osama Hamad
Closes #21238
2026-04-07 13:23:01 +02:00
Viktor Szakats
a0d5d8fea3
curl_ntlm_core: use wolfCrypt DES API with wolfSSL
Replacing the last uses of the OpenSSL compatibility API, and dropping
the redefinition of external symbols.

Closes #21247
2026-04-07 11:58:30 +02:00
Viktor Szakats
f974a00aba
lib: replace PRI*32 printf masks with C89 ones
Also: fix indent.

Follow-up to 13c1a93414 #20215

Closes #21234
2026-04-07 11:58:30 +02:00
Daniel Stenberg
be92f0a2e4
lib: reserve 'result' for CURLcode, even more
Closes #21245
2026-04-07 07:48:58 +02:00