Commit Graph

13577 Commits

Author SHA1 Message Date
Daniel Stenberg
9ee6da65d8
openssl: fix infof() to avoid compiler warning for %s with null
vtls/openssl.c: In function ‘ossl_connect_step2’:
../lib/curl_trc.h:120:10: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  120 |          Curl_infof(data, __VA_ARGS__); } while(0)
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/openssl.c:4008:5: note: in expansion of macro ‘infof’
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |     ^~~~~
vtls/openssl.c:4008:49: note: format string is defined here
 4008 |     infof(data, "SSL connection using %s / %s / %s / %s",
      |                                                 ^~

Follow-up to b6e6d4ff8f
Closes #12196
2023-10-26 17:43:38 +02:00
Stefan Eissing
dac293cfb7
lib: apache style infof and trace macros/functions
- test for a simplified C99 variadic check
- args to infof() in --disable-verbose are no longer disregarded but
  must compile.

Closes #12167
Fixes #12083
Fixes #11880
Fixes #11891
2023-10-26 17:42:54 +02:00
Stefan Eissing
56a4db2e4e
urldata: move async resolver state from easy handle to connectdata
- resolving is done for a connection, not for every transfer
- save create/dup/free of a cares channel for each transfer
- check values of setopt calls against a local channel if no
  connection has been attached yet, when needed.

Closes #12198
2023-10-26 17:29:17 +02:00
Stefan Eissing
47f5b1a37f
lib: introduce struct easy_poll_set for poll information
Connection filter had a `get_select_socks()` method, inspired by the
various `getsocks` functions involved during the lifetime of a
transfer. These, depending on transfer state (CONNECT/DO/DONE/ etc.),
return sockets to monitor and flag if this shall be done for POLLIN
and/or POLLOUT.

Due to this design, sockets and flags could only be added, not
removed. This led to problems in filters like HTTP/2 where flow control
prohibits the sending of data until the peer increases the flow
window. The general transfer loop wants to write, adds POLLOUT, the
socket is writeable but no data can be written.

This leads to cpu busy loops. To prevent that, HTTP/2 did set the
`SEND_HOLD` flag of such a blocked transfer, so the transfer loop cedes
further attempts. This works if only one such filter is involved. If a
HTTP/2 transfer goes through a HTTP/2 proxy, two filters are
setting/clearing this flag and may step on each other's toes.

Connection filters `get_select_socks()` is replaced by
`adjust_pollset()`. They get passed a `struct easy_pollset` that keeps
up to `MAX_SOCKSPEREASYHANDLE` sockets and their `POLLIN|POLLOUT`
flags. This struct is initialized in `multi_getsock()` by calling the
various `getsocks()` implementations based on transfer state, as before.

After protocol handlers/transfer loop have set the sockets and flags
they want, the `easy_pollset` is *always* passed to the filters. Filters
"higher" in the chain are called first, starting at the first
not-yet-connection one. Each filter may add sockets and/or change
flags. When all flags are removed, the socket itself is removed from the
pollset.

Example:

 * transfer wants to send, adds POLLOUT
 * http/2 filter has a flow control block, removes POLLOUT and adds
   POLLIN (it is waiting on a WINDOW_UPDATE from the server)
 * TLS filter is connected and changes nothing
 * h2-proxy filter also has a flow control block on its tunnel stream,
   removes POLLOUT and adds POLLIN also.
 * socket filter is connected and changes nothing
 * The resulting pollset is then mixed together with all other transfers
   and their pollsets, just as before.

Use of `SEND_HOLD` is no longer necessary in the filters.

All filters are adapted for the changed method. The handling in
`multi.c` has been adjusted, but its state handling the the protocol
handlers' `getsocks` method are untouched.

The most affected filters are http/2, ngtcp2, quiche and h2-proxy. TLS
filters needed to be adjusted for the connecting handshake read/write
handling.

No noticeable difference in performance was detected in local scorecard
runs.

Closes #11833
2023-10-25 09:34:32 +02:00
Viktor Szakats
2100d9fde2
cmake: pre-fill rest of detection values for Windows
The goal of this patch is to avoid unnecessary feature detection work
when doing Windows builds with CMake. Do this by pre-filling well-known
detection results for Windows and specifically for mingw-w64 and MSVC
compilers. Also limit feature checks to platforms where the results are
actually used. Drop a few redundant ones. And some tidying up.

- pre-fill remaining detection values in Windows CMake builds.

  Based on actual detection results observed in CI runs, preceding
  similar work over libssh2 and matching up values with
  `lib/config-win32.h`.

  This brings down CMake configuration time from 58 to 14 seconds on the
  same local machine.

  On AppVeyor CI this translates to:
  - 128 seconds -> 50 seconds VS2022 MSVC with OpenSSL (per CMake job):
    https://ci.appveyor.com/project/curlorg/curl/builds/48208419/job/4gw66ecrjpy7necb#L296
    https://ci.appveyor.com/project/curlorg/curl/builds/48217440/job/8m4fwrr2fe249uo8#L186
  - 62 seconds -> 16 seconds VS2017 MINGW (per CMake job):
    https://ci.appveyor.com/project/curlorg/curl/builds/48208419/job/s1y8q5ivlcs7ub29?fullLog=true#L290
    https://ci.appveyor.com/project/curlorg/curl/builds/48217440/job/pchpxyjsyc9kl13a?fullLog=true#L194

  The formula is about 1-3 seconds delay for each detection. Almost all
  of these trigger a full compile-link cycle behind the scenes, slow
  even today, both cross and native, mingw-w64 and apparently MSVC too.
  Enabling .map files or other custom build features slows it down
  further. (Similar is expected for autotools configure.)

- stop detecting `idn2.h` if idn2 was deselected.
  autotools does this.

- stop detecting `idn2.h` if idn2 was not found.
  This deviates from autotools. Source code requires both header and
  lib, so this is still correct, but faster.

- limit `ADDRESS_FAMILY` detection to Windows.

- normalize `HAVE_WIN32_WINNT` value to lowercase `0x0a12` format.

- pre-fill `HAVE_WIN32_WINNT`-dependent detection results.
  Saving 4 (slow) feature-detections in most builds: `getaddrinfo`,
  `freeaddrinfo`, `inet_ntop`, `inet_pton`

- fix pre-filled `HAVE_SYS_TIME_H`, `HAVE_SYS_PARAM_H`,
  `HAVE_GETTIMEOFDAY` for mingw-w64.
  Luckily this do not change build results, as `WIN32` took
  priority over `HAVE_GETTIMEOFDAY` with the current source
  code.

- limit `HAVE_CLOCK_GETTIME_MONOTONIC_RAW` and
  `HAVE_CLOCK_GETTIME_MONOTONIC` detections to non-Windows.
  We're not using these in the source code for Windows.

- reduce compiler warning noise in CMake internal logs:
  - fix to include `winsock2.h` before `windows.h`.
    Apply it to autotools test snippets too.
  - delete previous `-D_WINSOCKAPI_=` hack that aimed to fix the above.
  - cleanup `CMake/CurlTests.c` to emit less warnings.

- delete redundant `HAVE_MACRO_SIGSETJMP` feature check.
  It was the same check as `HAVE_SIGSETJMP`.

- delete 'experimental' marking from `CURL_USE_OPENSSL`.

- show CMake version via `CMakeLists.txt`.
  Credit to the `zlib-ng` project for the idea:
  61e181c8ae/CMakeLists.txt (L7)

- make `CMake/CurlTests.c` pass `checksrc`.

- `CMake/WindowsCache.cmake` tidy-ups.

- replace `WIN32` guard with `_WIN32` in `CMake/CurlTests.c`.

Closes #12044
2023-10-24 21:06:36 +00:00
Alex Bozarth
b6e6d4ff8f
OpenSSL: Include SIG and KEM algorithms in verbose
Currently the verbose output does not include which algorithms are used
for the signature and key exchange when using OpenSSL. Including the
algorithms used will enable better debugging when working on using new
algorithm implementations. Know what algorithms are used has become more
important with the fast growing research into new quantum-safe
algorithms.

This implementation includes a build time check for the OpenSSL version
to use a new function that will be included in OpenSSL 3.2 that was
introduced in openssl/openssl@6866824

Based-on-patch-by: Martin Schmatz <mrt@zurich.ibm.com>
Closes #12030
2023-10-24 00:11:12 +02:00
Daniel Stenberg
19a82c12c0
http2: provide an error callback and failf the message
Getting nghttp2's error message helps users understand what's going
on. For example when the connection is brought down due a forbidden
header is used - as that header is then not displayed by curl itself.

Example:

  curl: (92) Invalid HTTP header field was received: frame type: 1,
  stream: 1, name: [upgrade], value: [h2,h2c]

Ref: #12172
Closes #12179
2023-10-23 12:34:12 +02:00
Daniel Stenberg
f4ff410807
configure: check for the fseeko declaration too
... and make the code require both symbol and declaration.

This is because for Android, the symbol is always present in the lib at
build-time even when not actually available in run-time.

Assisted-by: Viktor Szakats
Reported-by: 12932 on github
Fixes #12086
Closes #12158
2023-10-22 20:20:49 +02:00
Daniel Stenberg
526779a7ee
openldap: move the alloc of ldapconninfo to *connect()
Fixes a minor memory leak on LDAP connection reuse.

Doing the allocation already in *setup_connection() is wrong since that
connect struct might get discarded early when an existing connection is
reused instead.

Closes #12166
2023-10-21 14:42:30 +02:00
Daniel Stenberg
3afbe0603d
openldap: set the callback argument in oldap_do
... to make sure it has the current 'data' pointer and not a stale old
one.

Reported-by: Dan Fandrich
Closes #12166
2023-10-21 14:42:25 +02:00
Daniel Stenberg
9cf4759354
gnutls: support CURLSSLOPT_NATIVE_CA
Remove the CURL_CA_FALLBACK logic. That build option was added to allow
primarily OpenSSL to use the default paths for loading the CA certs. For
GnuTLS it was instead made to load the "system certs", which is
different and not desirable.

The native CA store loading is now asked for with this option.

Follow-up to 7b55279d1d

Co-authored-by: Jay Satiro

Closes #12137
2023-10-21 14:41:06 +02:00
Stefan Eissing
7eb31c852d
RTSP: improved RTP parser
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with #12035 and various small receive
  sizes where current master fails

Closes #12052
2023-10-21 14:38:21 +02:00
Stefan Eissing
117c9bd978
http2: header conversion tightening
- fold the code to convert dynhds to the nghttp2 structs
  into a dynhds internal method
- saves code duplication
- pacifies compiler analyzers

Closes #12097
2023-10-21 14:36:51 +02:00
Daniel Stenberg
f76fcd6f4d
curl_ntlm_wb: fix elif typo
Reported-by: Manfred Schwarb
Follow-up to d4314cdf65
Bug: d4314cdf65 (r130551295)
2023-10-21 10:29:02 +02:00
Daniel Stenberg
b651aba096
hostip: show the list of IPs when resolving is done
Getting 'curl.se' today then gets this verbose output which might help
debugging connectivity related matters.

* Host curl.se:80 was resolved.
* IPv6: 2a04:4e42::347, 2a04:4e42:200::347, 2a04:4e42:400::347,
  2a04:4e42:600::347, 2a04:4e42:800::347, 2a04:4e42:a00::347,
  2a04:4e42:c00::347, 2a04:4e42:e00::347
* IPv4: 151.101.193.91, 151.101.1.91, 151.101.65.91, 151.101.129.91

Co-authored-by: Jay Satiro
Closes #12145
2023-10-20 23:00:10 +02:00
Daniel Stenberg
8d3ce930f8
vssh: remove the #ifdef for Curl_ssh_init, use empty macro
In the same style as other init calls
2023-10-20 22:56:01 +02:00
Daniel Stenberg
347cf02e9d
easy: remove duplicate wolfSSH init call
It is already done in Curl_ssh_init() where it belongs.

Closes #12168
2023-10-20 22:55:54 +02:00
Daniel Stenberg
24c495a52f
socks: make SOCKS5 use the CURLOPT_IPRESOLVE choice
Fixes #11949
Reported-by: Ammar Faizi
Closes #12163
2023-10-20 17:14:51 +02:00
Daniel Stenberg
fc077bc786
urldata: move the 'internal' boolean to the state struct
... where all the other state bits for the easy handles live.

Closes #12165
2023-10-20 16:59:52 +02:00
Daniel Stenberg
b0bee93dfe
url: don't touch the multi handle when closing internal handles
Reported-by: Maksymilian Arciemowicz
Closes #12165
2023-10-20 16:59:43 +02:00
Faraz Fallahi
d31a8424e8
getenv: PlayStation doesn't have getenv()
Closes #12140
2023-10-19 17:00:35 +02:00
Daniel Stenberg
df9aea22c2
transfer: only reset the FTP wildcard engine in CLEAR state
To avoid the state machine to start over and redownload all the files
*again*.

Reported-by: lkordos on github
Regression from 843b3baa3e (shipped in 8.1.0)
Bisect-by: Dan Fandrich
Fixes #11775
Closes #12156
2023-10-19 16:58:31 +02:00
Daniel Stenberg
d4314cdf65
ntlm_wb: use pipe instead of socketpair when possible
Closes #12149
2023-10-19 10:20:12 +02:00
Daniel Stenberg
43eb798da0
asyn-thread: use pipe instead of socketpair for IPC when available
If pipe() is present. Less overhead.

Helped-by: Viktor Szakats
Closes #12146
2023-10-18 08:23:53 +02:00
Daniel Stenberg
03a70edc50
multi: use pipe instead of socketpair to *wakeup()
If pipe() is present. Less overhead.

Closes #12142
2023-10-17 15:29:31 +02:00
Daniel Stenberg
01057d6161
socks: better buffer size checks for socks4a user and hostname
Also limit the proxy user name to 255 bytes, which is the same limit as
in SOCKS5.

Reported-by: sd0 on hackerone
Closes #12139
2023-10-16 23:47:08 +02:00
Jay Satiro
f80ab60c27 curl_trc: remove a bad assertion
- Remove DEBUGASSERT that an internal handle must not have user
  private_data set before calling the user's debug callback.

This is a follow-up to 0dc40b2a. The user can distinguish their easy
handle from an internal easy handle by setting CURLOPT_PRIVATE on their
easy handle. I had wrongly assumed that meant the user couldn't then
set CURLOPT_PRIVATE on an internal handle as well.

Bug: https://github.com/curl/curl/pull/12060#issuecomment-1754594697
Reported-by: Daniel Stenberg

Closes https://github.com/curl/curl/pull/12104
2023-10-14 03:19:59 -04:00
Stefan Eissing
9cc5787577
quic: manage connection idle timeouts
- configure a 120s idle timeout on our side of the connection
- track the timestamp when actual socket IO happens
- check IO timestamp to our *and* the peer's idle timeouts
  in "is this connection alive" checks

Reported-by: calvin2021y on github
Fixes #12064
Closes #12077
2023-10-13 23:15:47 +02:00
Viktor Szakats
4e57d0f0cb
lib: fix gcc warning in printf call
Do not pass NULL to printf %s.

Seen with gcc 13.2.0 on Debian:
```
.../curl/lib/connect.c:696:27: warning: '%s' directive argument is null [-Wformat-overflow=]
```
Ref: https://github.com/curl/curl-for-win/actions/runs/6476161689/job/17584426483#step:3:11104

Ref: #10284
Co-authored-by: Jay Satiro
Closes #12082
2023-10-13 09:19:05 +00:00
Alex Klyubin
465f02bf17
http2: safer invocation of populate_binsettings
populate_binsettings now returns a negative value on error, instead of a
huge positive value. Both places which call this function have been
updated to handle this change in its contract.

The way populate_binsettings had been used prior to this change the huge
positive values -- due to signed->unsigned conversion of the potentially
negative result of nghttp2_pack_settings_payload which returns negative
values on error -- are not possible. But only because http2.c currently
always provides a large enough output buffer and provides H2 SETTINGS
IVs which pass the verification logic inside nghttp2.  If the
verification logic were to change or if http2.c started passing in more
IVs without increasing the output buffer size, the overflow could become
reachable, and libcurl/curl might start leaking memory contents to
servers/proxies...

Closes #12101
2023-10-13 11:07:28 +02:00
Daniel Stenberg
b9f832edcc
openssl: avoid BN_num_bits() NULL pointer derefs
Reported-by: icy17 on github
Fixes #12099
Closes #12100
2023-10-13 11:00:18 +02:00
Daniel Stenberg
4dbc2ad467
wolfssl: require WOLFSSL_SYS_CA_CERTS for loading system CA
This define is set in wolfssl's options.h file when this function and
feature is present. Handles both builds with the feature explicitly
disabled and wolfSSL versions before 5.5.2 - which introduced this API
call.

Closes #12108
2023-10-13 10:58:23 +02:00
Loïc Yhuel
732d8ef758 cmake: fix CURL_DISABLE_GETOPTIONS
- Add CURL_DISABLE_GETOPTIONS to curl_config.h.cmake.

Prior to this change the option had no effect because it was missing
from that file.

Closes https://github.com/curl/curl/pull/12091
2023-10-13 00:57:09 -04:00
Loïc Yhuel
5adb6000ff easy_lock: add a pthread_mutex_t fallback
This allows to keep the init threadsafe with gcc < 4.9.0 (no C11
atomics).

Closes https://github.com/curl/curl/pull/12090
2023-10-12 23:40:08 -04:00
Daniel Stenberg
f2de575242
http: avoid Expect: 100-continue if Upgrade: is used
Reported-by: Daniel Jelinski
Fixes #12022
Closes #12062
2023-10-12 16:31:41 +02:00
Jay Satiro
fb4415d8ae
socks: return error if hostname too long for remote resolve
Prior to this change the state machine attempted to change the remote
resolve to a local resolve if the hostname was longer than 255
characters. Unfortunately that did not work as intended and caused a
security issue.

Bug: https://curl.se/docs/CVE-2023-38545.html
2023-10-11 07:34:19 +02:00
Stefan Eissing
b0f3d71c1f
MQTT: improve receive of ACKs
- add `mq->recvbuf` to provide buffering of incomplete
  ACK responses
- continue ACK reading until sufficient bytes available
- fixes test failures on low network receives

Closes #12071
2023-10-09 18:34:17 +02:00
Viktor Szakats
5032f04ee9
quic: fix BoringSSL build
Add guard around `SSL_CTX_set_ciphersuites()` use.

Bug: https://github.com/curl/curl/pull/12065#issuecomment-1752171885

Follow-up to aa9a6a1770

Co-authored-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Closes #12067
2023-10-09 12:43:56 +00:00
Daniel Stenberg
dc4e885f35
curl_easy_pause: set "in callback" true on exit if true
Because it might have called another callback in the mean time that then
set the bit FALSE on exit.

Reported-by: Jay Satiro
Fixes #12059
Closes #12061
2023-10-09 08:21:51 +02:00
Viktor Szakats
0e4bef0862
h3: add support for ngtcp2 with AWS-LC builds
```
curl 8.4.0-DEV (x86_64-apple-darwin) libcurl/8.4.0-DEV (SecureTransport) AWS-LC/1.15.0 nghttp2/1.56.0 ngtcp2/0.19.1 nghttp3/0.15.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IPv6 Largefile MultiSSL NTLM SSL threadsafe UnixSockets
```

Also delete an obsolete GnuTLS TODO and update the header comment in
`FindNGTCP2.cmake`.

Reviewed-by: Daniel Stenberg
Closes #12066
2023-10-08 22:35:04 +00:00
Viktor Szakats
58a95b6a49
build: do not publish HAVE_BORINGSSL, HAVE_AWSLC macros
Syncing this up with CMake.

Source code uses the built-in `OPENSSL_IS_AWSLC` and
`OPENSSL_IS_BORINSSL` macros to detect BoringSSL and AWS-LC. No help is
necessary from the build tools.

The one use of `HAVE_BORINGSSL` in the source turned out to be no longer
necessary for warning-free BoringSSL + Schannel builds. Ref: #1610 #2634

autotools detects this anyway for display purposes.
CMake detects this to decide whether to use the BoringSSL-specific
crypto lib with ngtcp2. It detects AWS-LC, but doesn't use the detection
result just yet (planned in #12066).

Ref: #11964

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #12065
2023-10-08 22:29:45 +00:00
Daniel Stenberg
43215842f2
url: fall back to http/https proxy env-variable if ws/wss not set
Reported-by: Craig Andrews
Fixes #12031
Closes #12058
2023-10-08 11:29:10 +02:00
Stefan Eissing
b9c78eeac1
cf-socket: simulate slow/blocked receives in debug
add 2 env variables for non-UDP sockets:
1. CURL_DBG_SOCK_RBLOCK: percentage of receive calls that randomly
   should return EAGAIN
2. CURL_DBG_SOCK_RMAX: max amount of bytes read from socket

Closes #12035
2023-10-08 11:04:09 +02:00
Stefan Eissing
ba1e559bd8
http2: refused stream handling for retry
- answer HTTP/2 streams refused via a GOAWAY from the server to
  respond with CURLE_RECV_ERROR in order to trigger a retry
  on another connection

Reported-by: black-desk on github
Ref #11859
Closes #12054
2023-10-08 11:01:47 +02:00
Jay Satiro
0dc40b2a0f CURLOPT_DEBUGFUNCTION.3: warn about internal handles
- Warn that the user's debug callback may be called with the handle
  parameter set to an internal handle.

Without this warning the user may assume that the only handles their
debug callback receives are the easy handles on which they set
CURLOPT_DEBUGFUNCTION.

This is a follow-up to f8cee8cc which changed DoH handles to inherit
the debug callback function set in the user's easy handle. As a result
those handles are now passed to the user's debug callback function.

Closes https://github.com/curl/curl/pull/12034
2023-10-08 00:21:10 -04:00
Jay Satiro
cf577bca84 url: fix typo 2023-10-07 18:43:14 -04:00
Daniel Stenberg
07008ee8ac
multi: do CURLM_CALL_MULTI_PERFORM at two more places
... when it does a state transition but there is no particular socket or
timer activity. This was made apparent when commit b5bb84c removed a
superfluous timer expiry.

Reported-by: Dan Fandrich.
Fixes #12033
Closes #12056
2023-10-07 22:54:54 +02:00
David Benjamin
9eb774304e
openssl: use X509_ALGOR_get0 instead of reaching into X509_ALGOR
While the struct is still public in OpenSSL, there is a (somewhat
inconvenient) accessor. Use it to remain compatible if it becomes opaque
in the future.

Closes #12038
2023-10-06 14:51:20 +02:00
Daniel Stenberg
6dd6654f75
multi: set CURLM_CALL_MULTI_PERFORM after switch to DOING_MORE
Since there is nothing to wait for there. Avoids the test 1233 hang
reported in #12033.

Reported-by: Dan Fandrich
Closes #12042
2023-10-06 08:49:58 +02:00
Jay Satiro
021d04f291 idn: fix WinIDN null ptr deref on bad host
- Return CURLE_URL_MALFORMAT if IDN hostname cannot be converted from
  UTF-8 to UTF-16.

Prior to this change a failed conversion erroneously returned CURLE_OK
which meant 'decoded' pointer (what would normally point to the
punycode) would not be written to, remain NULL and be dereferenced
causing an access violation.

Closes https://github.com/curl/curl/pull/11983
2023-10-05 03:11:41 -04:00
Daniel Stenberg
3ef3eaa27e
base64: also build for curl
Since the tool itself now uses the base64 code using the curlx way, it
needs to build also when the tool needs it. Starting now, the tool build
defines BULDING_CURL to allow lib-side code to use it.

Follow-up to 2e160c9c65

Closes #12010
2023-10-04 23:22:16 +02:00
Viktor Szakats
fd328fcaf1
cmake: fix unity builds for more build combinations
By using unique static function/variable names in source files
implementing these interfaces.

- OpenLDAP combined with any SSH backend.

- MultiSSL with mbedTLS, OpenSSL, wolfSSL, SecureTransport.

Closes #12027
2023-10-04 15:36:06 +00:00
Viktor Szakats
3b6d18bbf6
spelling: fix codespell 2.2.6 typos
Closes #12019
2023-10-03 21:37:56 +00:00
Viktor Szakats
83ec54e1b9
build: alpha-sort source files for lib and src
Closes #12014
2023-10-03 12:58:17 +00:00
Viktor Szakats
f42a279ee3
cmake: fix unity with Windows Unicode + TrackMemory
Found the root cause of the startup crash in unity builds with Unicode
and TrackMemory enabled at the same time.

We must make sure that the `memdebug.h` header doesn't apply to
`lib/curl_multibyte.c` (as even noted in a comment there.) In unity
builds all headers apply to all sources, including `curl_multibyte.c`.
This probably resulted in an infinite loop on startup.

Exclude this source from unity compilation with TrackMemory enabled,
in both libcurl and curl tool. Enable unity mode for a debug Unicode
CI job to keep it tested. Also delete the earlier workaround that
fully disabled unity for affected builds.

Follow-up to d82b080f63 #12005
Follow-up to 3f8fc25720 #11095

Closes #11928
2023-10-03 09:43:46 +00:00
Stefan Eissing
6b9a591bf7
h2: testcase and fix for pausing h2 streams
- refs #11982 where it was noted that paused transfers may
  close successfully without delivering the complete data
- made sample poc into tests/http/client/h2-pausing.c and
  added test_02_27 to reproduce

Closes #11989
Fixes #11982
Reported-by: Harry Sintonen
2023-09-30 23:53:33 +02:00
Viktor Szakats
f85dcaa6d2
cmake: detect sys/wait.h and netinet/udp.h
Ref: #11964 (effort to sync cmake detections with autotools)

Closes #11996
2023-09-30 15:17:21 +00:00
Daniel Stenberg
91878ebeca
lib: provide and use Curl_hexencode
Generates a lower case ASCII hex output from a binary input.

Closes #11990
2023-09-30 11:45:39 +02:00
Daniel Stenberg
463528b0f8
wolfssl: ignore errors in CA path
The default wolfSSL_CTX_load_verify_locations() function is quite picky
with the certificates it loads and will for example return error if just
one of the certs has expired.

With the *_ex() function and its WOLFSSL_LOAD_FLAG_IGNORE_ERR flag, it
behaves more similar to what OpenSSL does by default.

Even the set of default certs on my Debian unstable has several expired
ones.

Assisted-by: Juliusz Sosinowicz
Assisted-by: Michael Osipov

Closes #11987
2023-09-30 11:19:38 +02:00
Viktor Szakats
da5dcb7007
cmake: detect HAVE_CLOCK_GETTIME_MONOTONIC_RAW
Based on existing autotools logic.

Ref: #11964 (effort to sync cmake detections with autotools)

Closes #11981
2023-09-29 18:30:34 +00:00
Viktor Szakats
ca7daadd9b
cmake: fix HAVE_WRITABLE_ARGV detection
Move detection before the creation of detection results in
`curl_config.h`.

Ref: #11964 (effort to sync cmake detections with autotools)

Closes #11978
2023-09-29 18:29:55 +00:00
Viktor Szakats
1bc69df7b4
tidy-up: use more example domains
Also make use of the example TLD:
https://en.wikipedia.org/wiki/.example

Reviewed-by: Daniel Stenberg
Closes #11992
2023-09-29 18:25:56 +00:00
Daniel Stenberg
9b517c8b69
cmake: add missing checks
- check for arc4random. To make rand.c use it accordingly.
- check for fcntl
- fix fseek detection
- add SIZEOF_CURL_SOCKET_T
- fix USE_UNIX_SOCKETS
- define HAVE_SNPRINTF to 1
- check for fnmatch
- check for sched_yield
- remove HAVE_GETPPID duplicate from curl_config.h
- add HAVE_SENDMSG

Ref: #11964

Co-authored-by: Viktor Szakats
Closes #11973
2023-09-28 23:00:43 +02:00
Daniel Stenberg
db07376a3e
lib: remove TIME_WITH_SYS_TIME
It is not used in any code anywhere.

Ref: #11964
Closes #11975
2023-09-28 22:58:36 +02:00
Daniel Stenberg
290622cea6
cmake: add check for suseconds_t
And fix the HAVE_LONGLONG define

Ref: #11964
Closes #11977
2023-09-28 22:56:24 +02:00
Viktor Szakats
a8c773845f
tidy-up: whitespace fixes
Closes #11972
2023-09-28 12:03:28 +00:00
Viktor Szakats
781242ffa4
cmake: detect TLS-SRP in OpenSSL/wolfSSL/GnuTLS
With new option `CURL_DISABLE_SRP=ON` to force-disable it.
To match existing option and detection logic in autotools.

Also:
- fix detecting GnuTLS.
  We assume `nettle` as a GnuTLS dependency.
- add CMake GnuTLS CI job.
- bump AppVeyor CMake OpenSSL MSVC job to OpenSSL 1.1.1 (from 1.0.2)
  TLS-SRP fails to detect with 1.0.2 due to an OpenSSL header bug.
- fix compiler warning when building with GnuTLS and disabled TLS-SRP.
- fix comment typos, whitespace.

Ref: #11964

Closes #11967
2023-09-28 10:50:56 +00:00
Loïc Yhuel
b5bb84cbef
connect: only start the happy eyeballs timer when needed
The timeout is only used when there is a second address family, for the
delayed eyeballer.

Closes #11939
2023-09-28 10:21:32 +02:00
Stefan Eissing
0bd9e137e3
lib: move handling of data->req.writer_stack into Curl_client_write()
- move definitions from content_encoding.h to sendf.h
- move create/cleanup/add code into sendf.c
- installed content_encoding writers will always be called
  on Curl_client_write(CLIENTWRITE_BODY)
- Curl_client_cleanup() frees writers and tempbuffers from
  paused transfers, irregardless of protocol

Closes #11908
2023-09-28 10:00:13 +02:00
Loïc Yhuel
d39863d27a
multi: round the timeout up to prevent early wakeups
Curl_timediff rounds down to the millisecond, so curl_multi_perform can
be called too early, then we get a timeout of 0 and call it again.

The code already handled the case of timeouts which expired less than
1ms in the future.  By rounding up, we make sure we will never ask the
platform to wake up too early.

Closes #11938
2023-09-28 09:52:20 +02:00
Daniel Stenberg
1f92db87e0
inet_ntop: add typecast to silence Coverity
CID 1024653:  Integer handling issues  (SIGN_EXTENSION)

Suspicious implicit sign extension: "src[i]" with type "unsigned char
const" (8 bits, unsigned) is promoted in "src[i] << (1 - i % 2 << 3)" to
type "int" (32 bits, signed), then sign-extended to type "unsigned long"
(64 bits, unsigned).  If "src[i] << (1 - i % 2 << 3)" is greater than
0x7FFFFFFF, the upper bits of the result will all be 1.

111         words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));

