Commit Graph

15652 Commits

Author SHA1 Message Date
Daniel Stenberg
6d7e924e80
checksrc.pl: detect assign followed by more than one space
And fix some code previously doing this.

Closes #19375
2025-11-05 15:18:28 +01:00
Daniel Stenberg
a8bef39036
openssl: remove code handling default version
Since it is no longer actually kept as default internally, that's just
dead code.

Follow-up to 9d8998c994
Closes #19354
2025-11-05 14:14:58 +01:00
x2018
2db36f11b8
gtls: add return checks and optimize the code
This commit does the following things:

1. Update the description of gtls_init()

2. In gtls_client_init(), check the invaild SSLVERSION at first. Note
   that this part refactors the duplicate/incompatible checks and removes
   the useless local variable `sni`.

3. Check the return value of gnutls_ocsp_resp_init(). Although the
   original code is safe because gnutls_ocsp_resp_import() will check
   the validity of `ocsp_resp`, it is better to catch the error in time
   and record the proper message to output log.

Closes #19366
2025-11-05 14:09:34 +01:00
x2018
dd71f61ea2
lib: cleanup for some typos about spaces and code style
Closes #19370
2025-11-05 14:07:28 +01:00
x2018
8d4530537a
gtls: check the return value of gnutls_pubkey_init()
Closes #19362
2025-11-04 17:00:52 +01:00
Joshua Rogers
feab390124
rtsp: use explicit postfieldsize if specified
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Closes #19345
2025-11-03 22:27:16 +01:00
x2018
6adefe8ad0
multi: check the return value of strdup()
Closes #19344
2025-11-03 20:19:36 +01:00
x2018
231f0a2eec
http: check the return value of strdup
Closes #19343
2025-11-03 20:17:41 +01:00
Joshua Rogers
0d5e24281d
vtls: check final cfilter node in find_ssl_filter
find_ssl_filter used while(cf && cf->next) and skipped the last node.
If the SSL filter was last, channel binding lookup failed and we returned
CURLE_BAD_FUNCTION_ARGUMENT. Switch to while(cf) so the tail is examined.

This bug was found with ZeroPath.

Closes #19229
2025-11-03 18:21:57 +01:00
Devdatta Talele
8616e5aada
gssapi: make channel binding conditional on GSS_C_CHANNEL_BOUND_FLAG
Fixes #19109 - GSSAPI authentication fails on macOS with Apple's Heimdal
implementation which lacks GSS_C_CHANNEL_BOUND_FLAG support for TLS
channel binding.

Commit 0a5ea09a91 introduced TLS channel binding for SPNEGO/GSSAPI
authentication unconditionally, but Apple's Heimdal fork (used on macOS)
does not support this feature, causing "unsupported mechanism" errors
when authenticating to corporate HTTP services with Kerberos.

Solution:
- Add CURL_GSSAPI_HAS_CHANNEL_BINDING detection in curl_gssapi.h based
  on GSS_C_CHANNEL_BOUND_FLAG presence (MIT Kerberos >= 1.19)
- Make negotiatedata.channel_binding_data field conditional in vauth.h
- Guard channel binding collection/cleanup in http_negotiate.c
- Guard channel binding usage in spnego_gssapi.c

This follows the same pattern as GSS_C_DELEG_POLICY_FLAG detection and
ensures graceful degradation when channel binding is unavailable while
maintaining full support for implementations that have it.

Changes:
- lib/curl_gssapi.h: Add feature detection macro
- lib/vauth/vauth.h: Make struct field conditional
- lib/http_negotiate.c: Conditional init/cleanup (2 locations)
- lib/vauth/spnego_gssapi.c: Conditional channel binding usage

Tested on macOS with Apple Heimdal (no channel binding) and Linux with
MIT Kerberos (with channel binding). Both configurations authenticate
successfully without errors.

Closes #19164
2025-11-03 18:16:54 +01:00
Stefan Eissing
cccc65f051
openssl: check CURL_SSLVERSION_MAX_DEFAULT properly
The definition of these constants does not give a numeric ordering
and MAX_DEFAULT needs to be checked in addition of ciphers and QUIC
checks to apply correctly.

Fixes #19340
Reported-by: Peter Piekarski
Closes #19341
2025-11-03 16:31:22 +01:00
Stefan Eissing
7e91f24c73
cw-out: fix EAGAIN handling on pause
The interim CURLE_AGAIN result was not always converted to a
CURLE_OK and then caused write callers to report a failure.

