Commit graph

39007 commits

Author SHA1 Message Date
Daniel Stenberg
b56cb3b71e
_URL.md: remove the zone-id mention
While correct, it felt random and misplaced there.

Closes #22048
2026-06-16 16:21:22 +02:00
Stefan Eissing
bd10924b47
url: connection credentials origin
When tying credentials to a connection (NTLM, Negotiate) also link the
origin the credentials are for. This prevents a connection reuse with
the same credentials, but intended for another origin.

The mis-reuse could happen for a forwarding proxy and NTLM (although, in
the mind of the person writing this, it is an insane setup).

Closes #22040
2026-06-16 15:57:10 +02:00
Viktor Szakats
c2b050e4e4
servers: deduplicate storerequest() across two servers
Closes #22041
2026-06-16 12:42:59 +02:00
Daniel Stenberg
e0c6f4d4d6
tool_writeout: fix %time{} output for %s
Now testing both %s and %% in test 1981

Reported-by: wulin-nudt on github
Fixes #22038
Closes #22039
2026-06-16 10:17:43 +02:00
Viktor Szakats
678e63934c
perl: || die -> or die
Usage was fifty-fifty between these syntaxes before this patch.

Closes #22036
2026-06-16 00:41:29 +02:00
Daniel Stenberg
5d1ac48088
setopt: mark function argument as unused *properly*
Closes #22035
2026-06-15 23:08:59 +02:00
Daniel Stenberg
7f57aeec40
verify-release: don't unpack in git repo
- Clarify that the tarball to verify should be put in the same dir you
  run the script.

- Verify that the curl version number in the file name matches the
  version number within the tarball. To reduce risk for mistakes.

- When verifying using git, do not unpack the tarball. It avoids the
  security risk with malicious tarball contents playing tricks on git.

- Only unpack the tarball for git-less verfication.

- Move the source tarball into _tarballs/ instead of overwriting it,
  which can be useful in case the verification fails

Closes #22032
2026-06-15 22:35:33 +02:00
Stefan Eissing
bb72413b03
cf-https-connect: do not engage on proxy origin
When talking to a forwarding proxy, do not start HTTPS Eyeballing.
We might support this in the future, but for now, the --httpx.x
arguments to do not apply to such a setup.

Add a test case for forward proxying without use of ALPN.

Closes #22033
2026-06-15 22:32:15 +02:00
Dave Walker
b9702f8c48
cookie: use origin scheme for secure context check
`Curl_secure_context()` checked `conn->scheme` to determine if Secure
cookies may be sent. Since 73daec6, `conn->scheme` is set to the proxy's
scheme when using an HTTPS forwarding proxy, causing the function to
return TRUE for HTTP origins. This leaked Secure cookies over the
plaintext connection between proxy and origin.

Use `data->state.origin->scheme` instead, which always reflects the
origin's scheme regardless of proxy configuration.

Not an approved vulnerability because the regression was introduced
after the last release and is not present in any released version.

Verified by test 3401

Follow-up to 73daec6620
Reported-by: daviey on hackerone
URL: https://hackerone.com/reports/3803415
Closes #22024
2026-06-15 22:30:14 +02:00
Tobias Frauenschläger
50ffc359e9
tls: wolfssl: fixes for PQC key shares
This PR makes the wolfssl TLS backend work properly for PQC key
exchanges. The following issues are fixed:
* WOLFSSL_HAVE_KYBER is not present anymore in upstream wolfssl (for a
  long time actually), so it has no use and the ML-KEM functionality was
  never turned on properly.
* Key share group selection (via --curves) is now handled via the
  generic wolfSSL_CTX_set1_groups_list() method instead of the prior
  wolfSSL_CTX_set1_curves_list() and the additonal PQC handling. This
  removes a lot of PQC related special handling and the behavior now
  matches the OpenSSL backend.
* The default QUIC group setting has been removed. For QUIC, the key
  share as well as the list in the supported_groups extension is now
  handled all within wolfssl. This also supports --curves properly now.

