1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-01-27 00:18:12 +03:00
Commit Graph

3010 Commits

Author SHA1 Message Date
Viktor Szakats
df2b206cd0 ci/appveyor: fix PowerShell warning (#1514)
in WinCNG builds, e.g. VS2015, WinCNG, x86, Server 2016:
```
Test-Path : Cannot bind argument to parameter 'Path' because it is null.
At line:10 char:16
+   if(Test-Path $env:OPENSSL_ROOT_DIR) {
+                ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
```
https://ci.appveyor.com/project/libssh2org/libssh2/builds/51280178/job/9ddtkb91w54si3da#L85
2025-01-07 20:11:55 +01:00
Viktor Szakats
25d3a09207 ci/appveyor: use -A option with all MSVC versions (#1513)
To simplify the initialization. The ` Win64` method was meant for old
CMake versions not in use in CI.

Also pass the `-A` option without a space to make PowerShell pass
the option as expected by CMake.
2025-01-07 18:36:50 +01:00
Viktor Szakats
bc78138371 ci/GHA: bump to cygwin v5 (#1512) 2025-01-07 11:09:33 +01:00
Viktor Szakats
4725826550 cmake: fix cmake warnings (#1511)
```
CMake Warning (dev) at cmake/CopyRuntimeDependencies.cmake:59 (add_custom_command):
  The following keywords are not supported when using
  add_custom_command(TARGET): DEPENDS.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  example/CMakeLists.txt:58 (add_target_to_copy_dependencies)
```
```
CMake Warning (dev) at cmake/CopyRuntimeDependencies.cmake:59 (add_custom_command):
  Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.  Assuming
  POST_BUILD to preserve backward compatibility.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  example/CMakeLists.txt:58 (add_target_to_copy_dependencies)
```
Ref: https://github.com/libssh2/libssh2/actions/runs/12614228505/job/35152908184?pr=1510#step:15:77
2025-01-05 00:48:55 +01:00
Viktor Szakats
389d70bfeb cmake: tidy up -j make option in integration tests (#1509) 2025-01-04 23:24:51 +01:00
Viktor Szakats
ffd0c982a5 configure: fix --without-lib*-prefix when lib* is detected anyway
Do not test the prefix when set to `no`.
(as with `--without-lib*-prefix`)

Before this patch this test was always made and when detected despite
the wrong prefix, the `no` prefix remained in `LDFLAGS` causing a build
failure later in `libtool`.

Fixes:
```
$ ../configure --without-libssl-prefix
[...]
../libtool: line 7756: cd: no/lib: No such file or directory
libtool:   error: cannot determine absolute directory name of 'no/lib'
make[2]: *** [libssh2.la] Error 1
```

Follow-up to d19b619070 #1384

Reported-by: Christoph Reiter
Fixes #1505
Closes #1506
2025-01-02 22:34:21 +01:00
Viktor Szakats
bd8caa1983 configure: drop duplicate -lmbedcrypto from LIBS
Closes #1507
2025-01-02 14:19:44 +01:00
Stephan Eggermont
780bf13aa2 libssh2.h: typo fixes
Closes #1496
2024-11-21 11:46:26 +01:00
Viktor Szakats
21228cffb8 transport: fix indentation of comments
Cherry-picked from #1484
2024-11-15 01:55:18 +01:00
Viktor Szakats
c78d54c28e transport: stop passing newline to the trace handler via debugdump()
The trace handler is called from two places in libssh2. One of them was
passing a newline at the end of the trace message string, the other one
was not.

When the trace handler feature was introduced, a newline was passed both
via `debugdump()` and `libssh2_debug()`:
44eba0c993 (2010-01-15)

Shortly after a commit deleted the newline for `libssh2_debug()`:
0f0652a309 (2010-06-23)

This patch re-syncs behaviour between the traceback callbacks by
dropping the newline for trace handler calls made from `debugdump()`.

Reported-by: Chris Emsen
Fixes #1485
Follow-up to 0f0652a309
Closes #1492
2024-11-14 20:00:14 +01:00
Viktor Szakats
114923f1ac tidy-up: unsigned const char -> const unsigned char
For consistency with rest of the code.

Closes #1487
2024-11-02 00:37:59 +01:00
Viktor Szakats
91b0e09934 tidy-up: spelling [ci skip] 2024-10-31 21:19:43 +01:00
Viktor Szakats
5d03b4f94a cmake: build but don't install static lib in certain conditions
Building 3 tests require static libssh2 lib. Some may prefer not to
create the static lib, yet prefer to build all tests, including those
3 that require it.

Detect such intent by looking for an explicit `BUILD_TESTING=ON` and
`BUILD_STATIC_LIBS=OFF`, then build the static lib anyway but without
installing it.

Reported-by: Eli Schwartz
Fixes #1450
Closes #1469
2024-10-28 21:10:32 +01:00
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Pascal Neuperger
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
Viktor Szakats
7e1c6be12f checksrc: sync with curl
Check spaces around logical AND operator.

Closes #1474
2024-10-21 23:34:23 +02:00
Viktor Szakats
c04d57e785 libssh2.h: bump to 1.11.2_DEV 2024-10-21 12:00:17 +02:00
Viktor Szakats
00e5975ad2 libssh2.h: bump to 1.11.1 2024-10-21 11:59:53 +02:00
Viktor Szakats
9d6836e098 ci/GHA: adjust job for Ubuntu 24.04 image
Closes #1470
2024-10-21 11:55:29 +02:00
Daniel Stenberg
a312b43325 RELEASE-NOTES: 1.11.1 libssh2-1.11.1 2024-10-16 10:03:11 +02:00
Viktor Szakats
e2b2c02686 RELEASE-NOTES: sync [ci skip] 2024-10-08 23:08:39 +02:00
Anders Borum
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
Viktor Szakats
c3d6729f90 RELEASE-NOTES: sync [ci skip] 2024-10-07 12:15:56 +02:00
Viktor Szakats
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
Viktor Szakats
4b5f6b1031 cmake: initialize LIBSSH2_LIBDIRS [ci skip]
Follow-up to c87f129630 #1466
2024-10-04 13:55:02 +02:00
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
63898981cc cmake: initialize LIBSSH2_PC_REQUIRES_PRIVATE [ci skip]
Follow-up to 0fce9dcc29 #1464
2024-10-04 02:29:50 +02:00
Viktor Szakats
14b1b9d021 cmake: add comment about ibssh2.pc.in variables [ci skip] 2024-10-04 02:25:15 +02:00
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
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
Patrick Monnerat
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
Viktor Szakats
a8bc96c794 RELEASE-NOTES: sync [ci skip] 2024-09-30 23:39:41 +02:00
Daniel Stenberg
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
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
20ad047df5 ci: use Ninja with cmake
Closes #1458
2024-09-27 20:52:09 +02:00
dksslq
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
rolag
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
Will Cosgrove
b346541847 Prevent possible double free of hostkey (#1452)
NULL server hostkey based on fuzzer failure case.
2024-09-10 09:35:26 -07:00
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
0e9b5daa25 RELEASE-NOTES: sync [ci skip] 2024-08-13 19:40:19 +02:00