The value will not be greater than 0x7FFFFFFF so this still cannot
happen.

Also, switch to ints here instead of longs. The values stored are 16 bit
so at least no need to use 64 bit variables. Also, longs are 32 bit on
some platforms so this logic still needs to work with 32 bits.

Closes #11960
2023-09-27 13:18:22 +02:00
Daniel Stenberg
01d8473b25
connect: expire the timeout when trying next
... so that it gets called again immediately and can continue trying
addresses to connect to. Otherwise it might unnecessarily wait for a
while there.

Fixes #11920
Reported-by: Loïc Yhuel
Closes #11935
2023-09-27 10:35:36 +02:00
Daniel Stenberg
afb4b15614
http: remove wrong comment for http_should_fail
Reported-by: Christian Schmitz
Ref: #11936
Closes #11941
2023-09-27 09:15:03 +02:00
Viktor Szakats
1411c5eb33
cmake: add feature checks for memrchr and getifaddrs
- `HAVE_MEMRCHR` for `memrchr`.
- `HAVE_GETIFADDRS` for `getifaddrs`.
  This was present in `lib/curl_config.h.cmake` but missed the detection
  logic.

To match existing autotools feature checks.

Closes #11954
2023-09-26 22:10:28 +00:00
Viktor Szakats
96c29900bc
build: delete checks for C89 standard headers
Delete checks and guards for standard C89 headers and assume these are
available: `stdio.h`, `string.h`, `time.h`, `setjmp.h`, `stdlib.h`,
`stddef.h`, `signal.h`.

