Commit Graph

35972 Commits

Author SHA1 Message Date
Viktor Szakats
626051cd8b
test436: fix running on Windows with _curlrc present
in the user home directory.

Before this patch, the curl tool found the system curlrc first, ignoring
the custom one set by the test via `CURL_HOME`.

Closes #18242
2025-08-10 00:33:45 +02:00
Viktor Szakats
7fd7d561c4
cmake: set CURL_DIRSUFFIX automatically in multi-config builds
To make it easier to run tests when using the Visual Studio generator,
also perhaps Xcode.

Also drop manual settings from CI.

Closes #18241
2025-08-10 00:33:45 +02:00
Viktor Szakats
c04292648f
cmake: drop redundant unity mode for curlinfo
Unity mode adds nothing besides some overhead and log noise for
targets built from a single source file.

I wish cmake disabled unity automatically in this case.

Closes #18238
2025-08-09 14:25:29 +02:00
Viktor Szakats
fe5225b5ea
cmake: optimize building examples in CI
In CI we want to ensure that examples build cleanly, but we don't want
to actually run them there. Meaning it's enough to just compile, but not
link them in CI. Saving time up to 2-4x (MSVC), and disk space up
to 1.2GB (or 8-70x).

Add a new cmake target that compiles all examples without linking them
into runnable binaries. Keep a full build for a single example to test
if it links correctly.

Also:
- CI: switch over all `curl-examples` targets to `curl-examples-build`
- GHA/linux-old: build examples in one of the cmake builds.

Result highlights:

Job                 | Bef. |  Bef. | Aft. | Aft. |
:------------------ | ---: | ----: | ---: |----: |
cygwin              |  15s |   9MB |  10s |  1MB |
msys                |  13s |   8MB |   7s |  1MB |
dl-mingw 15         |  39s |  113M |  34s |  2MB |
dl-mingw 9.5.0      |  49s | 115MB |  42s |  2MB |
dl-mingw 7.3.0      |  19s | 113MB |  14s |  2MB |
dl-mingw 6.4.0      |   9s |  12MB |   7s |  4MB |
Linux cross         |  19s |  28MB |  19s |  2MB |
MSVC UWP            |  65s | 374MB |   9s | 17MB |
MSVC x64            |  22s | 846MB |   9s | 17MB |
VS2010              |  48s | 105MB |  15s |  9MB |
VS2022 clang-cl     | 195s | 1.2GB |  51s | 20MB |
iOS Xcode           |   8s |       |   5s |      |
macOS LibreSSL      |  16s |       |  11s |      |
Linux aws-lc        |   3s |       |   1s |      |

Follow-up to dda251ef10 #18232

Closes #18209
2025-08-09 02:27:43 +02:00
Viktor Szakats
869506d2da
appveyor: show disk space used in each job
Also bump minimum dir size in GHA, to reduce details.

Follow-up to be71475b13 #18150
Closes #18235
2025-08-09 02:01:54 +02:00
Viktor Szakats
dda251ef10
cmake: define WIN32_LEAN_AND_MEAN for examples
To build faster. Also syncing with autotools.

Job                 | Before | After |
:------------------ | -----: | ----: |
dl-mingw 15         |    45s |   39s |
dl-mingw 9.5.0      |    72s |   49s |
dl-mingw 7.3.0      |    29s |   19s |
dl-mingw 6.4.0      |    20s |    9s |
Linux cross         |    30s |   19s |
MSVC UWP            |    77s |   65s |
MSVC x64            |    27s |   22s |
VS2010              |    61s |   48s |
VS2022 clang-cl     |   226s |  195s |

