1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00
Commit Graph

2997 Commits

Author SHA1 Message Date
4844e36840 build: disable warning -Wunreachable-code-break
This warning remains silent in unity builds. Since we're using unity
in CI for most jobs, warnings remain undetected there.
Disable them for all builds to avoid a surprise warning outside our CI.

It also doesn't work in any #included `.c` sources, like the crypto
backend sources.

The issue caught by the warning is useful for a tidy codebase, but
doesn't affect executed code. It was enabled in
84338c4de2d7c798e3c270c9610d51a4ad18a90b #12331 (2023-11-15).

llvm source: fee2953f23/clang/lib/Sema/AnalysisBasedWarnings.cpp (L125-L134)
llvm issue: https://github.com/llvm/llvm-project/issues/71046

Follow-up to 7ecc309cd1 #1224
Closes #1481
2024-10-28 12:30:02 +01:00
bf9bb04571 cmake: add clang-cl support to PickyWarnings.cmake
via curl. (Untested with clang-cl in libssh2.)

Closes #1480
2024-10-28 12:30:02 +01:00
d4e43c7b69 cmake/Find*: clear package version after pkg-config detection
`pkg_check_modules()` seems to leave `<PACKAGE>_VERSION` defined with an
empty value, if the package is not found.

When the package is also not found in the fallback branch,
`find_package_handle_standard_args()` logs and error message. In this
message it includes the bogus empty value as: `(found version "")`:
```
  Could NOT find Libgcrypt (missing: LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)
  (found version "")
```

Clear the version number to avoid the confusion:
```
  Could NOT find Libgcrypt (missing: LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)
```

Seen with CMake v3.30.3 and 3.30.5.

Closes #1479
2024-10-28 11:35:41 +01:00
ac00f6c437 cmake: tidy up variables names in PickyWarnings.cmake
Use underscore-lowercase for internal variables to match the rest of
the source.

Closes #1478
2024-10-28 11:35:41 +01:00
efad5f9076 cmake: decorate comments in Find modules
Make them Markdown-like and make them pass spellcheckers better.

Closes #1477
2024-10-28 11:35:40 +01:00
d01680ca09 ci/GHA: make apg-get install faster, drop a workaround
- always pass `--no-install-suggests --no-install-recommends`
  to `apt-get` to avoid spending time to install packages we don't need.
  (notably in the i386 Linux job.)

- drop an `apt-get` hack that's no longer necessary.

Closes #1476
2024-10-23 01:15:07 +02:00
83590ac70d libssh2.h: add note about release versions to LIBSSH2_VERSION
As noted in #771 and #1473, the blessed and signed releases are on
libssh2.org and any other archives, like those generated by GitHub,
are just a collection of files from the tag and are not the official
releases.

This adds a note, which already exists for `LIBSSH2_TIMESTAMP`, to
`LIBSSH2_VERSION`, to clarify this fact.

Closes #1475
2024-10-23 01:15:07 +02:00
7e1c6be12f checksrc: sync with curl
Check spaces around logical AND operator.

Closes #1474
2024-10-21 23:34:23 +02:00
c04d57e785 libssh2.h: bump to 1.11.2_DEV 2024-10-21 12:00:17 +02:00
00e5975ad2 libssh2.h: bump to 1.11.1 2024-10-21 11:59:53 +02:00
9d6836e098 ci/GHA: adjust job for Ubuntu 24.04 image
Closes #1470
2024-10-21 11:55:29 +02:00
a312b43325 RELEASE-NOTES: 1.11.1 libssh2-1.11.1 2024-10-16 10:03:11 +02:00
e2b2c02686 RELEASE-NOTES: sync [ci skip] 2024-10-08 23:08:39 +02:00
1a9e8811f7 session: support server banners up to 8192 bytes (was: 256)
If server had banner exceeding 256 bytes there wasn't enough room in
`_LIBSSH2_SESSION.banner_TxRx_banner`. Only the first 256 bytes would be
read making the first packet read fail but also dooming key exchange as
`session->remote.banner` didn't include everything.