Some of these we already used unconditionally, some others we only used
for feature checks.

Follow-up to 9c7165e96a #11918 (for `stdio.h` in CMake)

Closes #11940
2023-09-26 14:25:10 +00:00
Stefan Eissing
d15ffe18d9 multiif.h: remove Curl_multi_dump declaration
Follow-up to d850eea2 which removed the Curl_multi_dump definition.

Closes https://github.com/curl/curl/pull/11946
2023-09-26 03:51:13 -04:00
Jay Satiro
aa6c94c5bf config-win32: define HAVE__FSEEKI64
Follow-up to 9c7165e9 which added an fseeko wrapper to the lib that
calls _fseeki64 if it is available.

Closes https://github.com/curl/curl/pull/11944
2023-09-26 03:45:20 -04:00
Stefan Eissing
34cdcb9b96 openssl: improve ssl shutdown handling
- If SSL shutdown is not finished then make an additional call to
  SSL_read to gather additional tracing.

- Fix http2 and h2-proxy filters to forward do_close() calls to the next
  filter.

For example h2 and SSL shutdown before and after this change:

Before:

Curl_conn_close -> cf_hc_close -> Curl_conn_cf_discard_chain ->
ssl_cf_destroy

After:

Curl_conn_close -> cf_hc_close -> cf_h2_close -> cf_setup_close ->
ssl_cf_close