It also happens to fix what looks like a Windows SDK header bug seen
with VS2019 on AppVeyor CI:
```
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winscard.h(1422,1): error C2220: the following warning is treated as an error (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winscard.h(1422,1): warning C5031: #pragma warning(pop): likely mismatch, popping warning state pushed in different file (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winioctl.h : message : #pragma warning(push) (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\windows.h(254,17): warning C5031: #pragma warning(pop): likely mismatch, popping warning state pushed in different file (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winscard.h : message : #pragma warning(push) (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winsock2.h(4221,1): warning C5031: #pragma warning(pop): likely mismatch, popping warning state pushed in different file (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\windows.h : message : #pragma warning(push) (compiling source file C:\projects\curl\docs\examples\block_ip.c)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winsock2.h : warning C5032: detected #pragma warning(push) with no corresponding #pragma warning(pop) (compiling source file C:\projects\curl\docs\examples\block_ip.c)
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/52531106/job/66b6r098pll2le70#L312

Closes #18232
2025-08-08 23:36:30 +02:00
Viktor Szakats
8ec241bc99
openssl: clear errors after a failed d2i_X509()
Without it, subsequent OpenSSL API calls may fail with an error caught
within the OpenSSL `d2i_X509()` (decode) call.

It was seen to happen when importing from the Windows certificate store
(e.g. with `--ca-native`), and any one of the certificates failed while
decoding, then skipped.

Behind the scene (and undocumented), the failed decode call is adding
an error to an internal OpenSSL error queue. This error is picked up
later, at the connect phase, by another OpenSSL API call, which happens
to check the error queue, without clearing it first. It made the connect
fail with the error collected earlier, while decoding the malformed and
discarded certificate.

Fix by explicitly clearing the error queue if the decode call fails.

Ref: https://docs.openssl.org/3.5/man3/d2i_X509/

`-vvvv` output before this patch:
```
[0-0] == Info: successfully imported Windows ROOT store
[0-0] == Info: successfully imported Windows CA store
[0-0] == Info: [SSL] SSL_connect() -> err=-1, detail=1
[0-0] == Info: TLS connect error: error:068000DD:asn1 encoding routines::illegal padding
[0-0] == Info: [SSL] cf_connect() -> 35, done=0
```

Mainline OpenSSL (as of 3.5.2) and quictls (as of 3.3.0) are affected.

LibreSSL is not affected. (I did not test BoringSSL and AWS-LC)

Assisted-by: Stefan Eissing
Reported-by: Michał Petryka
Fixes #18190

Closes #18228
2025-08-08 20:08:31 +02:00
Daniel Stenberg
b823966d66
tool_parsecfg: use dynbuf for quoted arguments
Instead of doing malloc/free every time and "manual" buffer population.
This reuses the dynbuf for this purpose for the duration of parsing the
file.

Closes #18230
2025-08-08 18:27:03 +02:00
Daniel Stenberg
da27db068f
tool_operate: cleanups
- move the state struct from config to global. It is used as a single
  instance anyway so might as well be a single one to save memory.
- simplify and combine several conditions
- set default retry delay inititally
- use better struct field names to make it easier to understand their
  purposes
- remove the state->outfiles field as it was not necessary
- remove superfluous glob cleanup call
- move conditions around to remove an indent level
- move the ->url NULL check

Takes single_transfer()'s complexity score down from 78 to 68.

Closes #18226
2025-08-08 11:43:28 +02:00
Daniel Stenberg
065a653158
tool_writeout: check gmtime return code too
If the unlikely event happen that it fails, it returns NULL.
CodeSonar is not happy unless we check for it.

Closes #18225
2025-08-08 11:42:33 +02:00
Jay Satiro
673b6c8cb8 schannel: add an error message for client cert not found
Prior to this change curl would show the generic error message
"curl: (58) Problem with the local SSL certificate".

Closes https://github.com/curl/curl/pull/18124
2025-08-08 03:43:54 -04:00
renovate[bot]
fd219aa44d
GHA: update cloudflare/quiche to v0.24.5
Closes #18224
2025-08-08 08:34:10 +02:00
renovate[bot]
56584ed6cc
GHA: update actions/cache digest to 0400d5f
Closes #18222
2025-08-07 23:01:34 +02:00
Daniel Stenberg
02b22ee4ea
curl: remove first argument from helpf()
It was always the same and it is a global already!

Closes #18221
2025-08-07 16:55:39 +02:00
Daniel Stenberg
16eac53dc9
tool_writeout: check strftime() return code
Because if it fails, the contents of the output buffer is undefined.

Pointed out by CodeSonar

Also polished the documentation

Follow-up to fadc487567

Closes #18220
2025-08-07 16:19:22 +02:00
Stefan Eissing
10e60e825c
cfilters: make Curl_conn_get_socket simpler
Since it is only used for the first socket anyway, simplify the
function.

Closes #18219
2025-08-07 14:44:52 +02:00
Stefan Eissing
fd9429cc29
request: eliminate request getheader bool, reverse header default
Deduce that the transfer response expects headers by the protocol
handler implementing `write_resp_hd` callback. This eleminates the
`getheader` parameter in the `Curl_xfer_setup_*()` methods.

Add an implementation to RTSP for `write_resp_hd`, joining the HTTP
protocol in the only handlers having it.

Reverse the default of request's `header` bit that signals that headers
are expected. Default is now FALSE, set to TRUE when setting up the
transfer by presence of `write_resp_hd` in the protocol handler.

Closes #18218
2025-08-07 13:39:50 +02:00
Stefan Eissing
c1372df2e2
ares: destroy channel on shutdown
When we cancel async resolv operations, we have kept an existing ares
channel open. This seems unreliable as reported in #18216.

To get reliable behaviour, always destroy the ares channel on async
shutdown and create a new one on demand.

Fixes #18216
Reported-by: devgs on github
Closes #18217
2025-08-07 11:35:35 +02:00
Daniel Stenberg
3b40128b0f
curl: make global truly global
The GlobalConfig only exists in a single instance and it has worked like
this since the dawn of time. It is about time we stop passing around
pointers to what was already essentially a global object and instead
just use a... global.

It simplifies things.

Closes #18213
2025-08-07 10:43:06 +02:00
Stefan Eissing
2d9f24bf24
http: resurrect addition from 41fe621
For some reason, these lines were unintentionally deleted in 6d5570c.
Thanks to IoannisGS for noticing.

Bug: https://github.com/curl/curl/pull/18179#issuecomment-3162876532
Reported-by: IoannisGS on github
Closes #18215
2025-08-07 10:40:47 +02:00
Viktor Szakats
17bf8809ef
cmake: ExternalProject test tidy-ups
Follow-up to b8296d367a #18208

Closes #18214
2025-08-07 10:37:10 +02:00
Karthik Das
d79269166e
curl_quiche.c: add include
Fixes #18211
Closes #18212
2025-08-07 09:54:09 +02:00
Viktor Szakats
b8296d367a
cmake: make the ExternalProject test work
By micromanaging the project dependency and its inclusion into the test
project. It feels like an awkward construct, but perhaps better than
nothing.

It's also fragile because it's a static build with no assistance from
the external project (curl in this case). Mitigated in test by disabling
all dependencies and some features.

Since there is no special core cmake logic to be tested here, in CI
the test is tested really. To keep CI jobs at minimum, only add 3 of
them, taking 42s in total. (All 6 would take 270s.)

Follow-up to e2a23d5d0d #17203

Closes #18208
2025-08-07 09:07:46 +02:00
Oxan van Leeuwen
a93113b5b4
libcurl: reset rewind flag in curl_easy_reset()
curl_easy_reset() did not reset the `rewind_read` flag. This caused any
handles that previously had a CURLE_SEND_FAIL_REWIND error to get stuck
with that error, failing any subsequent requests, even if they didn't
have any body at all.

Verified in test 3034

Fixes #18206
Closes #18207
2025-08-06 17:58:21 +02:00
Daniel Stenberg
ab9dfebdae
RELEASE-NOTES: synced 2025-08-06 17:19:09 +02:00
Daniel Stenberg
4b61e44e3d
tool_operate: use the correct config pointer
Triggered when doing 100+ parallel globbed upload transfers.

Reported-by: letshack9707 on hackerone

Closes #18200
2025-08-06 16:47:52 +02:00
Viktor Szakats
4e5459c8e1
tests/ech_tests.sh: indent, if/for style, inline ifs
Sync with rest of shell scripts.

Follow-up to 2485a2d100 #17001
Closes #18187
2025-08-06 15:07:04 +02:00
Daniel Stenberg
019991c25e
multi: fix bad splay management
The splay tree is a tree where each easy handle can be added *once*. The
expire time for that node is the closest expire time for that easy
handle.

Easy handles can however have more expire times queued up, so when the
node is removed from the splay tree because it is the next in line to
take care of, we must check if there is another expire time in the queue
and then add the node back into the splay.

Failing to do the later part, the calling of add_next_timeout after
Curl_splaygetbest, would leave the state.expiretime on the previous time
stamp, which when could make the next call to Curl_splaygetbest use the
wrong time stamp and get a wrong node out, causing trouble.

Reported-by: letshack9707 on hackerone
Closes #18201
2025-08-06 14:13:36 +02:00
Stefan Eissing
6cebd35b4c
lib: xfer_setup simplify
Make variants for transfers that send/receive or do both with just the
parameters they need. Split out the shutdown setting into a separate
function. Only FTP bothers with that.

Closes #18203
2025-08-06 14:12:46 +02:00
Daniel Stenberg
034612cd51
tool_urlglob: polish, cleanups, improvements
- assert instead of printing "internal error" for unlikely events
- avoid allocating the main struct
- convert globerror() from macro to function
- renames to shorter and clearer names
- malloc + copy => memdup0
- change buffer handling to dynbuf
- realloc to handle more globs, but use less memory for few

Closes #18198
2025-08-06 08:47:53 +02:00
Stefan Eissing
6d5570c4dd
lib: replace conn [write]sockfd members by index
The `connectdata` members `sockfd` and `writesockfd` needed to by either
CURL_SOCKET_BAD or a copy of one of `conn->sock[2]`. When equal to one,
that index was used to send/recv/poll the proper socket or connection
filter chain.

Replace those with `send_idx` and `recv_idx` which are either -1, 0 or 1
to indicate which socket/filter to send/receive on.

Closes #18179
2025-08-06 08:47:12 +02:00
Daniel Stenberg
aec28f3ad3
splay: add another assert for detected usage problem
Closes #18199
2025-08-06 08:42:39 +02:00
renovate[bot]
a1e4e81431
GHA: update actions/download-artifact action to v5
Closes #18193
2025-08-06 08:41:44 +02:00
Qriist
ca2536a60f
BINDINGS.md: add LibQurl
Add LibQurl to the list of known binding libraries.

Closes #18195
2025-08-06 08:40:04 +02:00
Daniel Stenberg
e1a0e2b72c
config2setopts: avoid curlx_dyn_addf(..., "%s"
Closes #18194
2025-08-06 08:32:07 +02:00
Daniel Stenberg
bf5265ad11
dynbuf: assert on curlx_dyn_addf use with just "%s"
Because it is wasteful and should be done better.

Closes #18194
2025-08-06 08:32:07 +02:00
Viktor Szakats
7aa04d3395
GHA/curl-for-win: include CPU archs in job names
Closes #18191
2025-08-06 00:38:51 +02:00
Stefan Eissing
41fe621ae1
vtls: set seen http version on successful ALPN
When a HTTP version has been negotiated via ALPN, set the member
`conn->httpversion_seen` accordingly. This allows pending transfers to
reuse multiplexed http connections before the response to the first
transfer has arrived.

Fixes #18177
Reported-by: IoannisGS on github
Closes #18181
2025-08-05 16:01:39 +02:00
Daniel Stenberg
952117c032
tool_cb_hrd: remove global pointer from 'struct HdrCbData'
It is not necessary

Closes #18184
2025-08-05 15:47:56 +02:00
Daniel Stenberg
b3b7d65239
tool: replace three malloc + copy with memdup0
The function already existed for private use in var.c

Closes #18185
2025-08-05 15:46:51 +02:00
renovate[bot]
a7bacfe6e0
ci: update openssl/openssl to v3.5.2
Closes #18186
2025-08-05 14:51:21 +02:00
Daniel Stenberg
2978d33089
tool_cb_wrt: use dynbuf instead of "manual" malloc
When creating new file names for no-clobber

Closes #18182
2025-08-05 14:26:16 +02:00
Daniel Stenberg
fe4ade53b7
tool_cb_wrt: split out win_console() from tool_write_cb()
Closes #18180
2025-08-05 14:05:40 +02:00
Daniel Stenberg
b059f7deaf
setopt: add helper functions to setopt_long()
- Consistently keep options within ranges
- Reduce the maximum maxredirs value to fit a signed short
- Removed comments as the place to document the options is not here

Closes #18174
2025-08-05 13:47:47 +02:00
Viktor Szakats
b5d2e6e63f
GHA: pin jobs to windows-2022
To avoid being bumped to windows-2025 in September, and to stay with
the superior performance offered by windows-2022 runners.

Ref: #18140
Closes #18178
2025-08-05 13:42:35 +02:00
David Zhuang
60587049f7
vquic: use curl_getenv
getenv isn't defined on all platforms, which prevents vquic from
building. I specifically ran into this issue building on PlayStation.

Closes #18170
2025-08-05 13:12:00 +02:00
Roberto Hidalgo
4442e06b1f
openssl: output unescaped utf8 x509 issuer/subject DNs
Closes #18171
2025-08-05 13:08:40 +02:00
Daniel Stenberg
3689ef21bd
multi: change prefix for the network change bits to CURLMNWC_
Because "CURLM_" is used for curl multi error codes and it is convenient
to use the prefix to identify the number family.

Closes #18176
2025-08-05 13:05:59 +02:00
Daniel Stenberg
96ff6b98b4
curl_multi_get_offt: language fix
Closes #18175
2025-08-05 11:48:31 +02:00
Daniel Stenberg
b2e6dae695
curl_multi_get_offt: add separate man pages for the options
Follow-up to 1ad2009ad6

Closes #18168
2025-08-05 11:24:30 +02:00