Fixes #19334
Reported-by: pennae on github
Closes #19338
2025-11-03 16:10:20 +01:00
Daniel Stenberg
c1e3a760ba
imap: avoid integer overflow
Follow-up to e64c28e243

Spotted by OSS-Fuzz

Closes #19332
2025-11-03 08:54:51 +01:00
x2018
c898da26c6
http_aws_sigv4: check the return value of curl_maprintf()
Closes #9328
2025-11-02 23:04:24 +01:00
x2018
e2a12fcbdb
vtls: properly handle SSL shutdown timeout
Closes #19323
2025-11-01 23:28:40 +01:00
x2018
f6bbc2b3be
doh: cleanup resources on error paths
Closes #19310
2025-11-01 23:14:33 +01:00
Daniel Stenberg
8d0bfe74fb
httpsrr: send HTTPS query to the right target
When the target host is on a different port than 443, the name
"_[port]._https.[name]" shall be used.

Fixes #19301
Reported-by: Gunni on github
Closes #19324
2025-11-01 23:13:30 +01:00
x2018
27f55383fb
schannel: properly close the certfile on error
Closes #19304
2025-10-31 23:27:06 +01:00
Daniel Stenberg
d4d7139e70
openssl: combine all the x509-store flags
... intead of overwriting the previous ones in ossl_populate_x509_store()

Pointed out by ZeroPath

Closes #19306
2025-10-31 23:24:38 +01:00
Stefan Eissing
b4630ed8fa
sectrust: fix verifystatus via sectrust
When openssl does not verify the certificate, but apple sectrust
does, we also pass it the ocsp stapled response when configured and
available.

When openssl does not verify the cert chain, it will also not be able
to verify the ocsp stapling. Do not call it if sectrust is the
verifier of the cert chain.

Fixes #19307
Reported-by: Harry Sintonen
Closes #19308
2025-10-31 23:10:35 +01:00
Daniel Stenberg
d646d5a130
openssl: fix the ocsp len arg to Curl_vtls_apple_verify
If it has no data, pass in a zero.

Fixes #19303
Reported-by: Harry Sintonen
Closes #19305
2025-10-31 23:09:05 +01:00
Viktor Szakats
9c0b239ec1
spelling: fix new finds by typos-cli 1.39.0
Closes #19312
2025-10-31 21:31:32 +01:00
Stefan Eissing
1e85cb4b7b
scp/sftp: fix disconnect
When a SCP/SFTP connection calls the protocol handler disconnect, it
required the connections *and* the easy handles SSH meta data to be
present. When the disconnect is called with an admin handle, the easy
meta data is not present, which prevented the shutdown to run.

The easy meta data is however not necessary to run the shutdown state
machine. Calling it with a NULL `sshp` is fine. To avoid any mixups,
check `sshp` in state operations that need it.

Fixes #19293
Reported-by: And-yW on github
Closes #19295
2025-10-31 15:56:58 +01:00
Viktor Szakats
5bf9445315
ftp: fix leaking internal buffer newhost on error
Pointed out by TIOBE scanner via Coverity 2025.3.0.

Closes #19290
2025-10-31 13:14:09 +01:00
Daniel Stenberg
c5de083bcc
base64: make base64_encode() error on too long input
The maximum size is set to 16MB.

It should not possible to call this function with this large input, but
this is a precaution to catch mistakes and replaces the earlier check on
architectures with small size_t.

Closes #19280
2025-10-30 15:41:28 +01:00
Daniel Stenberg
80258309b2
lib: reduce memcpy calls
socks_gssapi: the malloc + memcpy was superflous and can be skipped

cleartext: avoid malloc + three memcpy with aprintf()

digest_sspi: use memdup0 instead of malloc + memcpy

vtls: use memdup0 instead of malloc + memcpy

Closes #19282
2025-10-30 15:40:21 +01:00
x2018
fbc4d59151
conncache: prevent integer overflow in maxconnects calculation
Closes #19271
2025-10-30 10:38:32 +01:00
Daniel Stenberg
c1f1b66d78
pop3: check for CAPA responses case insensitively
Reported by ZeroPath

Closes #19278
2025-10-30 10:34:08 +01:00
TheBitBrine
e64c28e243
imap: fix custom FETCH commands to handle literal responses
Custom IMAP commands using -X (e.g. 'FETCH 123 BODY[1]') were only
returning the first line of responses containing literals, instead of
the full multi-line body data.