Note that currently the tracing does not show output on the connection
closure handle. Refer to discussion in #11878.

Ref: https://github.com/curl/curl/discussions/11878

Closes https://github.com/curl/curl/pull/11858
2023-09-26 03:40:20 -04:00
Loïc Yhuel
579f09343d
multi: fix small timeouts
Since Curl_timediff rounds down to the millisecond, timeouts which
expire in less than 1ms are considered as outdated and removed from the
list. We can use Curl_timediff_us instead, big timeouts could saturate
but this is not an issue.

Closes #11937
2023-09-26 00:58:47 +02:00
Viktor Szakats
a8ebde99f7
cmake: lib CURL_STATICLIB fixes (Windows)
- always define `CURL_STATICLIB` when building libcurl for Windows.

  This disables `__declspec(dllexport)` for exported libcurl symbols.
  In normal mode (hide symbols) these exported symbols are specified
  via `libcurl.def`. When not hiding symbols, all symbols are exported
  by default.

  Regression from 1199308dbc

  Fixes #11844

- fix to omit `libcurl.def` when not hiding private symbols.

  Regression from 2ebc74c36a

- fix `ENABLED_DEBUG=ON` + shared curl tool Windows builds by also
  omitting `libcurl.def` in this case, and exporting all symbols
  instead. This ensures that a shared curl tool can access all debug
  functions which are not normally exported from libcurl DLL.

- delete `INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB"` for "objects"
  target.

  Follow-up to 2ebc74c36a

- delete duplicate `BUILDING_LIBCURL` definitions.

- fix `HIDES_CURL_PRIVATE_SYMBOLS` to not overwrite earlier build settings.

  Follow-up to 1199308dbc

Closes #11914
2023-09-25 22:05:29 +00:00
Daniel Stenberg
9ffd411735
curl_multi_get_handles: get easy handles from a multi handle
Closes #11750
2023-09-25 20:16:58 +02:00
Stefan Eissing
bb4032a152
http: h1/h2 proxy unification
- use shared code for setting up the CONNECT request
  when tunneling, used in HTTP/1.x and HTTP/2 proxying
- eliminate use of Curl_buffer_send() and other manipulations
  of `data->req` or `data->state.ulbuf`

Closes #11808
2023-09-25 20:12:18 +02:00
Natanael Copa
9c7165e96a
lib: use wrapper for curl_mime_data fseek callback
fseek uses long offset which does not match with curl_off_t. This leads
to undefined behavior when calling the callback and caused failure on
arm 32 bit.

Use a wrapper to solve this and use fseeko which uses off_t instead of
long.

Thanks to the nice people at Libera IRC #musl for helping finding this
out.

Fixes #11882
Fixes #11900
Closes #11918
2023-09-25 20:03:09 +02:00
Daniel Stenberg
358f7e7577
warnless: remove unused functions
Previously put there for use with the intel compiler

Closes #11932
2023-09-25 17:06:33 +02:00
Daniel Stenberg
d850eea2d0
multi: remove Curl_multi_dump
A debug-only function that is basically never used. Removed to ease the
use of the singleuse script to detect non-static functions not used
outside the file where it is defined.

Closes #11931
2023-09-25 12:35:40 +02:00
Jay Satiro
ab18c04218 url: fix netrc info message
- Fix netrc info message to use the generic ".netrc" filename if the
  user did not specify a netrc location.

- Update --netrc doc to add that recent versions of curl on Windows
  prefer .netrc over _netrc.

Before:
* Couldn't find host google.com in the (nil) file; using defaults

After:
* Couldn't find host google.com in the .netrc file; using defaults

Closes https://github.com/curl/curl/pull/11904
2023-09-24 03:37:13 -04:00
Dan Fandrich
739a9e8e12 wolfssh: do cleanup in Curl_ssh_cleanup
Closes: #11921
2023-09-23 23:15:11 -07:00
Viktor Szakats
6a85659e7d
Makefile.mk: always set CURL_STATICLIB for lib (Windows)
Also fix to export all symbols in Windows debug builds, making
`-debug-dyn` builds work with `-DCURL_STATICLIB` set.

Ref: https://github.com/curl/curl/pull/11914 (same for CMake)

Closes #11924
2023-09-23 20:42:47 +00:00
Daniel Stenberg
aa9a6a1770
quic: set ciphers/curves the same way regular TLS does
for OpenSSL/BoringSSL

Fixes #11796
Reported-by: Karthikdasari0423 on github
Assisted-by: Jay Satiro
Closes #11836
2023-09-23 11:36:05 +02:00
Daniel Stenberg
914e49b9b7
lib: let the max filesize option stop too big transfers too
Previously it would only stop them from getting started if the size is
known to be too big then.

Update the libcurl and curl docs accordingly.

Fixes #11810
Reported-by: Elliot Killick
Assisted-by: Jay Satiro
Closes #11820
2023-09-23 11:20:20 +02:00
Viktor Szakats
38029101e2
mingw: delete support for legacy mingw.org toolchain
Drop support for "old" / "legacy" / "classic" / "v1" / "mingw32" MinGW:
  https://en.wikipedia.org/wiki/MinGW, https://osdn.net/projects/mingw/
Its homepage used to be http://mingw.org/ [no HTTPS], and broken now.
It supported the x86 CPU only and used a old Windows API header and
implib set, often causing issues. It also misses most modern Windows
features, offering old versions of both binutils and gcc (no llvm/clang
support). It was last updated 2 years ago.

curl now relies on toolchains based on the mingw-w64 project:
https://www.mingw-w64.org/  https://sourceforge.net/projects/mingw-w64/
https://www.msys2.org/  https://github.com/msys2/msys2
https://github.com/mstorsjo/llvm-mingw
(Also available via Linux and macOS package managers.)

Closes #11625
2023-09-23 09:12:57 +00:00
Daniel Stenberg
5595e33617
bufq: remove Curl_bufq_skip_and_shift (unused)
Closes #11915
2023-09-23 10:50:10 +02:00
Viktor Szakats
48ba5d9007
cmake: fix unity symbol collisions in h2 builds
Regression from 331b89a319

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #11912
2023-09-22 09:19:10 +00:00
Jakub Jelen
35eb2614d8
libssh: cap SFTP packet size sent
Due to libssh limitations

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

Closes #11804
2023-09-21 16:53:30 +02:00
Jay Satiro
80fc040e45 libssh2: fix error message on failed pubkey-from-file
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error
  message "SSH public key authentication failed: Reason unknown (-1)".

