Commit graph

15498 commits

Author SHA1 Message Date
Stefan Eissing
a4d3c4e847
ws: fix some edge cases
Fix edge cases around handling of pending send frames and encoding
frames with size_t/curl_off_t possible flowy things.

Reported-by: Joshua Rogers
Closes #18965
2025-10-10 23:42:29 +02:00
Stefan Eissing
4cc476b37f
gnutls: check conversion of peer cert chain
Check the result when converting the peer certificate chain
into gnutls internal x590 data structure for errors.

Reported-by: Joshua Rogers
Closes #18964
2025-10-10 23:41:31 +02:00
Stefan Eissing
7fecc009ea
socks: advance iobuf instead of reset
During the SOCKS connect phase, the `iobuf` is used to receive repsonses
from the server. If the server sends more bytes than expected, the code
discarded them silently.

Fix this by advancing the iobuf only with the length consumed.

Reported-by: Joshua Rogers

Closes #18938
2025-10-10 23:40:12 +02:00
Viktor Szakats
0855f30709
kerberos: bump minimum to 1.3 (2003-07-08), drop legacy logic
Previous minimum was: 1.2.4 (2002-02-28)

- assume `gssapi/gssapi.h` header for MIT Kerberos.

  Drop logic detecting this header, and drop alternate logic including
  a bare "gssapi.h". Bare `gssapi.h` is Heimdal-specific. MIT Kerberos
  added support for it for Heimdal compatibility on 2006-11-09,
  redirecting to `gssapi/gssapi.h`. MIT Kerberos supported the latter
  header in the 1990s already.

  Ref: 40e1a016f9 (2008-03-06)
  Ref: d119352001 (2006-11-09)

- configure.ac: stop using `HAVE_GSSAPI_GSSAPI_H`.

  Added in 2010 to support "ancient distros such as RHEL-3" where
  `gssapi/gssapi_krb5.h` did not include `gssapi/gssapi.h`.

  MIT Kerberos includes it since commit:
  d9e959edfa (2003-03-06)
  Released in 1.3 (2003-07-08).

  Bump minimum required version to avoid this issue.

  Reverts cca192e58f (2010-04-16)

Ref: https://web.mit.edu/kerberos/dist/historic.html
Ref: https://sources.debian.org/src/krb5/

Closes #18992
2025-10-10 19:47:08 +02:00
Viktor Szakats
9442dd480e
GHA/linux: test GNU GSS with autotools, cmake, valgrind and scan-build
The cmake build is running runtests with valgrind. The autotools one is
running scan-build.

Also:
- ignore two memleaks with GNU GSS detected by valgrind.
- add comment on support status of `GSS_C_DELEG_POLICY_FLAG`.

Closes #19008
2025-10-10 17:33:17 +02:00
Viktor Szakats
e5950b2d37
kerberos: stop including gssapi/gssapi_generic.h
It's a legacy MIT Kerberos header that's no longer used by curl since:
355bf01c82 (2015-01-09)

There were still mentions of it after this patch, when using versions
<1.2.3, but those versions aren't supported since:
9918541795 (2008-06-12)