The issue was that custom commands route through imap_perform_list()
and imap_state_listsearch_resp(), which didn't detect or handle IMAP
literal syntax {size}.

This commit adds literal detection to imap_state_listsearch_resp():
- Detects literal syntax {size} in untagged responses
- Writes the response header line containing the literal marker
- Handles any literal body data already in the pingpong buffer
- Sets up transfer layer to read remaining literal data from socket
- Configures maxdownload and transfer size to include header + body
- Initializes pp->overflow to 0 when no buffered data present
- Modifies imap_done() to transition to FETCH_FINAL for custom
  commands that set up downloads

Test 841 and 3206 verify.

Fixes #18847
Reported-by: BohwaZ
Bug: https://github.com/curl/curl/issues/18847
Closes #19246
2025-10-30 08:48:28 +01:00
Viktor Szakats
25aee8648a
http: fix -Wunused-variable in !alt-svc !proxy !ws builds
```
lib/http.c:2783:23: error: unused variable 'conn' [-Werror,-Wunused-variable]
 2783 |   struct connectdata *conn = data->conn;
      |                       ^~~~
1 error generated.
```

Closes #19276
2025-10-29 16:17:35 +01:00
Viktor Szakats
7973cb0b3e
http: fix -Wunreachable-code in !websockets !unity builds
Also requires non-unity build. Possibly more non-default options are
necessary to reproduce. Seen with llvm/clang.

```
lib/http.c:1856:15: error: code will never be executed [-Werror,-Wunreachable-code]
 1856 |     httpreq = HTTPREQ_GET;
      |               ^~~~~~~~~~~
1 error generated.
```

Closes #19275
2025-10-29 16:17:34 +01:00
Stefan Eissing
446dae5bfe
ngtcp2: overwrite rate-limits defaults
In pytests test_08 with the Caddy server, the new rate-limiting in
ngtcp2 did close the connection because it found "too many" stream data
packet repeats.

It is unclear if this is some Caddy issue or if the ngtcp2 implementaton
is wrong. Or if curl can do anything here.

Reported as https://github.com/ngtcp2/ngtcp2/issues/1850

This PR overwrites the ratelimit defaults in ngtcp2 with ten times
increased values. This makes the errors disappear on macOS.

Enable test_08_04/05 in CI again to see if there are any issues
to be found there. (We had those disabled before having parallel
pytests.)

Closes #19274
2025-10-29 13:34:27 +01:00
Daniel Stenberg
a97f9d41cc
openldap/ldap; check for binary attribute case insensitively
This bug was found with ZeroPath

Fixes #19240
Reported-by: Joshua Rogers
Closes #19273
2025-10-29 10:03:35 +01:00
Stefan Eissing
c82a70628d ssl-session-cache: check use on config and availability
Replace the check if a ssl session cache is configured with
a function checking if it is configured *and* if an ssl session
cache is available.

During normal operations, a session cache is always there, however
for "connect-only" transfers this might not be the case. When such
transfers receive new sessions/tickets, they need to silently
discard those and not fail.

Reported-by: Marc Aldorasi

Fixes https://github.com/curl/curl/issues/18983
Closes https://github.com/curl/curl/pull/19251
2025-10-29 03:07:59 -04:00
Daniel Stenberg
875ea98c36
schannel: handle Curl_conn_cf_send() errors better
Avoid a resource leak in the error path.

Reported-by: Joshua Rogers

Closes #19265
2025-10-28 23:26:33 +01:00
Daniel Stenberg
9308ea22e8
cookie: remove the temporary file on (all) errors
Fixes #19267
Reported-by: Harry Sintonen
Closes #19268
2025-10-28 16:51:30 +01:00
x2018
02113a6307
Curl_resolv: explicitly set *entry to NULL at the top
Closes #19263
2025-10-28 11:39:13 +01:00
Stefan Eissing
692c7f133e
TLS: IP address verification, extend test
Change the test certificate to carry a altname 'dns:127.0.0.1' which
should *not* match in test_17_05_bad_ip_addr.

wolfSSL: since `wolfSSL_check_domain_name()` does not differentiate
between DNS and IP names, use if only for DNS names. For IP addresses,
get the peer certificate after the handshake and check that using
wolfSSL_X509_check_ip_asc().