When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a
generic error and therefore doesn't set an error message. AFAICT that is
not documented behavior.

Prior to this change libcurl retrieved the last set error message which
would be from a previous function failing. That resulted in misleading
auth failed error messages in verbose mode.

Bug: https://github.com/curl/curl/issues/11837#issue-1891827355
Reported-by: consulion@users.noreply.github.com

Closes https://github.com/curl/curl/pull/11881
2023-09-21 02:59:21 -04:00
Stefan Eissing
8898257446
lib: disambiguate Curl_client_write flag semantics
- use CLIENTWRITE_BODY *only* when data is actually body data
- add CLIENTWRITE_INFO for meta data that is *not* a HEADER
- debug assertions that BODY/INFO/HEADER is not used mixed
- move `data->set.include_header` check into Curl_client_write
  so protocol handlers no longer have to care
- add special in FTP for `data->set.include_header` for historic,
  backward compatible reasons
- move unpausing of client writes from easy.c to sendf.c, so that
  code is in one place and can forward flags correctly

Closes #11885
2023-09-21 08:56:50 +02:00
Patrick Monnerat
bbac7c19e5
tftpd: always use curl's own tftp.h
Using the system's provided arpa/tftp.h and optimizing, GCC 12 detects
and reports a stringop-overread warning:

tftpd.c: In function ‘write_behind.isra’:
tftpd.c:485:12: warning: ‘write’ reading between 1 and 2147483647 bytes from a region of size 0 [-Wstringop-overread]
  485 |     return write(test->ofile, writebuf, count);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from tftpd.c:71:
/usr/include/arpa/tftp.h:58:30: note: source object ‘tu_data’ of size 0
   58 |                         char tu_data[0];        /* data or error string */
      |                              ^~~~~~~

This occurs because writebuf points to this field and the latter
cannot be considered as being of dynamic length because it is not
the last field in the structure. Thus it is bound to its declared
size.

This commit always uses curl's own version of tftp.h where the
target field is last in its structure, effectively avoiding the
warning.

As HAVE_ARPA_TFTP_H is not used anymore, cmake/configure checks for
arpa/tftp.h are removed.

Closes #11897
2023-09-21 08:47:07 +02:00
Daniel Stenberg
ff5e502316
lib: enable hmac for digest as well
Previously a build that disabled NTLM and aws-sigv4 would fail to build
since the hmac was disabled, but it is also needed for digest auth.

Follow-up to e92edfbef6

Fixes #11890
Reported-by: Aleksander Mazur
Closes #11896
2023-09-20 13:38:42 +02:00
Daniel Stenberg
7cf269dd1c
idn: if idn2_check_version returns NULL, return error
... this avoids a NULL dereference for this unusual case.

Reported-by: s0urc3_ on hackerone
Closes #11898
2023-09-20 13:36:51 +02:00
Daniel Stenberg
0d3956b8c6
http: fix CURL_DISABLE_BEARER_AUTH breakage
When bearer auth was disabled, the if/else logic got wrong and caused
problems.

Follow-up to e92edfbef6
Fixes #11892
Reported-by: Aleksander Mazur
Closes #11895
2023-09-20 13:33:31 +02:00
Michael Osipov
452182332d
wolfssl: allow capath with CURLOPT_CAINFO_BLOB
Remain consistent with OpenSSL. While CAfile is nulled as documented
with CURLOPT_CAINFO_BLOB, CApath remains intact.

Closes #11886
2023-09-20 13:30:41 +02:00
Michael Osipov
cc123e2757
wolfssl: use ssl_cafile/ssl_capath variables consistent with openssl.c
Closes #11886
2023-09-20 13:30:34 +02:00
Daniel Stenberg
8420fef590
wolfssl: if CURLOPT_CAINFO_BLOB is set, ignore the CA files
Ref: #11883
Reported-by: Michael Osipov
Closes #11884
2023-09-19 12:59:56 +02:00
Daniel Stenberg
73c82ed941
cookie: set ->running in cookie_init even if data is NULL
This is a regression introduced in b1b326ec50 (shipped in curl 8.1.0)

Test 3103 verifies.

Fixes #11875
Reported-by: wangp on github
Closes #11876
2023-09-19 08:26:07 +02:00
Daniel Stenberg
2cb0d346aa
http: use per-request counter to check too large headers
Not the counter that accumulates all headers over all redirects.

Follow-up to 3ee79c1674

Do a second check for 20 times the limit for the accumulated size for
all headers.

Fixes #11871
Reported-by: Joshix-1 on github
Closes #11872
2023-09-18 22:57:01 +02:00
Daniel Stenberg
f6e5435cef h2-proxy: remove left-over mistake in drain_tunnel()
Left-over from 331b89a319

Reported-by: 南宫雪珊

Closes https://github.com/curl/curl/pull/11877
2023-09-18 14:30:20 -04:00
vvb2060
746dbc1488
lib: failf/infof compiler warnings
Closes #11874
2023-09-18 09:56:25 +02:00
Daniel Stenberg
706eff9f1f
rand: fix 'alnum': array is too small to include a terminating null character
It was that small on purpose, but this change now adds the null byte to
avoid the error.

Follow-up to 3aa3cc9b05

Reported-by: Dan Fandrich
Ref: #11838
Closes #11870
2023-09-17 17:43:52 +02:00
Daniel Stenberg
f8cee8cc31
doh: inherit DEBUGFUNCTION/DATA
When creating new transfers for doing DoH, they now inherit the debug
settings from the initiating transfer, so that the application can
redirect and handle the verbose output correctly even for the DoH
transfers.

Reported-by: calvin2021y on github
Fixes #11864
Closes #11869
2023-09-16 18:27:38 +02:00
Dan Fandrich
c879203538 http_aws_sigv4: fix sorting with empty parts
When comparing with an empty part, the non-empty one is always
considered greater-than. Previously, the two would be considered equal
which would randomly place empty parts amongst non-empty ones. This
showed as a test 439 failure on Solaris as it uses a different
implementation of qsort() that compares parts differently.

Fixes #11855
Closes #11868
2023-09-16 08:35:16 -07:00
Harry Sintonen
3aa3cc9b05
misc: better random strings
Generate alphanumerical random strings.

Prior this change curl used to create random hex strings. This was
mostly okay, but having alphanumerical random strings is better: The
strings have more entropy in the same space.

The MIME multipart boundary used to be mere 64-bits of randomness due
to being 16 hex chars. With these changes the boundary is 22
alphanumerical chars, or little over 130 bits of randomness.

Closes #11838
2023-09-16 11:37:57 +02:00
Daniel Stenberg
f88cc654ec
cookie: reduce variable scope, add const 2023-09-15 22:09:43 +02:00
Daniel Stenberg
8c285a76ee
cookie: do not store the expire or max-age strings
Convert it to an expire time at once and save memory.

Closes #11862
2023-09-15 22:09:39 +02:00
Daniel Stenberg
61275672b4
cookie: remove unnecessary struct fields
Plus: reduce the hash table size from 256 to 63. It seems unlikely to
make much of a speed difference for most use cases but saves 1.5KB of
data per instance.

Closes #11862
2023-09-15 22:09:06 +02:00
Junho Choi
267e14f1ba quiche: fix build error with --with-ca-fallback
- Fix build error when curl is built with --with-quiche
  and --with-ca-fallback.

- Add --with-ca-fallback to the quiche CI job.

Fixes https://github.com/curl/curl/issues/11850
Closes https://github.com/curl/curl/pull/11847
2023-09-14 03:10:18 -04:00
Jay Satiro
7a2421dbb7 escape: replace Curl_isunreserved with ISUNRESERVED
- Use the ALLCAPS version of the macro so that it is clear a macro is
  being called that evaluates the variable multiple times.

- Also capitalize macro isurlpuntcs => ISURLPUNTCS since it evaluates
  a variable multiple times.

This is a follow-up to 291d225a which changed Curl_isunreserved into an
alias macro for ISUNRESERVED. The problem is the former is not easily
identified as a macro by the caller, which could lead to a bug.

For example, ISUNRESERVED(*foo++) is easily identifiable as wrong but
Curl_isunreserved(*foo++) is not even though they both are the same.

Closes https://github.com/curl/curl/pull/11846
2023-09-14 03:07:45 -04:00
Daniel Stenberg
291d225a50
ctype: add ISUNRESERVED()
... and make Curl_isunreserved() use that macro instead of providing a
separate funtion for the purpose.

Closes #11840
2023-09-13 14:29:44 +02:00
Thorsten Klein
a77a4a33c2
cmake: set SIZEOF_LONG_LONG in curl_config.h
in order to support 32bit builds regarding wolfssl CTC_SETTINGS

Closes #11839
2023-09-12 14:21:47 +02:00
Jay Satiro
ae5d433ecd curl_ngtcp2: fix error message 2023-09-12 03:14:16 -04:00
Jay Satiro
b5c65f8b7b http_aws_sigv4: handle no-value user header entries
- Handle user headers in format 'name:' and 'name;' with no value.

The former is used when the user wants to remove an internal libcurl
header and the latter is used when the user actually wants to send a
no-value header in the format 'name:' (note the semi-colon is converted
by libcurl to a colon).

Prior to this change the AWS header import code did not special case
either of those and the generated AWS SignedHeaders would be incorrect.

Reported-by: apparentorder@users.noreply.github.com

Ref: https://curl.se/docs/manpage.html#-H

Fixes https://github.com/curl/curl/issues/11664
Closes https://github.com/curl/curl/pull/11668
2023-09-11 15:24:05 -04:00
Daniel Stenberg
a1532a33b3
aws_sigv4: the query canon code miscounted URL encoded input
Added some extra ampersands to test 439 to verify "blank" query parts

Follow-up to fc76a24c53

Closes #11829
2023-09-11 08:17:39 +02:00
vvb2060
d5c562cd0d quic: don't set SNI if hostname is an IP address
We already do this for TLS connections.

RFC 6066 says: Literal IPv4 and IPv6 addresses are not permitted in
"HostName".

Ref: https://www.rfc-editor.org/rfc/rfc6066#section-3