This header remains in use by autotools and cmake to detect MIT Kerberos
(vs. Heimdal, which doesn't have it.)

Ref: https://github.com/curl/curl/pull/18978#issuecomment-3387414995

Closes #18990
2025-10-10 13:59:19 +02:00
Daniel Stenberg
c049c37acd
libssh: make atime and mtime cap the timestamp instead of wrap
The libssh API uses a 32 bit type for datestamp, so instead of just
force-typecast it, make sure it gets capped at UINT_MAX if the value is
larger.

Reported-by: Joshua Rogers
Closes #18989
2025-10-10 08:26:00 +02:00
Daniel Stenberg
69efbcaa03
ldap: avoid null ptr deref on failure
ldap_get_dn() can return NULL on error

Reported-by: Joshua Rogers
Closes #18988
2025-10-10 08:24:45 +02:00
Viktor Szakats
0d560d00fa
kerberos: drop logic for MIT Kerberos <1.2.3 (pre-2002) versions
curl requires 1.2.4 or newer.

Also:
- vms: stop defining `gss_nt_service_name`. Added in
  f9cf3de70b, symbol not used in curl code
  since 355bf01c82.

Closes #18978
2025-10-10 02:07:45 +02:00
Daniel Stenberg
be5a5c10d4
openldap: fix memory-leak on oldap_do's exit path
On SSL sockbuf setup failure in `oldap_do`, the 'lud' data would not be
freed and instead leak.

Reported-by: Joshua Rogers
Closes #18986
2025-10-09 23:28:00 +02:00
Daniel Stenberg
d35bdfa8f2
openldap: fix memory-leak in error path
The 'ber' pointer could escape a free if an early error occurred.

Reported-by: Joshua Rogers
Closes #18985
2025-10-09 23:27:08 +02:00
Daniel Stenberg
6c0338115a
ftp: simplify the 150/126 size scanner
The file size is weirdly returned in a 150 or 126 response as "XXX
bytes" mentioned somewhere in the response string. This is a rewrite of
the size scanner to replace the strange strstr() + backwards search from
before with a plain forward search until '[number] + " bytes"' is a
match.

Triggered by a report by Joshua Rogers about the previous parser.

Closes #18984
2025-10-09 23:26:30 +02:00
Daniel Stenberg
71585f9894
asyn-ares: use the duped hostname pointer for all calls
In one c-ares call the passed in pointer was used and not the new
duplicated one. This is probably fine but might as well use the new
pointer as all the other calls do, which will survive longer.

Reported-by: Joshua Rogers
Closes #18980
2025-10-09 22:03:59 +02:00
Daniel Stenberg
435da1f849
Curl_resolv: fix comment. 'entry' argument is not optional
Reported-by: Joshua Rogers
Closes #18979
2025-10-09 22:03:19 +02:00
Daniel Stenberg
2c6505e0ef
krb5_gssapi: fix memory leak on error path
If a non-compliant amount of bytes is received, the function would
return error without free.

Reported-by: Joshua Rogers
Closes #18976
2025-10-09 22:02:16 +02:00
Daniel Stenberg
2a2a2e5d10
vauth/digest: improve the digest parser
Previously, if for example the nonce would end with "realm=" etc it
would get the wrong piece, due to the naive parser.

Reported-by: Joshua Rogers
Closes #18975
2025-10-09 22:01:29 +02:00
Daniel Stenberg
1e6d507de7
schannel_verify: fix mem-leak in Curl_verify_host
Reported-by: Stanislav Fort
Closes #18972
2025-10-09 21:55:28 +02:00
Stefan Eissing
d1d5855689
openssl: add comments regarding OCSP verification
To allow future reviewers of "security" reports to more easily find out
why code is this way.

Closes #18962
2025-10-09 14:44:28 +02:00
Stefan Eissing
9e2c582d6c
memdup0: handle edge case
When length is already SIZE_MAX, fail without allocating.

Reported-by: Joshua Rogers
Closes #18966
2025-10-09 14:43:56 +02:00
Stefan Eissing
83bed97ad8
rustls: pass the correct result to rustls_failf
Reported-by: Joshua Rogers
Closes #18961
2025-10-09 14:43:14 +02:00
Daniel Stenberg
b0db5f12b1
hostip: don't store negative resolves due unrelated errors
Like for:

- OOM
- resolver_start() returns error
- DoH has problems

Fixes #18953
Fixes #18954
Reported-by: Joshua Rogers
Closes #18958
2025-10-09 10:50:56 +02:00
Daniel Stenberg
29d0a308b4
setopt: allow CURLOPT_DNS_CACHE_TIMEOUT set to -1
It is documented as valid. Regression from commit b059f7deaf shipped in
8.16.0

Reported-by: Andrei Kurushin
Fixes #18959
Closes #18960
2025-10-09 10:42:35 +02:00
Daniel Stenberg
1ce6dff01a
openssl: fix peer certificate leak in channel binding
Reported-by: Stanislav Fort
Bug: https://hackerone.com/reports/3373640
Closes #18917
2025-10-09 09:10:37 +02:00
Stefan Eissing
f609b57389
http2: ingress handling edge cases
Fix some edge cases around the `data_max_bytes` handling when
processing ingress.

Reported-by: Joshua Rogers
Closes #18933
2025-10-09 08:43:34 +02:00
Stefan Eissing
44a79d4f7a
http2: cleanup pushed newhandle on fail
When nghttp2_session_set_stream_user_data() fails, clean up the
new handle.

Reported-by: Joshua Rogers
Closes #18931
2025-10-09 08:42:49 +02:00
Stefan Eissing
93e91e965e
http2: check push header names by length first
Reported-by: Joshua Rogers
Closes #18930
2025-10-09 08:41:20 +02:00
Joshua Rogers
dae19dd94a
libssh2/sftp: fix resume corruption by avoiding O_APPEND with rresume
Opening the remote file with O_APPEND while attempting to resume causes
all writes to be forced to EOF on servers/implementations where O_APPEND
semantics override a prior seek(). As a result, sftp_seek64() is ignored
and the resumed data is appended, duplicating/corrupting the file.

Fix by:
- Using O_WRONLY (without O_APPEND) when resume_from > 0.
- Skipping the seek entirely if remote_append mode is requested.

Closes #18952
2025-10-09 08:30:23 +02:00
Joshua Rogers
391e3fbeec
libssh/sftp: fix resume corruption by avoiding O_APPEND with rresume
Opening the remote file with O_APPEND while attempting to resume causes
all writes to be forced to EOF on servers/implementations where O_APPEND
semantics override a prior seek(). As a result, sftp_seek64() is ignored
and the resumed data is appended, duplicating/corrupting the file.

Fix by:
- Using O_WRONLY (without O_APPEND) when resume_from > 0.
- Skipping the seek entirely if remote_append mode is requested.

Closes #18952
2025-10-09 08:30:09 +02:00
Stefan Eissing
c0a279a8e9
socks: deny server basic-auth if not configured
When the server proposes BASIC authentication and curl does
not have that configured, fail right away.

Reported-by: Joshua Rogers
Closes #18937
2025-10-09 08:28:42 +02:00
Stefan Eissing
0b4a704500
vquic: sending non-gso packets fix for EAGAIN
The function returned OK on EAGAIN and not the correct code.

Reported-by: Joshua Rogers
Closes #18936
2025-10-09 08:27:23 +02:00
Stefan Eissing
cc7b12347b
quiche: handle tls fail correctly
quiche receive may report a TLS failure after a verified handshake. That
needs to lead to a transfer receive error.

Reported-by: Joshua Rogers
Closes #18934
2025-10-09 08:26:39 +02:00
Daniel Stenberg
008078fc38
http: make Content-Length parser more WHATWG
Return error if there is something after the number other than
whitespace and newline.

Allow comma separated numbers and repeated headers as long as the new value is
the same as was set before.

Add test 767 to 771 to verify.

Reported-by: Ignat Loskutov
Fixes #18921
Closes #18925
2025-10-08 23:18:38 +02:00
Stefan Eissing
0f02744c41
apple sectrust: check correct result on old OS versions
On ancient Apple OS versions where SecTrustEvaluateWithError() is not
available, the deprected SecTrustEvaluate() is used. In that code
branch, the code checked the wong variable for the verified result.

Closes #18929
2025-10-08 23:16:50 +02:00
Stefan Eissing
ca789e09b5
wolfssl: no double get_error() detail
Code was calling wolfSSL_get_error() on code that it had
already retrieved with the same function. Remove that.

Reported-by: Joshua Rogers
Closes #18940
2025-10-08 23:15:07 +02:00
Joshua Rogers
38ab421f60
h3/ngtcp2: close just-opened QUIC stream when submit_request fails
Closes #18904
2025-10-07 23:59:06 +02:00
Joshua Rogers
4e77388a0b
h3/nghttp3: return NGHTTP3_ERR_CALLBACK_FAILURE from recv_header
Closes #18904
2025-10-07 23:59:00 +02:00
Joshua Rogers
4bfd7a9615
openssl: skip session resumption when verifystatus is set
Resumed TLS sessions skip OCSP stapled-response verification.
Force a full handshake so verifystatus() runs.

Closes #18902
2025-10-07 23:56:25 +02:00
Stefan Eissing
88a1ab511c
ngtcp2: fix handling of blocked stream data
The stream blocking might not be the one of the current easy handle.
Look up the stream to be marked as blocking via its stream_id in the
internal hash. Theoretically, this does not have to be one of the h3
streams, so not finding it is not an error.

Fixes #18905
Reported-by: Joshua Rogers
Closes #18906
2025-10-07 17:24:01 +02:00
Stefan Eissing
0d573969de
osslq: set out idle timeout to 0
Similar to our ngtcp2 backend, set our idle timeout for the connection
to 0, meaning we have no such timeout from our side. The effective idle
timeout is then the one announced by the peer.

Closes #18907
2025-10-07 17:23:24 +02:00
Daniel Stenberg
496802fdcf
multi: use CURLMNOTIFY_ as notification id prefix
Since CURLM_ is already used as prefix for multi error codes, it makes
it easier to detect and understand the difference between identifiers -
and allows for scripts on the website and elsewhere to separate them
properly.

Follow-up to 53be8166b2
Closes #18912
2025-10-07 17:18:05 +02:00
Stefan Eissing
53be8166b2
multi: notify rename, remove the last stragglers
in the public API.

Follow-up to 357808f4ad

Closes #18910
2025-10-07 14:54:49 +02:00
Stefan Eissing
089afd78cb
socks: handle premature close
When expecting to receive a number of bytes during socks connect,
treat an early connection close as error.

Reported-by: Joshua Rogers
Closes #18883
2025-10-07 13:14:50 +02:00
Joshua Rogers
783df22e59
vquic/ngtcp2: compare idle timeout in ms to avoid overflow
Closes #18903
2025-10-07 12:06:32 +02:00
Joshua Rogers
0061b2bfaa
vquic: fix idle-timeout checks (ngtcp2 ms<-->ns), 64-bit log & honor 0=no-timeout (osslquic)
Closes #18903
2025-10-07 12:06:26 +02:00
Stefan Eissing
357808f4ad
multi: add notifications API
Add infrastructure to colled and dispatch notifications for transfers
and the multi handle in general. Applications can register a callback
and en-/disable notification type the are interested in.

Without a callback installed, notifications are not collected. Same when
a notification type has not been enabled.

Memory allocation failures on adding notifications lead to a general
multi failure state and result in CURLM_OUT_OF_MEMORY returned from
curl_multi_perform() and curl_multi_socket*() invocations.

Closes #18432
2025-10-07 10:55:31 +02:00
Stefan Eissing
f4e83a0adc
ngtcp2: fix returns when TLS verify failed
In both send/recv functions of the ngtcp2 filter, when TLS verification
has failed, jump out by skipping ingress/egress handling.

Reported-by: Joshua Rogers
Closes #18881
2025-10-07 09:04:31 +02:00
Daniel Stenberg
33380fa214
telnet: ignore empty suboptions
To avoid printing from en empty buffer

Reported-by: Joshua Rogers
Closes #18899
2025-10-06 23:54:01 +02:00
Daniel Stenberg
3660e6da80
tftp: return error if it hits an illegal state
Reported-by: Joshua Rogers
Closes #18894
2025-10-06 23:52:57 +02:00
Daniel Stenberg
bc90f80556
tftp: default timeout per block is now 15 seconds
Down from the previous (rather ridiculous) 3600.

Reported-by: Joshua Rogers
Closes #18893
2025-10-06 23:51:43 +02:00
Daniel Stenberg
f1ed50a517
tftp: don't pin or check address if recvfrom returns error
Follow-up to c4f9977c66
Reported-by: Joshua Rogers
Closes #18892
2025-10-06 23:50:34 +02:00