This change bumps the banner buffer to 8KB to match OpenSSH.

Fixes #1442
Closes #1443
2024-10-08 23:04:12 +02:00
c3d6729f90 RELEASE-NOTES: sync [ci skip] 2024-10-07 12:15:56 +02:00
45064137ac cmake: sync and improve Find modules, add pkg-config native detection
- sync code between Find modules.
- wolfssl: replace `pkg-config` hints with native detection.
- libgcrypt, mbedtls: add `pkg-config`-based native detection.
- libgcrypt: add version detection.
- limit `pkg-config` use for `UNIX`, vcpkg, and non-cross MinGW builds,
  and builds with no manual customization via `*_INCLUDE_DIR` or
  `*_LIBRARY`.
- replace and sync Find module header comments.
- ci: delete manual mbedTLS config that's now redundant.

Based on similar work done in curl.

Second attempt at #1420
Closes #1445
2024-10-05 20:59:27 +02:00
4b5f6b1031 cmake: initialize LIBSSH2_LIBDIRS [ci skip]
Follow-up to c87f129630 #1466
2024-10-04 13:55:02 +02:00
66f8574ec5 ci/appveyor: fix and bump OpenSSL 3 path, add path check
Follow-up to b5e68bdc37 #1461
Closes #1468
2024-10-04 13:28:04 +02:00
a6d98fb41b cmake: link to OpenSSL::Crypto, not OpenSSL::SSL
Follow-up to 82b09f9b3a #1322
Follow-up to c84745e34e #1128
Cherry-picked from #1445
Closes #1467
2024-10-04 12:58:08 +02:00
c87f129630 cmake: generate LIBSSH2_PC_LIBS_PRIVATE dynamically
Generate `LIBSSH2_PC_LIBS_PRIVATE` from `LIBSSH2_LIBS`.

Also add extra libdirs (`-L`) to `Libs` and `Libs.private`.

Logic copied from curl.

Closes #1466
2024-10-04 11:24:34 +02:00
63898981cc cmake: initialize LIBSSH2_PC_REQUIRES_PRIVATE [ci skip]
Follow-up to 0fce9dcc29 #1464
2024-10-04 02:29:50 +02:00
14b1b9d021 cmake: add comment about ibssh2.pc.in variables [ci skip] 2024-10-04 02:25:15 +02:00
d70cee360e cmake: support absolute CMAKE_INSTALL_INCLUDEDIR/CMAKE_INSTALL_LIBDIR
in `libssh2.pc`.

Also use `${exec_prefix}` (instead of `${prefix}`) as a base for `libdir`.

Closes #1465
2024-10-04 02:21:02 +02:00
0fce9dcc29 cmake: rename two variables and initialize them
- `LIBRARIES` -> `LIBSSH2_LIBS`
- `SOCKET_LIBRARIES` -> `LIBSSH2_LIBS_SOCKET`

Also initialize them before use.

Cherry-picked from #1445
Closes #1464
2024-10-03 21:57:48 +02:00
b5e68bdc37 ci/appveyor: reduce test runs (workaround for infrastructure permafails)
Jobs consistently fail to connect to the test server (run in GHA) since
2024-Aug-29:
https://ci.appveyor.com/project/libssh2org/libssh2/builds/50498393

There was an earlier phase of failures one month before that, that got
fixed by increasing the wait for the server in
bf3af90b3f.

Thus, skip running tests in AppVeyor CI jobs, except: After some
experiments, it seems that running tests with the last OpenSSL job and
the last WinCrypt job _work_, which still leaves some coverage.
It remains to be seen how stable this is.

This is meant as a temporary fix till there is a solution to make all
jobs run tests reliable like up until a few months ago.

