Commit graph

3518 commits

Author SHA1 Message Date
Viktor Szakats
161e7f79f3
and later -> and newer 2026-06-13 00:09:05 +02:00
Viktor Szakats
c4707f2890
or greater -> higher 2026-06-13 00:09:05 +02:00
Viktor Szakats
879a1514c3
socket: introduce SOCK_EAGAIN() and use it
To contain the logic of checking for both `EWOULDBLOCK` and/or `EAGAIN`
depending on platform/availability. Also to avoid checking for both if
they mapp to the same value, and to avoid PP guards around use.

This also ensures `EAGAIN` is consistently not checked on Windows, where
headers defined it, but `SOCKERRNO` never returns it, because curl maps
it to `WSAGetLastError()`.

If they map to the same value, checking them both in an `if` expression
trips GCC warning `-Wlogical-op` (the same way it triggers duplicate
case value error in `switch`).

Also:
- replace two `switch()` statements with the new macro.
- tests/server/sws: make two outliers use the new macro that were only
  checking for `EWOULDBLOCK` before this patch, in `connect_to()`.
- move variables to the left-side of expressions, where missing.
- rustls: use a variant of this macro that uses raw `EWOULDBLOCK`.
  Tried tracing it back to the origins, but I couldn't figure out if
  this is working as expected on all supported Windows versions in
  Rust. It seems to be using `GetLastError()`, according to
  https://docs.rs/system_error/0.2.0/system_error/, which would be
  probably incorrect.

Notes:
- it's probably a good idea to assign `SOCKERRNO` to a variable before
  passing it to this macro.

Cherry-picked from #21893

Closes #21992
2026-06-12 23:27:23 +02:00
Viktor Szakats
7c51a33877
AmigaOS: fix build fallouts, re-add to CI
Fix build issues:
- src: adjust `toolx_ftruncate()`.
- libtests/cli_ftp_upload: make `struct timeval` initialization portable.
- libtests/lib1960: do unconst in local `inet_pton()` macro.
- tests/server/dnsd: make it stub instead of failing the build.
- tests/server: make them link AmiSSL for `SocketBase`.

Also:
- bump AmiSSL to the latest release.
- add download hash checks and toolchain cache.
- sync restored code with local updates made since last year.

It takes 30 seconds per job, 1 minute in total.

Thanks-to: Bebbo
Thanks-to: Darren Banfi
Ref: https://github.com/curl/curl/pull/21989#issuecomment-4691380623
Follow-up to 7a14898264 #17486

Closes #21993
2026-06-12 20:27:44 +02:00
Daniel Stenberg
ab3bb8cd8b
config2setopts: use default protocol properly
Verified by test 1724, 1725 and 2036

Closes #21983
2026-06-12 12:57:15 +02:00
Viktor Szakats
e35ba09f47
tidy-up: add spaces around equal operators where missing
Found via regex search: `=[^~>= ]`

Closes #21975
2026-06-11 19:52:01 +02:00
Viktor Szakats
97aed9c960
tidy-up: drop stray comparisons with literal zero
Drop from:
- strcmp, strcmpi, strncmp, memcmp, lstat, getrlimit, setrlimit, fseek,
  fstat
- autotools detection snippets.
- smooth-gtk-thread: simplify `!var != 0` expression.

Closes #21947
2026-06-10 15:15:54 +02:00
Viktor Szakats
2f3fa479dd
build: enable -Wformat-signedness, fix issues found
Adjust code to avoid `-Wformat-signedness` warnings, while making sure
that enums are always cast to a known type when passing them to `printf`
functions, to support compilers and compiler settings where enums are
not default-size signed ints.

- cast integers printed as hex to `unsigned`. (63 times, 20 of them in
  `mbedtls.c`)
- cast misc enums to `int` for printing. (31 times)
- cast `CURL_LOCK_DATA_*` enums to `int`. (4 times)
- cast `CURL_FORMADD_*` enums to `int`. (13 times)
- cast `CURLSHE_*` enums to `int`. (3 times)
- cast `CURLUE_*` enums to `int`. (33 times)
- cast `CURLMSG_*` enums to `int`. (6 times)
- cast `CURLE_*` enums to `int`. (~380 times)
- unit1675: fix mask.
  Follow-up to 7c34365cce #21879

Ref: #18343 (initial attempt)

Closes #20848
2026-06-10 15:14:08 +02:00
Viktor Szakats
014be82a66
tidy-up: drop redundant == NULL syntax
Where missed by checksrc.

Closes #21935
2026-06-09 14:37:36 +02:00
Viktor Szakats
59213abfb2
tidy-up: drop redundant != NULL syntax
Where missed by checksrc.