Fixes https://github.com/curl/curl/issues/11827
Closes https://github.com/curl/curl/pull/11828
2023-09-11 02:14:23 -04:00
Daniel Stenberg
16bdc09ee0
http_aws_sigv4: skip the op if the query pair is zero bytes
Follow-up to fc76a24c53

Spotted by OSS-Fuzz

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62175
Closes #11823
2023-09-08 22:15:20 +02:00
Nathan Moinvaziri
f6700c744b schannel: fix ordering of cert chain info
- Use CERT_CONTEXT's pbCertEncoded to determine chain order.

CERT_CONTEXT from SECPKG_ATTR_REMOTE_CERT_CONTEXT contains
end-entity/server certificate in pbCertEncoded. We can use this pointer
to determine the order of certificates when enumerating hCertStore using
CertEnumCertificatesInStore.

This change is to help ensure that the ordering of the certificate chain
requested by the user via CURLINFO_CERTINFO has the same ordering on all
versions of Windows.

Prior to this change Schannel certificate order was reversed in 8986df80
but that was later reverted in f540a39b when it was discovered that
Windows 11 22H2 does the reversal on its own.

Ref: https://github.com/curl/curl/issues/9706

Closes https://github.com/curl/curl/pull/11632
2023-09-08 03:47:13 -04:00
Chris Talbot
7703ca7f86 digest: Use hostname to generate spn instead of realm
In https://www.rfc-editor.org/rfc/rfc2831#section-2.1.2

digest-uri-value should be serv-type "/" host , where host is:

      The DNS host name or IP address for the service requested.  The
      DNS host name must be the fully-qualified canonical name of the
      host. The DNS host name is the preferred form; see notes on server
      processing of the digest-uri.

Realm may not be the host, so we must specify the host explicitly.

Note this change only affects the non-SSPI digest code. The digest code
used by SSPI builds already uses the hostname to generate the spn.

Ref: https://github.com/curl/curl/issues/11369

Closes https://github.com/curl/curl/pull/11395
2023-09-08 03:23:44 -04:00
Daniel Stenberg
fc76a24c53
http_aws_sigv4: canonicalize the query
Percent encoding needs to be done using uppercase, and most
non-alphanumerical must be percent-encoded.

Fixes #11794
Reported-by: John Walker
Closes #11806
2023-09-07 17:50:13 +02:00
Wyatt O'Day
e92edfbef6
lib: add ability to disable auths individually
Both with configure and cmake

Closes #11490
2023-09-07 17:45:06 +02:00
Stefan Eissing
33dac9dfac
ngtcp2: fix handling of large requests
- requests >64K are send in parts to the filter
- fix parsing of the request to assemble it correctly
  from several sends
- open a QUIC stream only when the complete request has
  been collected

Closes #11815
2023-09-07 17:32:47 +02:00
Stefan Eissing
c849062677
openssl: when CURLOPT_SSL_CTX_FUNCTION is registered, init x509 store before
- we delay loading the x509 store to shorten the handshake time.
  However an application callback installed via CURLOPT_SSL_CTX_FUNCTION
  may need to have the store loaded and try to manipulate it.
- load the x509 store before invoking the app callback

Fixes #11800
Reported-by: guoxinvmware on github
Cloes #11805
2023-09-07 16:18:48 +02:00
Daniel Stenberg
25907fd5ba
krb5: fix "implicit conversion loses integer precision" warnings
conversions to/from enum and unsigned chars

Closes #11814
2023-09-07 16:17:13 +02:00
Stefan Eissing
3b30cc1a0d
pytest: improvements
- set CURL_CI for pytest runs in CI environments
- exclude timing sensitive tests from CI runs
- for failed results, list only the log and stat of
  the failed transfer

- fix type in http.c comment

Closes #11812
2023-09-07 10:30:14 +02:00
Viktor Szakats
c63a4b6544
http3: adjust cast for ngtcp2 v0.19.0
ngtcp2 v0.19.0 made size of `ecn` member of `ngtcp2_pkt_info`
an `uint8_t` (was: `uint32_t`). Adjust our local cast accordingly.

Fixes:
```
./curl/lib/vquic/curl_ngtcp2.c:1912:12: warning: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'uint8_t' (aka 'unsigned char') [-Wimplicit-int-conversion]
  pi.ecn = (uint32_t)ecn;
         ~ ^~~~~~~~~~~~~
```

Also bump ngtcp2, nghttp3 and nghttp2 to their latest versions in our
docs and CI.

Ref: 80447281bb
Ref: https://github.com/ngtcp2/ngtcp2/pull/877
Closes #11798
2023-09-05 15:25:37 +00:00
Stefan Eissing
2485547da0
http: fix sending of large requests
- refs #11342 where errors with git https interactions
  were observed
- problem was caused by 1st sends of size larger than 64KB
  which resulted in later retries of 64KB only
- limit sending of 1st block to 64KB
- adjust h2/h3 filters to cope with parsing the HTTP/1.1
  formatted request in chunks

- introducing Curl_nwrite() as companion to Curl_write()
  for the many cases where the sockindex is already known

Fixes #11342 (again)
Closes #11803
2023-09-05 16:36:03 +02:00
Viktor Szakats
3a6287d726
lib: silence compiler warning in inet_ntop6
```
./curl/lib/inet_ntop.c:121:21: warning: possible misuse of comma operator here [-Wcomma]
        cur.base = i, cur.len = 1;
                    ^
./curl/lib/inet_ntop.c:121:9: note: cast expression to void to silence warning
        cur.base = i, cur.len = 1;
        ^~~~~~~~~~~~
        (void)(     )
```

Closes #11790
2023-09-04 18:56:49 +00:00
Daniel Stenberg
95a865b462
transfer: also stop the sending on closed connection
Previously this cleared the receiving bit only but in some cases it is
also still sending (like a request-body) when disconnected and neither
direction can continue then.

Fixes #11769
Reported-by: Oleg Jukovec
Closes #11795
2023-09-04 19:51:59 +02:00
Stefan Eissing
519b1cf97b
multi: more efficient pollfd count for poll
- do not use separate pollfds for sockets that have POLLIN+POLLOUT

Closes #11792
2023-09-04 19:50:22 +02:00
Stefan Eissing
331b89a319
http2: polish things around POST
- added test cases for various code paths
- fixed handling of blocked write when stream had
  been closed inbetween attempts
- re-enabled DEBUGASSERT on send with smaller data size

- in debug builds, environment variables can be set to simulate a slow
  network when sending data. cf-socket.c and vquic.c support
  * CURL_DBG_SOCK_WBLOCK: percentage of send() calls that should be
    answered with a EAGAIN. TCP/UNIX sockets.
    This is chosen randomly.
  * CURL_DBG_SOCK_WPARTIAL: percentage of data that shall be written
    to the network. TCP/UNIX sockets.
    Example: 80 means a send with 1000 bytes would only send 800
    This is applied to every send.
  * CURL_DBG_QUIC_WBLOCK: percentage of send() calls that should be
    answered with EAGAIN. QUIC only.
    This is chosen randomly.

Closes #11756
2023-09-04 19:48:49 +02:00
Nicholas Nethercote
50aa325742
hyper: remove hyptransfer->endtask
`Curl_hyper_stream` needs to distinguish between two kinds of
`HYPER_TASK_EMPTY` tasks: (a) the `foreach` tasks it creates itself, and
(b) background tasks that hyper produces. It does this by recording the
address of any `foreach` task in `hyptransfer->endtask` before pushing
it into the executor, and then comparing that against the address of
tasks later polled out of the executor.

This works right now, but there is no guarantee from hyper that the
addresses are stable. `hyper_executor_push` says "The executor takes
ownership of the task, which should not be accessed again unless
returned back to the user with `hyper_executor_poll`". That wording is a
bit ambiguous but with my Rust programmer's hat on I read it as meaning
the task returned with `hyper_executor_poll` may be conceptually the
same as a task that was pushed, but that there are no other guarantees
and comparing addresses is a bad idea.

This commit instead uses `hyper_task_set_userdata` to mark the `foreach`
task with a `USERDATA_RESP_BODY` value which can then be checked for,
removing the need for `hyptransfer->endtask`. This makes the code look
more like that hyper C API examples, which use userdata for every task
and never look at task addresses.

Closes #11779
2023-09-03 18:42:37 +02:00
Nicholas Nethercote
73f4ef584f
hyper: fix a progress upload counter bug
`Curl_pgrsSetUploadCounter` should be a passed a total count, not an
increment.

This changes the failing diff for test 579 with hyper from this:
```
 Progress callback called with UL 0 out of 0[LF]
-Progress callback called with UL 8 out of 0[LF]
-Progress callback called with UL 16 out of 0[LF]
-Progress callback called with UL 26 out of 0[LF]
-Progress callback called with UL 61 out of 0[LF]
-Progress callback called with UL 66 out of 0[LF]
+Progress callback called with UL 29 out of 0[LF]
```
to this:
```
 Progress callback called with UL 0 out of 0[LF]
-Progress callback called with UL 8 out of 0[LF]
-Progress callback called with UL 16 out of 0[LF]
-Progress callback called with UL 26 out of 0[LF]
-Progress callback called with UL 61 out of 0[LF]
-Progress callback called with UL 66 out of 0[LF]
+Progress callback called with UL 40 out of 0[LF]
```
Presumably a step in the right direction.

Closes #11780
2023-09-01 14:44:12 +02:00
Daniel Stenberg
b8dabfb1e1
awssiv4: avoid freeing the date pointer on error
Since it was not allocated, don't free it even if it was wrong syntax

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61908

Follow-up to b137634ba3

Closes #11782
2023-09-01 13:36:10 +02:00
Viktor Szakats
26c7feb8b9
cmake: add support for CURL_DEFAULT_SSL_BACKEND
Allow overriding the default TLS backend via a CMake setting.

E.g.:
`cmake [...] -DCURL_DEFAULT_SSL_BACKEND=mbedtls`

Accepted values: bearssl, gnutls, mbedtls, openssl, rustls,
schannel, secure-transport, wolfssl

The passed string is baked into the curl/libcurl binaries.
The value is case-insensitive.

We added a similar option to autotools in 2017 via
c7170e20d0.