Closes #1461
2024-10-03 19:13:59 +02:00
40e817ff50 os400: drop vsprintf() use
Follow-up to discussion in #1457

Plus e-mail address update.

Closes #1462
2024-10-02 16:04:30 +02:00
a8bc96c794 RELEASE-NOTES: sync [ci skip] 2024-09-30 23:39:41 +02:00
b942bad190 openssl: free allocated resources when using openssl3
Reproduces consistently with curl test case 638

Closes #1459
2024-09-30 11:43:18 +02:00
1117b677a0 checksrc: update, check all sources, fix fallouts
update from curl:
cff75acfec/scripts/checksrc.pl

Closes #1457
2024-09-28 11:41:52 +02:00
d9c2e550ca cmake: prefer find_dependency() in libssh2-config.cmake
CMake manual suggest using `find_dependency()` (over  `find_package()`)
in `config.cmake` scripts.

Ref: https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html

Closes #1460
2024-09-28 11:41:48 +02:00
20ad047df5 ci: use Ninja with cmake
Closes #1458
2024-09-27 20:52:09 +02:00
8d3bc19b3b Fix memory leaks in _libssh2_ecdsa_curve_name_with_octal_new and _libssh2_ecdsa_verify (#1449)
Better error handling in`_libssh2_ecdsa_curve_name_with_octal_new` and `_libssh2_ecdsa_verify` to prevent leaks.

Credit: dksslq <dksslq@github.com>
2024-09-27 08:54:22 -07:00
de0048759b Fix unstable connections over nonblocking sockets (#1454)
The `send_existing()` function allows partially sent packets to be sent
fully before any further packets are sent. Originally this returned
`LIBSSH2_ERROR_BAD_USE` when a different caller or thread tried to send
an existing packet created by a different caller or thread causing the
connection to disconnect. Commit 33dddd2f8a removed the return
allowing any caller to continue sending another caller's packet. This
caused connection instability as discussed in #1397 and confused the
client and server causing occasional duplicate packets to be sent and
giving the error `rcvd too much data` as discussed in #1431. We return
`LIBSSH2_ERROR_EAGAIN` instead to allow existing callers to finish
sending their own packets.

Fixes #1397
Fixes #1431
Related #720

Credit: klux21, rolag
2024-09-27 08:52:47 -07:00
b346541847 Prevent possible double free of hostkey (#1452)
NULL server hostkey based on fuzzer failure case.
2024-09-10 09:35:26 -07:00
9d9ee7807d cmake: tidy up syntax, minor improvements
- make internal variables underscore-lowercase.
- unfold lines.
- fold lines setting header directories.
- fix indent.
- drop interim variable `EXAMPLES`.
- initialize some variables before populating them.
- clear a variable after use.
- add `libssh2_dumpvars()` function for debugging.
- allow to override default `CMAKE_UNITY_BUILD_BATCH_SIZE`.
- bump up default `CMAKE_UNITY_BUILD_BATCH_SIZE` to 0 (was 32).
- tidy up option descriptions.

Closes #1446
2024-09-07 21:27:55 +02:00
570de0f23f cmake: rename mbedTLS and wolfSSL Find modules
To match the curl ones.

Cherry-picked from #1445
2024-08-18 12:57:04 +02:00
0e9b5daa25 RELEASE-NOTES: sync [ci skip] 2024-08-13 19:40:19 +02:00
8e3c40b2a3 cmake: fixup version detection in mbedTLS find module
- avoid warning with 2.x versions about missing header file while
  extracting the version number.

- clear temp variables.

Closes #1444
2024-08-13 19:34:25 +02:00
814a850c97 buildconf: drop
Use `autoreconf -fi` instead.

Follow-up to fc5d77881e
Closes #1441
2024-08-07 18:19:15 +02:00
492bc543bb Implement chacha20-poly1305@openssh.com
Probably the biggest and potentially most controversial change we have
to upstream.

Because earlier versions of OpenSSL implemented the algorithm before
standardization, using an older version of OpenSSL can cause problems
connecting to OpenSSH servers. Because of this, we use the public domain
reference implementation instead of the crypto backends, just like
OpenSSH does.

We've been holding this one for a few years. We were about to upstream
it around the same time as aes128gcm landed upstream, and the two
changes were completely incompatible. Honestly, it took me weeks to
reconcile these two implementations, and it could be much better.

Our original implementation changed every crypt method to decrypt the
entire message at once. the AESGCM implementation instead went with this
firstlast design, where a firstlast paramater indicates whether this is
the first or last call to the crypt method for each message. That added
a lot of bookkeeping overhead, and wasn't compatible with the chacha
public domain implementation.

As far as I could tell, OpenSSH uses the technique of decrypting the
entire message in one go, and doesn't have anything like firstlast.
However, I could not get out aes128gcm implementation to work that way,
nor could I get the chacha implementation to work with firstlast, so I
split it down the middle and let each implementation work differently.
It's kind of a mess, and probably should be cleaned up, but I don't have
the time to spend on it anymore, and it's probably better to have
everything upstream.

Fixes #584
Closes #1426
2024-08-06 10:56:23 +02:00
29a4b607d8 tidy-up: do/while formatting
Also fix an indentation and delete empty lines.

Closes #1440
2024-08-06 10:56:22 +02:00
8ae1b2d742 wolfssl: drop header path hack
The wolfSSL OpenSSL headers reside in `wolfssl/openssl/*.h`.

Before this patch the wolfSSL OpenSSL compatibilty header includes were
shared with the native OpenSSL codepath, and used `openssl/*h`. For
wolfSSL builds this required a hack to append the
`<wolfssl-prefix>/wolfssl` directory to the header search path, to find
the headers.

This patch changes the source to use the correct header references,
allowing to drop the header path hack.

Also fix to use the correct variable to set up the header path in CMake:
`WOLFSSL_INCLUDE_DIRS` (was: `WOLFSSL_INCLUDE_DIR`, without the `S`)

Closes #1439
2024-08-06 10:56:22 +02:00
6d1d13c2a6 cmake: mbedTLS detection tidy-ups
- set and use `MBEDTLS_INCLUDE_DIRS`.
- stop marking `MBEDTLS_LIBRARIES` as advanced.

Closes #1438
2024-08-06 10:56:22 +02:00
2bb46d4481 cmake: add quotes, delete ending dirseps
Follow-up to 3fa5282d62 #1166
Closes #1437
2024-08-06 10:56:22 +02:00
bf3af90b3f CI/appveyor: increase wait for SSH server on GHA [ci skip]
Blind attempt to make AppVeyor CI tests work again.
2024-07-30 23:35:32 +02:00
b7ab0faa70 disable DSA by default
Also:
- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
- test the above option in CI.
- say 'deprecated' in docs and public header.
- disable DSA in the CI server config.
  (OpenSSH 9.8 no longer builds with it by default)
  https://www.openssh.com/txt/release-9.8
  Patch-by: Jose Quaresma
- disable more DSA code when not enabled.

Fixes #1433
Closes #1435
2024-07-30 22:59:02 +02:00
c905bfd27c tidy-up: link updates (#1434) 2024-07-30 19:35:38 +02:00
e4c042f6c2 ci/GHA: revert concurrency and improve permissions
Statuses are per AppVeyor event and commit, not pull-request.
Also align permissions approach with curl, least priviledge.

Partially reverts b08cfbc99f.
2024-07-27 20:50:42 +02:00
a50d7debfd Always init mbedtls_pk_context (#1430)
In the failure case, mbedtls_pk_context could be free'd without first being initialized.
2024-07-23 10:32:13 -07:00
457b02e8dd mbedtls: tidy-up (#1429) 2024-07-22 11:50:38 -07:00