Closes #21932
2026-06-09 14:37:36 +02:00
Viktor Szakats
847aac066d
tidy-up: use uppercase TRUE/FALSE where missing
Keep it only in external API calls and C++ code.

Also:
- curlx/fopen: replace with `!!`.

Spotted by GitHub Code Quality in cf-socket.c.

Closes #21925
2026-06-09 12:52:08 +02:00
Daniel Stenberg
9b69cfb937
var: use a dedicated pointer for the alloc
As the 'c' pointer might actually get modified before it is time to free
the memory.

Verify in test 2310

Reported-by: Eunsoo Kim
Fixes #21898
Closes #21900
2026-06-08 09:37:06 +02:00
Daniel Stenberg
7bb7b2c2a4
tool: warn when --ssl and --ftp-ssl-control override each other
and mention this properly in the docs.

Closes #21887
2026-06-07 14:42:13 +02:00
Viktor Szakats
d3e9a815c4
tidy-up: miscellaneous
- fix typos.
- badword: add two new words.
- cpp: drop parentheses from standalone `#if` expressions.
- libssh: vertical-align comment block with others.
- clang-format.

Closes #21880
2026-06-05 16:57:38 +02:00
Viktor Szakats
1b8f4dba28
tidy-up: drop stray casts for allocated pointers
Closes #21865
2026-06-05 12:24:01 +02:00
Daniel Stenberg
cf7919262d
tool_parsecfg: refactor parseconfig()
- introduce helper functions
- remove #ifdef'ed debug code

Closes #21855
2026-06-03 10:40:01 +02:00
Daniel Stenberg
b825417043
tool_operhlp: avoid NULL to %s
If the filename allocation fails.

Reported-by: Gao Liyou
Ref: #21825
Closes #21836
2026-06-02 08:48:19 +02:00
Daniel Stenberg
7d2382ebfa
tool_help: rectify a bad assert
The condition was wrong, and now it also verifies 'tlen'.

Reported-by: Gao Liyou
Ref: #21825
Closes #21837
2026-06-02 08:45:48 +02:00
Viktor Szakats
d229055549
tidy-up: miscellaneous
- drop more uses of the word "just". (not enforced here)
- drop some uses of the "will" word.
- "then" -> "than".
- tests/http/testenv/curl.py: fix copy-paste typo in error message.
- pytest: replace `shutdownh` with `shutdown` in test names.
  Spotted by GitHub Code Quality.
- comment typos.
- whitespace and newlines fixes.

Closes #21830
2026-06-01 22:33:57 +02:00
Daniel Stenberg
4beffe7737
Revert "tool: add a retry delay for transfers to same origin on 429"
This reverts commit c5fb460e7c.

This needs some further work before we can do this.

Fixes #21822
Closes #21824
2026-06-01 09:28:31 +02:00
htasta
c5fb460e7c
tool: add a retry delay for transfers to same origin on 429
Closes #21355
2026-06-01 08:40:58 +02:00
Stefan Eissing
4ff212f8ed
url: connection reuse fixes for starttls
Add test_31_13 to check connection reuse on mixed --ssl-reqd setting.
For that add debug env var CURL_DBG_NO_USE_SSL_ON_FIRST to disable
--ssl-reqd for the first url. Check that the connection without SSL
from the first url is not reused on the second URL that requires it.

Tweak special ftp: protocol check to fail a DEBUGASSERT on mismatched
`use_ssl` settings as that should have been caught before in the
connection reuse matching (imap/smtp etc. do not have this extra check
and rely on the general part doing its job).

Closes #21665
2026-05-31 23:29:15 +02:00
Viktor Szakats
f1a6f190a6
badwords: prefer 'workaround' (without hyphen)
Closes #21807
2026-05-31 22:05:54 +02:00
Viktor Szakats
9591ff123d
tidy-up: add space around operators, where missing
Closes #21793
2026-05-28 10:12:00 +02:00
Viktor Szakats
7e1001bcd6
tidy-up: miscellaneous
- H3 proxy: re-sync code with original source `curl_ngtcp2.c` to reduce
  differences, and to apply missed minor fixes. Also apply clang-format.
  Drop redundant `#undef`s, casts, `#endif` comments, includes, drop
  intermediate variables, sync include and macro order.
  Follow-up to e78b1b3ecc #21153
