Daniel Stenberg [Fri, 10 May 2024 08:52:58 +0000 (10:52 +0200)]
cf-socket: don't try getting local IP without socket
In cf_tcp_connect(), it might fail and not get a socket assigned to
ctx->sock but set_local_ip() is still called which would make
getsockname() get invoked with a negative file desriptor and fail.
By adding this check, set_local_ip() will now instead blank out the
fields correctly.
Stefan Eissing [Wed, 8 May 2024 11:44:35 +0000 (13:44 +0200)]
h3/ngtcp2: improve error handling
- identify ngtcp2 and nghttp3 error codes that are fatal
- close quic connection on fatal errors
- refuse further filter operations once connection is closed
- confusion about the nghttp3 API. We should close the QUIC stream on
cancel and not use the nghttp3 calls intended to be invoked when the
QUIC stream was closed by the peer.
Jay Satiro [Wed, 8 May 2024 07:37:12 +0000 (03:37 -0400)]
docs: fix some CURLINFO examples
- improve getinfo result check for example sections:
CURLINFO_ACTIVESOCKET, CURLINFO_LASTSOCKET, CURLINFO_SSL_VERIFYRESULT,
CURLINFO_PROXY_SSL_VERIFYRESULT
- fix getinfo result check for example sections:
CURLINFO_NUM_CONNECTS, CURLINFO_OS_ERRNO
- fix verify result check for example sections:
CURLINFO_PROXY_SSL_VERIFYRESULT
Daniel Stenberg [Wed, 8 May 2024 21:50:55 +0000 (23:50 +0200)]
managen: fix the option sort order
... it used to strip off the .d file extension to sort correctly but
ever since the extension changed to .md the operation failed and the
sort got wrong.
Viktor Szakats [Wed, 8 May 2024 17:43:07 +0000 (19:43 +0200)]
appveyor: make gcc 6 mingw64 job build-only
This job has proven to be the flakiest of all, and it's also the oldest
Windows runner we had tests running on: 'Visual Studio 2015', that is
running on Windows Server 2012 R2:
https://www.appveyor.com/docs/windows-images-software/
Turn off tests on this job to help stabilizing CI runs.
This was also one of the slowest running job amongst the AppVeyor CI ones.
Pavel P [Thu, 2 May 2024 04:15:44 +0000 (06:15 +0200)]
asyn-thread: fix curl_global_cleanup crash in Windows
- Make sure that asynchronous resolves handled by Winsock are stopped
before WSACleanup is called.
This is implemented by ensuring that when Curl_resolver_kill is called
(eg via multi_done) it will cancel the Winsock asynchronous resolve and
wait for the cancellation to complete. Winsock runs the asynchronous
completion routine immediately when a resolve is canceled.
Prior to this change it was possible that during curl_global_cleanup
"a DNS resolver thread created by GetAddrInfoExW did not terminate yet,
however curl is already shutting down, deinitializing Winsock with
WSACleanup() leading to an access violation."
Background:
If libcurl is built with the asynchronous threaded resolver option for
Windows then it resolves in one of two ways. For Windows 8.1 and later,
libcurl resolves by using the Winsock asynchronous resolver which does
its own thread management. For older versions of Windows, libcurl
resolves by creating a separate thread that calls getaddrinfo. This
change only affects the former and it's already handled for the latter.
Jay Satiro [Mon, 6 May 2024 18:49:43 +0000 (14:49 -0400)]
asyn-thread: fix Curl_thread_create result check
- Compare to curl_thread_t_null instead of 0 for error.
Currently for both supported thread libraries (pthreads and Windows)
curl_thread_t_null is defined as 0. However, the pattern throughout the
code is to check against curl_thread_t_null and not 0 since for
posterity some thread library may not use 0 for error.
CURLOPT_EGDSOCKET and CURLOPT_RANDOM_FILE are both completely dead
so remove their example sections since the code there is useless.
There is still a way to inject a random file for OpenSSL older than
1.1.0 but it's not what the example showed (and it's not even done
with this option) so we refrain from documenting it here.
Closes: #13540 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
tests: Only require EXAMPLE for non-deprecated options
Manpages which document deprecated CURLOPT_ or CURLINFO_ are not
required to have an EXAMPLE section since they might effectively
be dead no-ops which we don't want to trick users into believing
they can use by copying example code.
Closes: #13540 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Ivan [Mon, 6 May 2024 08:35:53 +0000 (10:35 +0200)]
misc: fix typos, quoting and spelling
Fix wording of comments, and misquotings where `' is markdown parsed
where it shouldn't be, and remove a misspelled preprocessor comment
which really isn't needed (and removing it makes it match surrounding
code better).
Closes: #13538 Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Daniel Stenberg [Fri, 3 May 2024 13:06:54 +0000 (15:06 +0200)]
doh: cleanups in ECH related functions
- make local_decode_rdata_name use dynbuf instead of calloc + memcpy
- avoid extra memdup in local_decode_rdata_alpn
- no need to if() before free()
- use memdup instead of calloc + memcpy in Curl_doh_decode_httpsrr
Daniel Stenberg [Tue, 30 Apr 2024 21:11:59 +0000 (23:11 +0200)]
curl.h: change CURL_SSLVERSION_* from enum to defines
C++20 and later compilers emit a deprecation warning if values from two
different enums are combined with a bitwise operation the way the
CURL_SSLVERSION_* values were previously created.
Reported-by: Michael Kaufmann
Fixes #13510
Closes #13511
Daniel Stenberg [Tue, 30 Apr 2024 09:07:28 +0000 (11:07 +0200)]
tool_cb_rea: limit rate unpause for -T . uploads
To avoid getting stuck in a busy-loop when nothing is read from stdin,
this function now checks the call rate and might enforce a short sleep
when called repeatedly without uploading anything. It is a crude
work-around to avoid a 100% busy CPU.
Reported-by: magisterquis on hackerone
Fixes #13174
Closes #13506
Stefan Eissing [Fri, 26 Apr 2024 12:13:23 +0000 (14:13 +0200)]
tests: add SNI and peer name checks
- connect to DNS names with trailing dot
- connect to DNS names with double trailing dot
- rustls, always give `peer->hostname` and let it
figure out SNI itself
- add SNI tests for ip address and localhost
- document in code and TODO that QUIC with ngtcp2+wolfssl
does not do proper peer verification of the certificate
- mbedtls, skip tests with ip address verification as not
supported by the library
Viktor Szakats [Sat, 27 Apr 2024 22:11:38 +0000 (00:11 +0200)]
cmake: add `BUILD_EXAMPLES` option to build examples
You can enable it with `-DBUILD_EXAMPLES=ON`.
To match autotools' `make examples` feature.
Windows (static) builds not tested.
Also enable examples in a pair of CI jobs.
Apply related updates to the macOS CI workflow:
- drop unused `CXX` envs.
- drop no longer needed `-Wno-error=undef -Wno-error=conversion` flags.
- pass `-Wno-deprecated-declarations` to GCC too (for `BUILD_EXAMPLES`).
- document why `-Wno-deprecated-declarations` is necessary.
Stefan Eissing [Thu, 25 Apr 2024 11:12:18 +0000 (13:12 +0200)]
http3: quiche+ngtcp2 improvements
- quiche: error transfers that try to receive on a closed
or draining connection
- ngtcp2: use callback for extending max bidi streams. This
allows more precise calculation of MAX_CONCURRENT as we
only can start a new stream when the server acknowledges
the close - not when we locally have closed it.
- remove a fprintf() from h2-download client to avoid excess
log files on tests timing out.
Stefan Eissing [Fri, 26 Apr 2024 08:11:51 +0000 (10:11 +0200)]
vtls: TLS session storage overhaul
- add session with destructor callback
- remove vtls `session_free` method
- let `Curl_ssl_addsessionid()` take ownership
of session object, freeing it also on failures
- change tls backend use
- test_17, add tests for SSL session resumption
Daniel Stenberg [Thu, 25 Apr 2024 07:52:51 +0000 (09:52 +0200)]
multi: avoid memory-leak risk
'newurl' is allocated in some conditions and used in a few scenarios,
but there were theoretical combinations in which it would not get freed.
Move the free to happen unconditionally. Never triggered by tests, but
spotted by Coverity.
Stefan Eissing [Thu, 25 Apr 2024 15:35:50 +0000 (17:35 +0200)]
CI: macos fixes for new ARM GHA images
- based on #13478 with additions from #13476
- make homebrew install path flexible
- fix OpenSSL pkgconfig files libdir
- add path to --with-libssh2 target
- disable gcc securetransport due to linker
errors (missing symbols), probably because
the os version is no longer low enough
Jay Satiro [Tue, 28 Nov 2023 08:39:09 +0000 (03:39 -0500)]
dllmain: Call OpenSSL thread cleanup for Windows and Cygwin
- Call OPENSSL_thread_stop on thread termination (DLL_THREAD_DETACH)
to prevent a memory leak in case OpenSSL is linked statically.
- Warn in libcurl-thread.3 that if OpenSSL is linked statically then it
may require thread cleanup.
OpenSSL may need per-thread cleanup to stop a memory leak. For Windows
and Cygwin if libcurl was built as a DLL then we can do that for the
user by calling OPENSSL_thread_stop on thread termination. However, if
libcurl was built statically then we do not have notification of thread
termination and cannot do that for the user.
Also, there are several other unusual cases where it may be necessary
for the user to call OPENSSL_thread_stop, so in the libcurl-thread
warning I added a link to the OpenSSL documentation.
Co-authored-by: Viktor Szakats Reported-by: southernedge@users.noreply.github.com Reported-by: zmcx16@users.noreply.github.com
Ref: https://www.openssl.org/docs/man3.0/man3/OPENSSL_thread_stop.html#NOTES
Jan Venekamp [Tue, 23 Apr 2024 15:59:46 +0000 (17:59 +0200)]
rustls: remove incorrect SSLSUPP_TLS13_CIPHERSUITES flag
The rustls backend advertises SSLSUPP_TLS13_CIPHERSUITES, but
the code does not actually seem to support it (yet?). Removed
the flag and corrected documentation.
tool_operate: don't truncate the etag save file by default
This fixes a regression of 75d79a4486b279100209ddf8c7fdb12955fb66e9. The
code in tool-operate truncated the etag save file, under the assumption
that the file would be written with a new etag value. However since 75d79a4486b279100209ddf8c7fdb12955fb66e9 that might not be the case
anymore and could result in the file being truncated when --etag-compare
and --etag-save was used and that the etag value matched with what the
server responded. Instead the truncation should not be done when a new
etag value should be written.
Test 3204 was added to verify that the file with the etag value doesn't
change the contents when used by --etag-compare and --etage-save and
that value matches with what the server returns on a non 2xx response.
Stefan Eissing [Thu, 18 Apr 2024 21:24:34 +0000 (23:24 +0200)]
http2 + ngtcp2: pass CURLcode errors from callbacks
- errors returned by Curl_xfer_write_resp() and the header variant are
not errors in the protocol. The result needs to be returned on the
next recv() from the protocol filter.
- make xfer write errors for response data cause the stream to be
cancelled
- added pytest test_02_14 and test_02_15 to verify that also for
parallel processing
Daniel Stenberg [Fri, 19 Apr 2024 08:27:04 +0000 (10:27 +0200)]
http: reject HTTP major version switch mid connection
A connection that has seen an HTTP major version now refuses any other
major HTTP version in future responses. Previously, a HTTP/1.x
connection would just silently accept HTTP/2 or HTTP/3 in the status
lines as long as it had support for those built-in. It would then just
lead to confusion and badness.
Indirectly Spotted by CodeSonar which identified a duplicate assignment
in this function.
Daniel Stenberg [Fri, 19 Apr 2024 07:32:23 +0000 (09:32 +0200)]
mqtt: when Curl_xfer_recv returns error, don't use nread
A returned error code makes other return value unreliable, and in this
case potentially uninitialized. On error, do not read other return
values like the nread counter.
Daniel Stenberg [Fri, 19 Apr 2024 07:13:42 +0000 (09:13 +0200)]
ftp: fix socket leak on rare error
In the function AcceptServerConnect() the newly created socket would
leak if Curl_conn_tcp_accepted_set() returns error. Which basically
should never happen.