TODO: Convert to lowercase to improve reproducibility.

Closes #11774
2023-08-31 23:04:05 +00:00
Viktor Szakats
4727d32e2e
sectransp: fix compiler warnings
https://github.com/curl/curl-for-win/actions/runs/6037489221/job/16381860220#step:3:11046
```
/Users/runner/work/curl-for-win/curl-for-win/curl/lib/vtls/sectransp.c:2435:14: warning: unused variable 'success' [-Wunused-variable]
    OSStatus success;
             ^
/Users/runner/work/curl-for-win/curl-for-win/curl/lib/vtls/sectransp.c:3300:44: warning: unused parameter 'sha256len' [-Wunused-parameter]
                                    size_t sha256len)
                                           ^
```

Closes #11773
2023-08-31 23:02:43 +00:00
Viktor Szakats
ce3dce9015
tidy-up: mostly whitespace nits
- delete completed TODO from `./CMakeLists.txt`.
- convert a C++ comment to C89 in `./CMake/CurlTests.c`.
- delete duplicate EOLs from EOF.
- add missing EOL at EOF.
- delete whitespace at EOL (except from expected test results).
- convert tabs to spaces.
- convert CRLF EOLs to LF in GHA yaml.
- text casing fixes in `./CMakeLists.txt`.
- fix a codespell typo in `packages/OS400/initscript.sh`.

Closes #11772
2023-08-31 23:02:10 +00:00
Patrick Monnerat
6f8d9cc4e9
os400: implement CLI tool
This is provided as a QADRT (ascii) program, a link to it in the IFS and
a minimal CL command.

Closes #11547
2023-08-30 11:38:27 +02:00
Matthias Gatto
b137634ba3 lib: fix aws-sigv4 having date header twice in some cases
When the user was providing the header X-XXX-Date, the header was
re-added during signature computation, and we had it twice in the
request.

Reported-by: apparentorder@users.noreply.github.com

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>

Fixes: https://github.com/curl/curl/issues/11738
Closes: https://github.com/curl/curl/pull/11754
2023-08-30 03:41:29 -04:00
Jay Satiro
7f597ca12c multi: remove 'processing: <url>' debug message
- Remove debug message added by e024d566.

Closes https://github.com/curl/curl/pull/11759
2023-08-30 03:39:17 -04:00
Jay Satiro
2fe97dc274 ftp: fix temp write of ipv6 address
- During the check to differentiate between a port and IPv6 address
  without brackets, write the binary IPv6 address to an in6_addr.

Prior to this change the binary IPv6 address was erroneously written to
a sockaddr_in6 'sa6' when it should have been written to its in6_addr
member 'sin6_addr'. There's no fallout because no members of 'sa6' are
accessed before it is later overwritten.

Closes https://github.com/curl/curl/pull/11747
2023-08-30 03:22:07 -04:00
Jay Satiro
2fe26a7c6a hostip: fix typo 2023-08-29 17:08:23 -04:00
Daniel Stenberg
748da39b94
connect: stop halving the remaining timeout when less than 600 ms left
When curl wants to connect to a host, it always has a TIMEOUT. The
maximum time it is allowed to spend until a connect is confirmed.

curl will try to connect to each of the IP adresses returned for the
host. Two loops, one for each IP family.

During the connect loop, while curl has more than one IP address left to
try within a single address family, curl has traditionally allowed (time
left/2) for *this* connect attempt. This, to not get stuck on the
initial addresses in case the timeout but still allow later addresses to
get attempted.

This has the downside that when users set a very short timeout and the
host has a large number of IP addresses, the effective result might be
that every attempt gets a little too short time.

This change stop doing the divided-by-two if the total time left is
below a threshold. This threshold is 600 milliseconds.

Closes #11693
2023-08-29 10:43:26 +02:00
Daniel Stenberg
a181b4a053
asyn-ares: reduce timeout to 2000ms
When UDP packets get lost this makes for slightly faster retries. This
lower timeout is used by @c-ares itself by default starting next
release.

Closes #11753
2023-08-29 10:40:57 +02:00
John Bampton
7378f9cc32
misc: remove duplicate words
Closes #11740
2023-08-29 10:39:31 +02:00
Daniel Stenberg
c0998fa9a9
wolfSSL: avoid the OpenSSL compat API when not needed
... and instead call wolfSSL functions directly.

Closes #11752
2023-08-28 23:46:52 +02:00
Viktor Szakats
d50fe6becb
lib: fix null ptr derefs and uninitialized vars (h2/h3)
Fixing compiler warnings with gcc 13.2.0 in unity builds.

Assisted-by: Jay Satiro
Assisted-by: Stefan Eissing
Closes #11739
2023-08-28 19:47:14 +00:00
Daniel Stenberg
25ca79df1e
altsvc: accept and parse IPv6 addresses in response headers
Store numerical IPv6 addresses in the alt-svc file with the brackets
present.

Verify with test 437 and 438

Fixes #11737
Reported-by: oliverpool on github
Closes #11743
2023-08-28 17:08:42 +02:00
Nicholas Nethercote
9b84f274f1
hyper: fix ownership problems
Some of these changes come from comparing `Curl_http` and
`start_CONNECT`, which are similar, and adding things to them that are
present in one and missing in another.

The most important changes:
- In `start_CONNECT`, add a missing `hyper_clientconn_free` call on the
  happy path.
- In `start_CONNECT`, add a missing `hyper_request_free` on the error
  path.
- In `bodysend`, add a missing `hyper_body_free` on an early-exit path.
- In `bodysend`, remove an unnecessary `hyper_body_free` on a different
  error path that would cause a double-free.
  https://docs.rs/hyper/latest/hyper/ffi/fn.hyper_request_set_body.html
  says of `hyper_request_set_body`: "This takes ownership of the
  hyper_body *, you must not use it or free it after setting it on the
  request." This is true even if `hyper_request_set_body` returns an
  error; I confirmed this by looking at the hyper source code.

Other changes are minor but make things slightly nicer.

Closes #11745
2023-08-28 11:06:15 +02:00
John Hawthorn
6d44625305
OpenSSL: clear error queue after SSL_shutdown
We've seen errors left in the OpenSSL error queue (specifically,
"shutdown while in init") by adding some logging it revealed that the
source was this file.

Since we call SSL_read and SSL_shutdown here, but don't check the return
code for an error, we should clear the OpenSSL error queue in case one
was raised.

This didn't affect curl because we call ERR_clear_error before every
write operation (a0dd9df9ab), but when
libcurl is used in a process with other OpenSSL users, they may detect
an OpenSSL error pushed by libcurl's SSL_shutdown as if it was their
own.

Co-authored-by: Satana de Sant'Ana <satana@skylittlesystem.org>

Closes #11736
2023-08-26 19:36:40 +02:00
John Bampton
bc7c4996f1
misc: fix spelling
Closes #11733
2023-08-25 20:54:14 +02:00
Nicholas Nethercote
e854166472
c-hyper: fix another memory leak in Curl_http.
There is a `hyper_clientconn_free` call on the happy path, but not one
on the error path. This commit adds one.

Fixes the second memory leak reported by Valgrind in #10803.

Fixes #10803
Closes #11729
2023-08-25 15:27:22 +02:00
Nicholas Nethercote
c61dd5fed2
c-hyper: fix a memory leak in Curl_http.
A request created with `hyper_request_new` must be consumed by either
`hyper_clientconn_send` or `hyper_request_free`.

This is not terrifically clear from the hyper docs --
`hyper_request_free` is documented only with "Free an HTTP request if
not going to send it on a client" -- but a perusal of the hyper code
confirms it.

This commit adds a `hyper_request_free` to the `error:` path in
`Curl_http` so that the request is consumed when an error occurs after
the request is created but before it is sent.

Fixes the first memory leak reported by Valgrind in #10803.

Closes #11729
2023-08-25 15:27:11 +02:00
John Bampton
fb3180a024
misc: spellfixes
Closes #11730
2023-08-25 13:21:07 +02:00
Daniel Stenberg
2ff7cd75c7
lib: minor comment corrections 2023-08-24 10:02:23 +02:00
Daniel Stenberg
887b998e6e
urlapi: setting a blank URL ("") is not an ok URL
Test it in 1560
Fixes #11714
Reported-by: ad0p on github
Closes #11715
2023-08-23 23:24:16 +02:00
Daniel Stenberg
5e2beb3395
spelling: use 'reuse' not 're-use' in code and elsewhere
Unify the spelling as both versions were previously used intermittently

Closes #11717
2023-08-23 23:22:36 +02:00
Dan Fandrich
86179afcbb http: close the connection after a late 417 is received
In this situation, only part of the data has been sent before aborting
so the connection is no longer usable.

Assisted-by: Jay Satiro
Fixes #11678
Closes #11679
2023-08-22 15:32:16 -07:00
Daniel Stenberg
74b87a8af1
lib: move mimepost data from ->req.p.http to ->state
When the legacy CURLOPT_HTTPPOST option is used, it gets converted into
the modem mimpost struct at first use. This data is (now) kept for the
entire transfer and not only per single HTTP request. This re-enables
rewind in the beginning of the second request instead of in end of the
first, as brought by 1b39731.

The request struct is per-request data only.

Extend test 650 to verify.

Fixes #11680
Reported-by: yushicheng7788 on github
Closes #11682
2023-08-17 23:49:57 +02:00
Daniel Stenberg
e67718eef7
lib: --disable-bindlocal builds curl without local binding support 2023-08-17 17:17:59 +02:00
Daniel Stenberg
acca40c9b5
lib: build fixups when built with most things disabled
Closes #11687
2023-08-17 17:17:54 +02:00
Stefan Eissing
1bccee76c8
bearssl: handshake fix, provide proper get_select_socks() implementation
- bring bearssl handshake times down from +200ms down to other TLS backends
- vtls: improve generic get_select_socks() implementation
- tests: provide Apache with a suitable ssl session cache

Closes #11675
2023-08-17 13:45:08 +02:00
Daniel Stenberg
a281057091
urlapi: return CURLUE_BAD_HOSTNAME if puny2idn encoding fails
And document it. Only return out of memory when it actually is a memory
problem.