- INSTALL-CMAKE.md: move `CURL_ENABLE_SMB` to the enable section.
- tests/http/env: rename `tcpdmp` to `tcpdump` to match object variable.
- mbedtls: drop incorrect `mbedTLS 4+` comments.
  (features are also supported by 3+, meaning it's always supported.)
- lib1648: rename a variable to match purpose.
- CIPHERS.md: alpha-sort link list.
- replace rare `X''` hex markup with `0x`.
- `IP v4/6` -> `IPv4/6`.
- 'version X.Y' -> 'vX.Y', where sensible.
- 'VX.Y' -> 'vX.Y', where sensible.
- fix indents, casing, newlines, typos.

Closes #21772
2026-05-27 16:53:57 +02:00
Aritra Basu
e78b1b3ecc
HTTP/3: add proxy CONNECT and MASQUE CONNECT-UDP support (ngtcp2 QUIC)
This patch adds two major proxy capabilities to curl (ngtcp2 QUIC):
- HTTP/3 Proxy CONNECT: Tunnel HTTP/1.1 or HTTP/2 traffic through an
  HTTPS proxy that speaks HTTP/3 (QUIC) using the standard CONNECT
  method over an HTTP/3 connection.
- MASQUE CONNECT-UDP: Tunnel HTTP/3 (QUIC) traffic through an HTTP
  proxy (speaking HTTP/1.1, HTTP/2, or HTTP/3) using the extended
  CONNECT method with the CONNECT-UDP protocol (RFC9297 & RFC9298).

Public API additions:
- `CURLPROXY_HTTPS3`: new proxy type constant for HTTP/3 proxy
- `--proxy-http3`: new CLI flag to negotiate HTTP/3 with HTTPS proxy

The implementation adds two new filters:
- `H3-PROXY` - enables negotiating HTTP/3 (QUIC) to the proxy and
  running CONNECT/CONNECT-UDP through that proxy transport.
- `CAPSULE` - dedicated filter inserted between QUIC transport and
  HTTP-PROXY to handle datagram capsule encapsulation/decapsulation.

Here is how the curl filter chaining looks in different scenarios:
- HTTP/3 Proxy CONNECT (tunneling TCP protocols over QUIC proxy):
  conn -> HTTP/1.1 or HTTP/2  -> SSL -> HTTP-PROXY ->
                                 H3-PROXY -> HAPPY-EYEBALLS -> UDP
- MASQUE CONNECT-UDP (tunneling QUIC over any proxy):
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H3-PROXY ->
                               HAPPY-EYEBALLS -> UDP
  conn -> HTTP/3 -> CAPSULE -> HTTP-PROXY -> H1-PROXY or H2-PROXY ->
                               SSL -> HAPPY-EYEBALLS -> TCP

- Both features currently require the ngtcp2 QUIC backend.
- Both features are experimental (disabled by default). Enable with
  `--enable-proxy-http3`(autotools) or `-DUSE_PROXY_HTTP3=ON`(CMake).

Tests:
- tests/unit/unit3400.c: Unit tests for capsule protocol encode/decode
- tests/http/test_60_h3_proxy.py: Comprehensive pytest integration suite
- tests/http/testenv/h2o.py: Managing h2o instances with HTTP/1.1, HTTP/2,
  and HTTP/3 (QUIC) listeners, proxy.connect and proxy.connect-udp enabled.

References:
  RFC 9297 - HTTP Datagrams and the Capsule Protocol
  RFC 9298 - Proxying UDP in HTTP
  RFC 9000 §16 — Variable-Length Integer Encoding

Signed-off-by: Aritra Basu <aritrbas+gh@cisco.com>

Closes #21153
2026-05-27 08:49:53 +02:00
Viktor Szakats
bcd0497c81
tidy-up: use curlx_safefree()
Closes #21700
2026-05-21 01:31:03 +02:00
Viktor Szakats
b3f76b21c9
tidy-up: miscellaneous
- fix typos and wording in documentation and comments.
- KNOWN_BUGS: merge duplicate H1 section.
- test_10_proxy: delete stray expressions.
- Perl: `while()` -> `while(1)`.
- Perl: fix indent, whitespace, drop redundant quotes and parentheses.
- fix casing: URL, SSL, Windows.
- badwords: readd `threadsafe`, add `well-known` (and fix it).
- replace `WinXP` -> `Windows XP` to match other uses.

Closes #21646
2026-05-20 00:50:43 +02:00
Viktor Szakats
614b94eecc
tidy-up: miscellaneous
- avoid "will" in builds scripts, scripts folder, curl_easy_ssls_export.md,
  and few other files.
- badwords: add "initialise", "nul terminated", "thread safety" and
  variations.
- prefer "null-terminat", where missing (two places).
- fix "null-terminat*" missing dash.
- hostip: merge two `#if` blocks.
- tool_doswin: fix comment
  Spotted by GitHub Code Quality
  Follow-up to 9a2663322c #17572
- fix stray spaces and newlines.

Closes #21638
2026-05-16 01:56:17 +02:00
Viktor Szakats
4780e509aa
tidy-up: prefer "initialize" with a 'z'
To match the majority of usage in source.

Closes #21618
2026-05-15 11:49:06 +02:00
Viktor Szakats
eb9b253d66
libssh: add support for SHA256 host public keys
Reported-by: Joshua Rogers
Fixes #21605

Closes #21607
2026-05-15 11:49:06 +02:00
Viktor Szakats
976eb1d50d
windows: update MS SDK versions in comments
To make them more accurate.

Also:
- show Visual Studio version, where missing.
- ease the formatting.
- schannel_int.h: clang-tidy fallback code.

Used: `rg -l --sort=path CERT_FIND_HAS_PRIVATE_KEY`

Closes #21621
2026-05-15 03:41:33 +02:00
Daniel Stenberg
b2476a0712
tool_urlglob: check glob use before access
As this function can now be invoked with only the second glob "active",
it must avoid accessing the first one if not in use.

Follow-up to 2238f0921c

Spotted by Codex Security

Closes #21586
2026-05-13 13:12:10 +02:00
Daniel Stenberg
2238f0921c
curl: named globs in output file name for upload glob references
Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:

    curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'

Verified by test 2014

Closes #21407
2026-05-13 10:07:50 +02:00
Daniel Stenberg
287b082c63
tool_urlglob: better 'Duplicate glob name' position
This now points to where the duplicate name ends, not where it starts.

Also fixes test 2410 to use a fixed hostname so that the error position
remains the same.

Reported-by: Viktor Szakats
Fixes #21567
Closes #21568
2026-05-12 23:46:04 +02:00
Daniel Stenberg
7eb0b30934
tool_urlglob: make globbing error reported for correct position
Reported by Codex Security

Closes #21561
2026-05-12 10:21:45 +02:00
Daniel Stenberg
cb0636980b
tool_urlglob: add named globs
Idea-by: Bastian Jesuiter

Verified by test 2408 - 2411

Closes #21409
2026-05-12 08:33:01 +02:00
Daniel Stenberg
3ce10063f1
tool_urlglob: avoid overflow at end of range
Due to how the range span globbing code works, a range that ends with
9223372036854775807 (the maximum signed 63 bit value) cannot be used as
it triggers an integer overflow.

Verified in test 2092

Reported-by: Andrew Nesbit
Closes #21529
2026-05-07 22:58:20 +02:00
Daniel Stenberg
98d818cf2b
tool_formparse: tool2curlparts is no longer recursive
It could otherwise trigger a stack overflow in extreme cases

Reported-by: Andrew Nesbit
Closes #21518
2026-05-07 09:10:24 +02:00
Daniel Stenberg
21687202d9
tool_formparse: polish error message + make two functions static
Closes #21510
2026-05-06 09:15:03 +02:00
Daniel Stenberg
03b547f73f
tool_formparse.c: use define instead of magic number
The longest header lines accepted for the -F option is now a define
instead of a magic number. I also bumped it to be an even 8K.

When fixing, I noticed that for some OOM errors curl would display two
error messages. Also fixed here.

Closes #21501
2026-05-05 10:11:10 +02:00
Daniel Stenberg
6f26ecb734
tool_formparse: cleanups
- explain the get_param_part() function
- make it parse only blanks like the rest of this code
- check for commas explicitly when scanning multiple files (to help code
  understanding)

Closes #21489
2026-05-04 10:57:45 +02:00
Daniel Stenberg
faa4b0692d
tool_formparse.c: fix two minor comment typos
Pointed out by Copilot

Closes #21480
2026-05-01 11:54:08 +02:00
Daniel Stenberg
ecc8bf6be2
tool_formparse: simplify get_param_part
Introduce a few sub functions to reduce complexity

Closes #21478
2026-05-01 10:26:33 +02:00
Viktor Szakats
13b6a6036c
tool_dirhie: fix to create drive-relative directory
Fix to create the top directory `foo` when specified as
`X:foo\bar\filename`, on Windows and MS-DOS. Add test to verify.

Caught by Codex Security

Follow-up to 787ee935ac #16566

Closes #21449
2026-04-27 12:09:09 +02:00
Daniel Stenberg
b16be8e244
tool_operate: reset the upload glob counter for next URL
Fixes #21402

Adjust test 2012 and 2013 accordingly

Closes #21403
2026-04-22 07:50:59 +02:00
Daniel Stenberg
dcf535629b
tool_operate: keep the filename for upload globbing
Follow-up to 19695e815c

Verify with test 2012 and 2013

Closes #21401
2026-04-21 23:11:42 +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
19695e815c
tool_operate: split create_single into smaller sub functions
Reduces complexity from 58 => 32.

Closes #21389
2026-04-21 08:35:09 +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