Closes #22030
2026-06-15 22:18:29 +02:00
Viktor Szakats
526d3b8a53
servers: silence -Wunused-result with pragma
In some configurations the `write()` functions gets the
`warn_unused_result` attribute, that makes casting to `(void)`
ineffective to silence this warning. Seen with glibc, in 5 CI jobs.
The warning option appeared in GCC 4.5 and comes enabled by default.

```
tests/server/util.c:329:5: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
  329 |     write(STDERR_FILENO, msg, sizeof(msg) - 1);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/27548333990/job/81427544632

Refs:
https://github.com/curl/curl/pull/22023#issuecomment-4708455631
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Warning-Options.html#index-Wunused-result
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Common-Attributes.html#index-warn_005funused_005fresult
https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result

Follow-up to c8d8f081fd #22023
Follow-up to e95f509c66 #16852

Closes #22034
2026-06-15 22:04:39 +02:00
Viktor Szakats
5687d211c4
servers: fix off-by-3 OOB write for large loghex() inputs
Spotted by GitHub Code Quality

Closes #22031
2026-06-15 18:38:29 +02:00
Viktor Szakats
46ba384b1b
winldap: avoid NULL pointer deref on ldap_get_dn() fail
In non-Unicode builds.

Assisted-by: Jay Satiro

Closes #22000
2026-06-15 18:38:29 +02:00
Viktor Szakats
adb606eae7
curl_formdata: fix to pass long where missing, document CURLFORM_NAMELENGTH
- lib650: pass `long` to `CURLFORM_NAMELENGTH` in test.
  Spotted by Copilot.
  https://github.com/curl/curl/pull/22011#discussion_r3412407235
  Follow-up to 3620e569b3

- lib650: drop an interim variable, and interim casts.
  Follow-up to 60776a0515 #2747

- curl_formdata.md: document `CURLFORM_NAMELENGTH` on man page.

- curl_formdata.md: pass `long` to `CURLFORM_BUFFERLENGTH` on man page.

- formdata: pass `long` to `CURLFORM_CONTENTSLENGTH` in comment.

Closes #22017
2026-06-15 16:57:21 +02:00
Viktor Szakats
0dae3b2690
servers: accept lstat() failing due to the file missing
In `bind_unix_socket()`, before retrying `bind()`.

Before this patch the code wanted to check if the to-be-deleted unix
socket path was indeed a socket, before deleting it and retrying to
bind. If `lstat()` failed for any reason, it skipped retry. Fix to retry
if `lstat()` failed because of the file missing.

Ref: https://pubs.opengroup.org/onlinepubs/9799919799/functions/lstat.html

Follow-up to 0882e3951d #22026
Follow-up to 03bc93bd32 #22021
Follow-up to e70f8ebd34 #22020
Follow-up to 30e491e5c9 #7034
Follow-up to 99fb36797a

Closes #22010
2026-06-15 16:43:21 +02:00
Stefan Eissing
eb6d1e098e
ratelimits: use minimal burst rate
Some protocols (and servers) prefer to batch IO and will not send data
unless the window is of sufficient size. Set the burst rate for our
rate limits to a minimum of 32KB to prevent stalling.

Reported-by: Tatsuhiro Tsujikawa

Closes #22016
2026-06-15 15:59:10 +02:00
Stefan Eissing
f497b25672
cf-setup: own source file
Move the setup filter into its own source file.

Move the main connect driving function, `Curl_conn_connect()`,
from cfilters.c to connect.c.

Closes #22022
2026-06-15 15:55:58 +02:00
Viktor Szakats
8932063828
lib668: do not assume null-terminator in test input data
For correctness. Did not cause an issue, because the null-terminator is
present.

Also:
- change a size type to avoid casts.
- reuse input length value.

Spotted by GitHub Code Quality

Follow-up to 1e4cb333ef #4826

Closes #22027
2026-06-15 15:55:29 +02:00
Viktor Szakats
7d09426187
servers: accept unlink() failing due to the file missing
In `bind_unix_socket()`, before retrying `bind()`.

This patch uses `ENOENT`. This was last time in source between
d25b050379 (2018) and
dffd996e3b (2023), and also earlier. Also
defined by supported Windows envs. Seems safe to use.

Reported-by CodeQL
Follow-up to 99fb36797a
Cherry-picked from #22010

Closes #22028
2026-06-15 15:52:28 +02:00
Daniel Stenberg
6ce740403e
verify-release: verify more thoroughly with git
If the script is invoked in a git repository it verifies the tarball
better.

Closes #22018
2026-06-15 15:44:08 +02:00
Stefan Eissing
7333f6674c
cf-capsule: complete filter
Make the capsule filter complete, implement:

- pollset handling
- flush handling and querying
- shutdown handling
- replace allocated send buffer with a bufq

Closes #22019
2026-06-15 15:42:22 +02:00
Daniel Stenberg
c8d8f081fd
src/test: avoid (void)! constructs
The reason to use them seems to be that just (void) before a function
call is not enough to silence compiler warnings when return codes are
ignored and -Werror=unused-result is used.

While (void)! apparently works to silence those warnings, it is just too
weird and surprising to readers to use.

It is rather a reason to reconsider the usefulness of the warning.

Closes #22023
2026-06-15 14:43:09 +02:00
Daniel Stenberg
9f25dcea55
checksrc: detect and warn for (void)!
It's plain weird. Don't do it.

Closes #22023
2026-06-15 14:42:52 +02:00
Daniel Stenberg
b0d733e143
VULN-DISCLOSURE-POLICY: non-released code
Closes #22025
2026-06-15 14:32:35 +02:00
Viktor Szakats
0882e3951d
servers: mask to S_IFMT in unix socket path attribute check
Instead of `S_IFSOCK` before this patch. For correctness; it is probably
not an issue in most environments.

Spotted by Copilot
Bug: https://github.com/curl/curl/pull/22021#discussion_r3413049506
Follow-up to 99fb36797a

Closes #22026
2026-06-15 14:27:07 +02:00
Stefan Eissing
8cc3fed7df
transfer: adapt Curl_xfer_is_secure()
Now that `conn->origin` can be the proxy, we need to change how
Curl_xfer_is_secure() and some other places work.

Pointed out by Codex Security

Closes #22015
2026-06-15 13:41:26 +02:00
Viktor Szakats
03bc93bd32
servers: drop unix socket path attribute check on Windows
On Windows there is no `lstat()`, which was later substituted with
normal `stat()`, but on Windows `S_IFSOCK` is never defined, which meant
the output of stat was not actually used, reducing this to checking for
the presence of the file, and bailing out without retry if missing.

Follow-up to 30e491e5c9 #7034
Follow-up to 99fb36797a

Cherry-picked from #22010

Closes #22021
2026-06-15 13:36:46 +02:00
Viktor Szakats
e70f8ebd34
servers: fix error message if unix socket path is not a socket
Follow-up to 99fb36797a
Cherry-picked from #22010

Closes #22020
2026-06-15 13:07:08 +02:00
Viktor Szakats
a6d9783894
libtests: prefer sizeof() over strlen(), fix potential OOB read in 1591
- test1591: fix potential OOB read.
  Spotted by GitHub Code Quality
  Follow-up to f464535bfd #3350

Closes #22011
2026-06-15 11:24:19 +02:00
Daniel Stenberg
79a24161ab
urlapi: refactor and simplify curl_url_set
Create and make use of:

- url_encode_part()
- url_uppercasehex_part()
- url_append_query()
- url_sethost()

Closes #22012
2026-06-15 08:33:19 +02:00
Viktor Szakats
9061302a86
tidy-up: prefer spelling 'flavor', where missing
In comments and two internal build variables.

Closes #22014
2026-06-15 03:28:42 +02:00
Viktor Szakats
43c685fa78
cmake/FindGSS: fix comment, adjust custom flavor property name
- fix property name in comment.
- rename `INTERFACE_CURL_GSS_FLAVOUR` ->
  `INTERFACE_CURL_GSS_FLAVOR` to match preferred usage.

Follow-up to 8aeefd0b35 (subcommit)
Follow-up to 16f073ef49 #16973

Closes #22013
2026-06-15 02:41:29 +02:00
Viktor Szakats
0ffab25b6c
tidy-up: miscellaneous
- `N byte` -> `N-byte` or `N bytes`.
- INTERNALS.md: language tweaks.
- schannel: language tweak in comment/error message.
- socks_gssapi, socks_sspi: simplify composing an error message.
  (at a cost of 8 extra constant string bytes.)
- m4/curl-compilers.m4: fix typo in link (in comment).
- contrithanks.sh: fix indent, drop stray `;` terminator.
- lib, src, tests: drop/fix a bunch of badwords.
- fix typos in comments.
- fix indent, stray spaces.

Some of these spotted by GitHub Code Quality and Copilot

Closes #22009
2026-06-14 20:10:28 +02:00
Daniel Stenberg
5bff1c35f1
socks_sspi: store socks5_gssapi_enctype
Store the unwrapped protection level in `conn->socks5_gssapi_enctype` to
prevent the proxy from contuning unprotected. Matches the GSSAPI version
of the code.

Reported-by: Trail of Bits
Closes #22004
2026-06-14 18:36:13 +02:00
Daniel Stenberg
c4cb67692d
smb: integer overflow proof a size check
By using size_t for the vars instead of shorts.

Pointed out by Zeropath

Closes #22001
2026-06-14 18:12:33 +02:00
Viktor Szakats
f1b1919bd0
servers: drop single-use interim result variables
Closes #22008
2026-06-14 17:49:33 +02:00
Viktor Szakats
9002d3350c
servers: minor socket error handling fixes
- sws: fix socket error code in `select()` failure message.
  Spotted by Copilot
  Bug: https://github.com/curl/curl/pull/21998#discussion_r3409469444
- sws: do not call `SOCKERRNO` twice on error.
- dnsd: do not call `SOCKERRNO` twice on error.
- dnsd: replace `goto` with `while()` to sync with rest of code.
- dnsd: `sendto()` fail message fixes:
  - replace `int` cast with `%zu` mask.
  - drop redundant newline.
  - show socket error string like rest of code.
  - report not-fully-sent error separately from socket errors.

Closes #22007
2026-06-14 16:16:25 +02:00
Viktor Szakats
945938de10
rtspd: sync up sleep loop with sws
Check for `!got_exit_signal` as part of the `while()` expression,
instead of doing it after calling `curlx_wait_ms()`. To simplify and
improve consistency with rest of code.

Follow-up to 0653fa107f
Follow-up to 123c92c904

Closes #22006
2026-06-14 16:16:25 +02:00
Viktor Szakats
d9ea8cdcfa
tests/servers: do not interpret unlink() retval as errno
In `socksd` and `sws` error messages.

Also:
- show the messages only if `unlink()` failed.
- rename a return code variable and sync a message text for consistency.

Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html

Spotted by Copilot in `socksd.c`
Bug: https://github.com/curl/curl/pull/21998#discussion_r3409395013
Follow-up to 80eb71a3f5 #8687

Closes #22005
2026-06-14 14:25:02 +02:00
Viktor Szakats
9972f700a8
perl: switch from backticks to qx()
To make it easier to find external command invocation in the source.

Also drop backticks from a comment.

To find external command invocations in Perl code use:
```sh
git grep -E "((exec|qx|open2|open3|system)\(|open\(.+-\|)" $(<perlfiles>)
```

Refs:
https://perldoc.perl.org/functions/qx
https://perldoc.perl.org/perlop#Simpler-Quote-Like-Operators

Closes #21994
2026-06-14 14:25:02 +02:00
Viktor Szakats
c61f007a73
krb5_sspi: fix error message on DecryptMessage() fail
Spotted by GitHub Code Quality

Closes #22003
2026-06-14 14:17:27 +02:00
Viktor Szakats
ba16b83221
telnet: drop an int cast no longer necessary
Spotted-by GitHub Code Quality

Follow-up to c5637baa06
Follow-up to 83a5e39065

Closes #22002
2026-06-14 14:17:27 +02:00
Viktor Szakats
fe2df80a5a
socket: use name sockerr for socket error variables
Also:
- add comment explaining a `sockerr = errno` (vs. `SOCKERRNO`)
  assigment.

Closes #21998
2026-06-14 14:17:07 +02:00
Daniel Stenberg
fb83911aa6
socks_sspi: invalid response length is a fatal error
Pointed out by Zeropath
Closes #21999
2026-06-14 12:29:38 +02:00
Saud Alshareef
6b78264bcf
ldap: base64 encode binary LDIF values with WinLDAP
The WinLDAP backend only base64 encoded LDAP values when the attribute
name ended in ;binary. This made attributes such as jpegPhoto get
written as raw bytes, producing malformed LDIF output.

Match the OpenLDAP backend by also base64 encoding values with leading
or trailing blanks or non-printable bytes.

Fixes #21926
Reported-by: oreadvanthink on github
Closes #21982
2026-06-14 11:11:43 +02:00
Daniel Stenberg
8d3c4fe344
sspi: free libcurl allocated memory with curlx_free
DecryptMessage() decrypts the buffer in place, overwriting the original
contents. It does not allocate any new buffer so the single original
buffer should be freed using the same memory "system" that allocated it.

Reported-by: Trail of Bits
Closes #21990
2026-06-13 23:18:59 +02:00
Viktor Szakats
bb837dda23
telnet: drop redundant interim variables
Also reduce scope of a declaration.

Closes #21995
2026-06-13 01:27:50 +02:00
Stefan Eissing
73daec6620
lib: transfer origin and proxy handling
Add `data->state.origin` as the origin the transfer is sending the
current request to/gets the response from. Use it for request specific
properties like authentication, hsts and cookie handling, etc.

Unless talking to a forwarding HTTP proxy (e.g. not tunneling),
`data->state.origin` and `conn->origin` are the same.

With a forwarding HTTP proxy in play, `conn->origin` is set to
`conn->http_proxy.peer` and `conn->bits.origin_is_proxy` (a new bit) is
set.

Remove the connection bits, now replaced with:

* `conn->bits.socksproxy` -> `conn->socks_proy.peer`
* `conn->bits.httpproxy` -> `conn->http_proy.peer`
* `conn->bits.proxy` -> `(conn->socks_proy.peer || conn->http_proy.peer`)
* `conn->bits.tunnel_proxy` -> (`conn->http_proy.peer && !conn->bits.origin_is_proxy`)
* `(conn->bits.httpproxy && !conn->bits.tunnel_proxy)` -> `conn->bits.origin_is_proxy`

Rename `noproxy.[ch]` to `proxy.[ch]`. Move the connection proxy setup
code from `url.c` to `proxy.c`.

Remove `data->info.conn_remote_port` as no one uses it.

Add test_40_02b for a SOCKS connection to a forwarding HTTPS proxy.

Update internal documentation about peers and creds.

Closes #21967
2026-06-12 23:52:00 +02:00
Viktor Szakats
c951368579
build: enable -Wlogical-op picky warning for GCC 4.4+
Follow-up to 879a1514c3 #21992

Closes #21893
2026-06-12 23:37:37 +02:00
Viktor Szakats
879a1514c3
socket: introduce SOCK_EAGAIN() and use it
To contain the logic of checking for both `EWOULDBLOCK` and/or `EAGAIN`
depending on platform/availability. Also to avoid checking for both if
they mapp to the same value, and to avoid PP guards around use.

This also ensures `EAGAIN` is consistently not checked on Windows, where
headers defined it, but `SOCKERRNO` never returns it, because curl maps
it to `WSAGetLastError()`.

If they map to the same value, checking them both in an `if` expression
trips GCC warning `-Wlogical-op` (the same way it triggers duplicate
case value error in `switch`).

Also:
- replace two `switch()` statements with the new macro.
- tests/server/sws: make two outliers use the new macro that were only
  checking for `EWOULDBLOCK` before this patch, in `connect_to()`.
- move variables to the left-side of expressions, where missing.
- rustls: use a variant of this macro that uses raw `EWOULDBLOCK`.
  Tried tracing it back to the origins, but I couldn't figure out if
  this is working as expected on all supported Windows versions in
  Rust. It seems to be using `GetLastError()`, according to
  https://docs.rs/system_error/0.2.0/system_error/, which would be
  probably incorrect.

Notes:
- it's probably a good idea to assign `SOCKERRNO` to a variable before
  passing it to this macro.

Cherry-picked from #21893

Closes #21992
2026-06-12 23:27:23 +02:00