Unfortunately, this succeeds where it should not, as wolfSSL internally
used the same check code for both cases. So, skip the test case until
wolfSSL fixes that.

Reported-by: Joshua Rogers
Closes #19252
2025-10-27 17:22:17 +01:00
Daniel Stenberg
2bb33c18a7
pingpong: change repsonse timeout to one minute
It was previously two minutes by default and sometimes one minute.
Removes a struct field.

Closes #19254
2025-10-27 16:33:30 +01:00
x2018
6c97ff8c12
socks: properly maintain the status of 'done'
Closes #19255
2025-10-27 16:31:37 +01:00
Daniel Stenberg
cdd945e486
http_proxy: fix adding custom proxy headers
Reported-by: Joshua Rogers
Fixes #19227
Closes #19239
2025-10-27 09:52:00 +01:00
TheBitBrine
a49e4e3d16
pop3: fix CAPA response termination detection
The code was checking if a line starts with '.', which would
incorrectly match capability names starting with dots. Per RFC 2449,
the terminator must be a line containing only a single dot.

RFC 2449 also explicitly excludes '.' from valid capability name
starting characters, so this is purely theoretical, but the code
should match the spec.

Changed to check for exact match: line length of 3 with '.\r' or
length 2 with '.\n' to handle both CRLF and LF-only servers.

(Mistake detected with ZeroPath)

Fixes #19228
Reported-by: Joshua Rogers
Closes #19245
2025-10-26 10:59:20 +01:00
Viktor Szakats
4f03e3fcbd
socks_gssapi: also reset buffer length after free
To mimic this behavior of the previously used `gss_release_buffer()`.

Some or all of these zero assignments may be redundant.

Follow-up to e7818999db #19018

Closes #19167
2025-10-26 01:52:41 +02:00
Daniel Stenberg
3e12ed955b
schannel: lower the maximum allowed time to block to 7 seconds
During TLS renegotiation, the schannel_recv_renegotiate() function is
allowed to block for a short while. Reduce the maximum allowed time to
block from 10 minutes down to 7 seconds.

Closes #19205
2025-10-25 17:52:29 +02:00
Viktor Szakats
a13d811044
lib: delete unused header includes
`escape.h`, `getinfo.h`, `strdup.h`.

Tested OK with full non-unity CI run.

Closes #19231
2025-10-25 00:19:00 +02:00
Viktor Szakats
71d1eec675
tidy-up: miscellaneous
- cmake/Find*: make double quotes consistent.
- drop redundant parenthesis.
- GHA/checksrc: sync a step name with others.
- whitespace.

Closes #19233
2025-10-25 00:19:00 +02:00
Viktor Szakats
543b78652a
curl_ngtcp2: fix -Wunreachable-code with H3 !verbose !unity clang
Not tested in default CI.

macOS / CM clang OpenSSL gsasl rtmp AppleIDN SecTrust +examples,
macOS / CM llvm@18 OpenSSL gsasl rtmp AppleIDN SecTrust +examples:
```
lib/vquic/curl_ngtcp2.c:530:5: error: code will never be executed [-Werror,-Wunreachable-code]
  530 |     const ngtcp2_transport_params *rp;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
Ref: https://github.com/curl/curl/actions/runs/18787154442/job/53608230871?pr=19225#step:11:183

Confirmed fixed via #19225
Closes #19226
2025-10-24 22:53:26 +02:00
Viktor Szakats
3fc727751f
lib: delete unused crypto header includes
Tested OK with full non-unity CI run.

Closes #19225
2025-10-24 22:53:26 +02:00
Viktor Szakats
833da09b53
vtls: drop duplicate CURL_SHA256_DIGEST_LENGTH definition
Closes #19224
2025-10-24 19:16:53 +02:00
Viktor Szakats
207a74206b
mbedtls: fix building with sha-256 missing from PSA
Fixing:
```
lib/vtls/mbedtls.c:1505:10: error: call to undeclared function 'Curl_sha256it'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1505 |   return Curl_sha256it(sha256sum, input, inputlen);
      |          ^
1 error generated.
```

with mbedTLS configuration:
```
tf-psa-crypto/scripts/config.py unset PSA_WANT_ALG_SHA_256
tf-psa-crypto/scripts/config.py unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
tf-psa-crypto/scripts/config.py unset MBEDTLS_LMS_C
```

Follow-up to 3a305831d1 #19077

Closes #19223
2025-10-24 19:14:28 +02:00