Pointed-out-by: Jacob Mealey
Closes #11674
2023-08-17 08:21:08 +02:00
Daniel Stenberg
be21769cc7
http: remove the p_pragma struct field
unused since 40e8b4e52 (2008)

Closes #11681
2023-08-16 11:01:10 +02:00
Daniel Stenberg
ab3b2c47bd
transfer: don't set TIMER_STARTTRANSFER on first send
The time stamp is for measuring the first *received* byte

Fixes #11669
Reported-by: JazJas on github
Closes #11670
2023-08-15 14:52:01 +02:00
trrui-huawei
23c3dc20c1
quiche: enable quiche to handle timeout events
In parallel with ngtcp2, quiche also offers the `quiche_conn_on_timeout`
interface for the application to invoke upon timer
expiration. Therefore, invoking the `on_timeout` function of the
Connection is crucial to ensure seamless functionality of quiche with
timeout events.

Closes #11654
2023-08-15 14:38:31 +02:00
trrui-huawei
bcc51b76c5
quiche: adjust quiche QUIC_IDLE_TIMEOUT to 60s
Set the `QUIC_IDLE_TIMEOUT` parameter to match ngtcp2 for consistency.
2023-08-15 14:37:54 +02:00
Daniel Stenberg
8a86ccf343
imap: add a check for failing strdup() 2023-08-14 18:07:12 +02:00
Daniel Stenberg
91765104c2
imap: remove the only sscanf() call in the IMAP code
Avoids the use of a stack buffer.

Closes #11673
2023-08-14 18:07:12 +02:00
Daniel Stenberg
de5f66595e
imap: use a dynbuf in imap_atom
Avoid a calculation + malloc. Build the output in a dynbuf.

Closes #11672
2023-08-14 15:56:11 +02:00
Marin Hannache
67e9e3cb1e
http: do not require a user name when using CURLAUTH_NEGOTIATE
In order to get Negotiate (SPNEGO) authentication to work in HTTP you
used to be required to provide a (fake) user name (this concerned both
curl and the lib) because the code wrongly only considered
authentication if there was a user name provided, as in:

  curl -u : --negotiate https://example.com/

This commit leverages the `struct auth` want member to figure out if the
user enabled CURLAUTH_NEGOTIATE, effectively removing the requirement of
setting a user name both in curl and the lib.

Signed-off-by: Marin Hannache <git@mareo.fr>
Reported-by: Enrico Scholz
Fixes https://sourceforge.net/p/curl/bugs/440/
Fixes #1161
Closes #9047
2023-08-14 10:21:46 +02:00
Daniel Stenberg
c350069f64
urlapi: CURLU_PUNY2IDN - convert from punycode to IDN name
Asssisted-by: Jay Satiro
Closes #11655
2023-08-13 15:34:38 +02:00
Jay Satiro
889c071d3c schannel: verify hostname independent of verify cert
Prior to this change when CURLOPT_SSL_VERIFYPEER (verifypeer) was off
and CURLOPT_SSL_VERIFYHOST (verifyhost) was on we did not verify the
hostname in schannel code.

This fixes KNOWN_BUG 2.8 "Schannel disable CURLOPT_SSL_VERIFYPEER and
verify hostname". We discussed a fix several years ago in #3285 but it
went stale.

Assisted-by: Daniel Stenberg

Bug: https://curl.haxx.se/mail/lib-2018-10/0113.html
Reported-by: Martin Galvan

Ref: https://github.com/curl/curl/pull/3285

Fixes https://github.com/curl/curl/issues/3284
Closes https://github.com/curl/curl/pull/10056
2023-08-11 12:27:18 -04:00
Daniel Stenberg
c7056759be
curl_quiche: remove superfluous NULL check
'stream' is always non-NULL at this point

Pointed out by Coverity

Closes #11656
2023-08-11 11:43:17 +02:00
Viktor Szakats
fc9bfb1452
cmake: allow SHARE_LIB_OBJECT=ON on all platforms
2ebc74c36a #11546 introduced sharing
libcurl objects for shared and static targets.

The above automatically enabled for Windows builds, with an option to
disable with `SHARE_LIB_OBJECT=OFF`.

This patch extend this feature to all platforms as a manual option.
You can enable it by setting `SHARE_LIB_OBJECT=ON`. Then shared objects
are built in PIC mode, meaning the static lib will also have PIC code.

[EXPERIMENTAL]

Closes #11627
2023-08-09 12:01:07 +00:00
Daniel Stenberg
850f6c79e8
c-hyper: adjust the hyper to curlcode conversion
Closes #11621
2023-08-08 23:27:42 +02:00
Daniel Stenberg
f0fed4e131
cf-haproxy: make CURLOPT_HAPROXY_CLIENT_IP set the *source* IP
... as documented.

Update test 3201 and 3202 accordingly.

Reported-by: Markus Sommer
Fixes #11619
Closes #11626
2023-08-08 17:05:24 +02:00
Stefan Eissing
d7eafb1d55
http3: quiche, handshake optimization, trace cleanup
- load x509 store after clienthello
- cleanup of tracing

Closes #11618
2023-08-08 16:33:53 +02:00
Daniel Stenberg
9bca45dba8
ngtcp2: remove dead code
'result' is always zero (CURLE_OK) at this point

Detected by Coverity

Closes #11622
2023-08-08 12:29:48 +02:00
Viktor Szakats
00a70cca74
openssl: auto-detect SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED
OpenSSL 1.1.1 defines this macro, but no ealier version, or any of the
popular forks (yet). Use the macro itself to detect its presence,
replacing the hard-wired fork-specific conditions.

This way the feature will enable automatically when forks implement it,
while also shorter and possibly requiring less future maintenance.

Follow-up to 94241a9e78 #6721

Reviewed-by: Jay Satiro
Closes #11617
2023-08-08 09:10:04 +00:00
Viktor Szakats
b0bb86c1e9
openssl: use SSL_CTX_set_ciphersuites with LibreSSL 3.4.1
LibreSSL 3.4.1 (2021-10-14) added support for
`SSL_CTX_set_ciphersuites`.

Ref: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.1-relnotes.txt

Reviewed-by: Jay Satiro
Closes #11616
2023-08-08 09:10:04 +00:00
Viktor Szakats
e43474b472
openssl: use SSL_CTX_set_keylog_callback with LibreSSL 3.5.0
LibreSSL 3.5.0 (2022-02-24) added support for
`SSL_CTX_set_keylog_callback`.

Ref: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.5.0-relnotes.txt

Reviewed-by: Jay Satiro
Closes #11615
2023-08-08 09:10:04 +00:00
Daniel Gustafsson
22eb9893bc
crypto: ensure crypto initialization works
Make sure that context initialization during hash setup works to avoid
going forward with the risk of a null pointer dereference.

Reported-by: Philippe Antoine on HackerOne
Assisted-by: Jay Satiro
Assisted-by: Daniel Stenberg

Closes #11614
2023-08-08 10:44:01 +02:00
Viktor Szakats
bec0c5bbf3
openssl: switch to modern init for LibreSSL 2.7.0+
LibreSSL 2.7.0 (2018-03-21) introduced automatic initialization,
`OPENSSL_init_ssl()` function and deprecated the old, manual init
method, as seen in OpenSSL 1.1.0. Switch to the modern method when
available.

Ref: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.0-relnotes.txt

Reviewed-by: Daniel Stenberg
Closes #11611
2023-08-07 23:55:58 +00:00
Daniel Stenberg
78d6232f1f
gskit: remove
We remove support for building curl with gskit.

 - This is a niche TLS library, only running on some IBM systems
 - no regular curl contributors use this backend
 - no CI builds use or verify this backend
 - gskit, or the curl adaption for it, lacks many modern TLS features
   making it an inferior solution
 - build breakages in this code take weeks or more to get detected
 - fixing gskit code is mostly done "flying blind"

This removal has been advertized in DEPRECATED in Jan 2, 2023 and it has
been mentioned on the curl-library mailing list.

It could be brought back, this is not a ban. Given proper effort and
will, gskit support is welcome back into the curl TLS backend family.

Closes #11460
2023-08-07 20:57:48 +02:00
Stefan Eissing
199fb4b94a
http3/ngtcp2: shorten handshake, trace cleanup
- shorten handshake timing by delayed x509 store load (OpenSSL)
  as we do for HTTP/2
- cleanup of trace output, align with HTTP/2 output

Closes #11609
2023-08-07 17:13:52 +02:00
Daniel Stenberg
95ca3c53d3
headers: accept leading whitespaces on first response header
This is a bad header fold but since the popular browsers accept this
violation, so does curl now. Unless built with hyper.

Add test 1473 to verify and adjust test 2306.

Reported-by: junsik on github
Fixes #11605
Closes #11607
2023-08-07 12:45:45 +02:00
Daniel Stenberg
80ea7f7fc2
cf-socket: log successful interface bind
When the setsockopt SO_BINDTODEVICE operation succeeds, output that in
the verbose output.

Ref: #11599
Closes #11608
2023-08-07 10:42:37 +02:00
Stefan Eissing
fbacb14c4c
http2: cleanup trace messages
- more compact format with bracketed stream id
- all frames traced in and out

Closes #11592
2023-08-06 17:47:38 +02:00
Daniel Stenberg
83319e0271
pingpong: don't use *bump_headersize
We use that for HTTP(S) only.

Follow-up to 3ee79c1674

Closes #11590
2023-08-04 11:06:39 +02:00
Daniel Stenberg
8a9f4d481a
urldata: remove spurious parenthesis to unbreak no-proxy build
Follow-up to e12b39e133

Closes #11591
2023-08-04 11:04:24 +02:00
Daniel Stenberg
c15569bb41
easy: don't call Curl_trc_opt() in disabled-verbose builds
Follow-up to e12b39e133

Closes #11588
2023-08-04 10:07:57 +02:00
Daniel Stenberg
a2a894f550
http: use %u for printfing int
Follow-up to 3ee79c1674

Closes #11587
2023-08-04 09:34:44 +02:00
Goro FUJI
ae91bb7e1a
vquic: show stringified messages for errno
Closes #11584
2023-08-03 22:44:36 +02:00