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
1701d5c0d3 Correctly initialize values (#1428)
Fix regression with commit from #1421
2024-07-22 09:57:24 -07:00
c0357b73a2 RELEASE-NOTES: sync [ci skip] 2024-07-14 11:01:49 +02:00
1628f6cab8 mbedtls: expose mbedtls_pk_load_file() for our use
While it's moved to pk_internal, it won't removed in mbedTLS 3.6 LTS
so it's safe to redeclare it on our side to find it.

This is implementing emergency fix suggested from
2e4c5ec462 (commitcomment-141379351)

Follow-up to e973493f99 #1393
Follow-up to 2e4c5ec462 #1349
Closes #1421
2024-07-13 17:47:53 +02:00
42ef8f3f0b ci/GHA: simplify mbedTLS build hack for autotools (#1425)
Follow-up to e973493f99 #1393
2024-07-13 11:40:07 +02:00
9f23a3bbaf Always check for null pointers before calling _libssh2_bn_set_word (#1423) 2024-07-12 21:24:18 -07:00
ae04b1b953 ci/GHA: FreeBSD 14.1, actions bump (#1424) 2024-07-12 01:54:26 +02:00
75de6a37cb Increase SFTP_HANDLE_MAXLEN back to 4092 (#1422)
Match OpenSSH for compatibility.
2024-07-11 13:42:00 -07:00
c6d42df5d3 ci/GHA: tidy up casing [ci skip] 2024-07-10 00:29:00 +02:00
420f902617 REUSE: fix typo in comment 2024-07-06 02:37:34 +02:00
99723f07af REUSE: shorten and improve
Follow-up to 70b8bf314c #1419
2024-07-05 16:42:31 +02:00
70b8bf314c REUSE: upgrade to REUSE.toml
Closes #1419
2024-07-05 15:13:18 +02:00
2677d3b087 build: stop detecting sys/param.h header
This header is no longer used.

Follow-up to 12427f4fb8 #1415
Closes #1418
2024-07-04 01:59:58 +02:00
12427f4fb8 tests: avoid using MAXPATHLEN, for portability
`MAXPATHLEN` is not present in some systems, e.g. GNU Hurd.

Co-authored-by: Viktor Szakats
Ref: 54bef4c5da #198
Fixes #1414
Closes #1415
2024-07-03 23:42:43 +02:00
a0310699f5 cmake: sync formatting in cmake/Find* modules 2024-07-03 22:27:18 +02:00
fb6527468c sftp: implement posix-rename@openssh.com
Add a new function `libssh2_sftp_posix_rename_ex()` and
`libssh2_sftp_posix_rename()`, which implement
the posix-rename@openssh.com extension.

If the server does not support this extension, the function returns
`LIBSSH2_FX_OP_UNSUPPORTED` and it's up to the user to recover, possibly
by calling `libssh2_sftp_rename()`.

Co-authored-by: Viktor Szakats (bump to size_t)
Closes #1386
2024-06-26 19:31:34 +02:00
dc206408c1 src: use UINT32_MAX
Needs to be defined for platforms missing it, e.g. VS2008.

Closes #1413
2024-06-26 16:34:40 +02:00
1910184376 Fix a memory leak in key exchange. (#1412)
Original fix submitted as a patch by Trzik.

Co-authored-by: Michael Buckley <michael@panic.com>
2024-06-25 11:11:25 -07:00
dd74b02bba RELEASE-NOTES: sync [ci skip] 2024-06-25 12:33:42 +02:00
a5b0fac292 wolfssl: fix EVP_Cipher() use with v5.6.0 and older
Add workaround for the wolfSSL `EVP_Cipher(*p, NULL, NULL, 0)` bug to
make libssh2 work with wolfSSL v5.6.0 and older.

wolfSSL fixed this issue in v5.7.0:
https://github.com/wolfSSL/wolfssl/pull/7143
b0de0a1c95

Without our local workaround:

- v5.3.0 and older fail most tests:
  Ref: https://github.com/libssh2/libssh2/actions/runs/9646827522/job/26604211476#step:17:1263

- v5.4.0, v5.5.x, v5.6.0 fail these:
  ```
  29 - test_read-aes128-cbc (Failed)
  30 - test_read-aes128-ctr (Failed)
  32 - test_read-aes192-cbc (Failed)
  33 - test_read-aes192-ctr (Failed)
  34 - test_read-aes256-cbc (Failed)
  35 - test_read-aes256-ctr (Failed)
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/9646827522/job/26604233819#step:17:978

Oddly enough the workaround breaks OpenSSL tests, so only enable it for
the affected wolfSSL versions.

Also add new build-from-source wolfSSL CI job to test the new codepath.

wolfSSL has a build bug where `wolfssl/options.h` and
`wolfssl/version.h` are not copied to the `install` destination with
autotools. With CMake it has a different bug where `wolfcrypt/sp_int.h`
is not copied (with v5.4.0). And another with CMake where `FIPS_mode()`
remains missing (with v5.6.0 and earlier.)

Therefore use CMake with v5.5.4 and a workaround for `FIPS_mode()`.
Another option is autotools with v5.4.0 and a workaround for `install`,
but CMake builds quicker.

Regression-from 3c953c05d6 #797
Fixes #1020
Fixes #1299
Assisted-by: Michael Buckley via #1394
Closes #1394 (another attempt to fix the mentioned wolfSSL bug)
Closes #1407
2024-06-24 17:01:39 +02:00
5cab802c55 wolfssl: bump version in upstream issue comment [ci skip] 2024-06-24 15:00:29 +02:00
260a721cbe wolfssl: require v5.4.0 for AES-GCM
Earlier versions crash while running tests.

This patch is part of a series of fixes to make wolfSSL AES-GCM support
work together with libssh2.

Possibly related is this wolfSSL bugfix patch, released in v5.4.0:
https://github.com/wolfSSL/wolfssl/pull/5205
fb3c611275
"Fix another AES-GCM EVP control command issue"

Ref: #1020
Ref: #1299
Cherry-picked from #1407
Closes #1411
2024-06-24 14:59:02 +02:00
fbd9d19279 tests: fix excluding AES-GCM tests
Replace hard-coded crypto backends and rely on `LIBSSH2_GCM` macro
to decide whether to run AES-GCM tests.

Without this, build attempted to run AES-GCM tests (and failed)
for crypto backends that have conditional support for this feature, e.g.
wolfSSL without the necessary features built-in
(as in before Homewbrew wolfssl 5.7.0_1, or OpenSSL v1.1.0 and older).

This patch is part of a series of fixes to make wolfSSL AES-GCM support
work together with libssh2.

Cherry-picked from #1407
Closes #1410
2024-06-24 14:39:31 +02:00
1c0b07a726 ci/GHA: fix wolfSSL-from-source AES-GCM tests
Turns out these tests:
```
31 - test_read-aes128-gcm@openssh.com (Failed)
36 - test_read-aes256-gcm@openssh.com (Failed)
```
were failing because AES-GCM wasn't enabled in libssh2. This in turn
happened because the `WOLFSSL_AESGCM_STREAM` macro wasn't enabled while
building wolfSSL. Which happened because this macro isn't enabled by
any CMake-level wolfSSL option. Passing it as `CPPFLAGS` fixes it.

This allows enabling tests with wolfSSL 5.7.0.

Follow-up to d4cea53f53 #1408
Closes #1409
2024-06-22 01:56:17 +02:00
d4cea53f53 ci/GHA: add Linux job with latest wolfSSL built from source
After this patch it's possible to run tests with wolfSSL 5.7.0.

wolfSSL 5.7.0 fixes this bug that affects open issues #1020 and #1299:
https://github.com/wolfSSL/wolfssl/pull/7143

`-DWOLFSSL_OPENSSLALL=ON` is necessary for `wolfSSL_FIPS_mode()`

Closes #1408
2024-06-22 00:52:47 +02:00
2c63303384 ci/GHA: tidy up build-from-source steps [ci skip]
- make curl downloads less verbose.

- fix cmake warning:
  ```
  CMake Warning:
    No source or binary directory provided.  Both will be assumed to be the
    same as the current working directory, but note that this warning will
    become a fatal error in future CMake releases.
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/9509866494/job/26213472410#step:5:32
2024-06-22 00:29:25 +02:00
ac2e8c73b1 src: fix type warning in libssh2_sftp_unlink macro
The `libssh2_sftp_unlink` macro was implicitly casting the `size_t`
returned by `strlen` to the `unsigned int` type expected by
`libssh2_sftp_unlink_ex`.

This fix adds an explicit cast to match similar macro definitions in
the same file (e.g. `libssh2_sftp_rename`, `libssh2_sftp_mkdir`).

Closes #1406
2024-06-14 04:47:44 +02:00
c149a12721 libssh2.pc: reference mbedcrypto pkgconfig
mbedtls 3.6.0 got pkgconfig support:
a4d17b34f3

Reference it from `libssh2.pc`.

Closes #1405
2024-06-08 02:53:20 +02:00
792e1b6fbc tidy-up: typo in comment [ci skip] 2024-06-08 00:49:14 +02:00
e23dea609a RELEASE-NOTES: sync [ci skip]
Also bump planned deprecation dates.
2024-06-07 00:55:18 +02:00
dab48398b9 ci/GHA: show configure logs on failure and other tidy-ups
- dump cmake error log on configure failure. (for cmake 3.26 and newer)
- dump `config.log` on autotools configure failure.
- convert specs filename to Windows format before passing to CMake.
- add missing quotes.

Closes #1403
2024-06-05 14:05:03 +02:00
6f3d3bc8ff ci/GHA: bump parallel jobs to nproc+1
Ref: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

Closes #1402
2024-06-04 23:26:53 +02:00
b8ffa7a56d ci/GHA: show test logs on failure
Closes #1401
2024-05-31 22:34:23 +02:00
839bb84e89 ci/GHA: fix Dockerfile failing after Ubuntu package update
Likely due an upstream Ubuntu package update (requiring an apt-get
install call beforehand), tests run via autotools started failing with
no change in the libssh2 repo:
```
FAIL: test_aa_warmup
====================

Error running command 'docker build --quiet -t libssh2/openssh_server %s' (exit 256): Dockerfile:10
--------------------
   8 |      && apt-get clean \
   9 |      && rm -rf /var/lib/apt/lists/*
  10 | >>> RUN mkdir /var/run/sshd
  11 |
  12 |     # Chmodding because, when building on Windows, files are copied in with
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /var/run/sshd" did not complete successfully: exit code: 1

Failed to build docker image
Cannot stop session - none started
Cannot stop container - none started
Command: docker build --quiet -t libssh2/openssh_server ../../tests/openssh_server
FAIL test_aa_warmup (exit status: 1)
```
Ref: https://github.com/libssh2/libssh2/actions/runs/9322194756/job/25662748095#step:11:390

Fix it by skipping `mkdir` if `/var/run/sshd` already exists.

(Why cmake-based jobs aren't affected, I don't know.)

Ref: 50143d5867 (commitcomment-142560875)
Closes #1400
2024-05-31 21:21:30 +02:00
50143d5867 ci/GHA: use ubuntu-latest with OmniOS job
It's the same as ubuntu-22.04.

Also update OmniOS package search link.
2024-05-30 12:12:20 +02:00
e44f041805 ci: disable dependency tracking in autotools builds
For better build performance. Dependency tracking causes a build
overhead while compiling to help a subsequent build, but in CI there is
never one and the extra work is discarded.

Closes #1396
2024-05-27 21:41:38 +02:00
e973493f99 mbedtls: fail to compile with v3.6.0 outside CI
A compile-time failure is preferred over an unexpected one at
runtime.

The problem is silenced with a macro in CI and this macro will have
to be added to more platforms when mbedTLS v3.6.0 reaches them.

Follow-up to 2e4c5ec462 #1349
Closes #1393
2024-05-24 19:22:29 +02:00
38e50aa06e tests: drop default cygpath option -u 2024-05-24 15:40:54 +02:00
706ec36dc3 tidy-up: fix typo found by codespell
Ref: https://github.com/libssh2/libssh2/actions/runs/9224795055/job/25380857082?pr=1393#step:4:5
2024-05-24 15:39:23 +02:00
3b23e039f7 ci/GHA: shell syntax tidy-up
Closes #1390
2024-05-14 14:55:14 +02:00
64bab99e2e RELEASE-NOTES: sync [ci skip] 2024-05-11 23:28:29 +02:00
e980af729f ci/GHA: bump NetBSD/OpenBSD, add NetBSD arm64 job
OpenBSD arm64 jobs were very slow, so skipped that.

Closes #1388
2024-05-11 01:47:29 +02:00
d19b619070 autotools: fix to update LDFLAGS for each detected dependency
autotools lib detection routine failed to extend LDFLAGS for each
detection. This could cause successful detection of a dependency, but
later failing to use it. This did not cause an issue as long as all
dependencies lived under the same prefix, but started breaking on macOS
ARM + Homebrew where this was no longer true for mbedTLS and zlib in
particular.

Follow-up to 844115393b #1381
Follow-up to ae2770de25 #1377
Closes #1384
2024-05-08 23:44:14 +02:00
8b3c6e9dee OpenSSL 3: Fix calculating DSA public key (#1380) 2024-05-08 13:44:09 -07:00
5953c1f153 ci/GHA: tidy-up wolfSSL autotools config on macOS
Closes #1383
2024-05-08 22:19:54 +02:00
736e3d7d8b ci/GHA: shorter mbedTLS autotools workaround
Follow-up to 844115393b #1381
Closes #1382
2024-05-08 22:13:39 +02:00
844115393b ci: fix mbedtls runners on macOS (#1381)
Sets LDFLAGS while configuring the autoconf mbedTLS build for macOS.
2024-05-08 12:23:59 -07:00
4c4d28a9fc RELEASE-NOTES: sync [ci skip] 2024-04-29 17:11:08 +02:00
4858467199 wincng: fix DH_GEX_MAXGROUP set higher than supported
In 1c3a03ebc3 #493,
`LIBSSH2_DH_GEX_MAXGROUP` was introduced to specify
crypto-backend-specific modulus sizes. Unfortunately, the max size for
the wincng DH modulus was defined to 8192, probably because this is the
value most other backends support.

According to Microsoft documentation [1], `BCryptGenerateKeyPair`
currently only supports up to 4096-bit keys when the selected algorithm
is `BCRYPT_DH_ALGORITHM`. Requesting larger keys when calling
`BCryptGenerateKeyPair` in `_libssh2_dh_key_pair` always results in
`STATUS_INVALID_PARAMETER` being returned and ultimately key exchange
failing.

When attempting to connect to any server that offers 8192 bit DH, this
causes key exchange to always fail when using the wincng backend.
Reducing `LIBSSH2_DH_GEX_MAXGROUP` to 4096 fixes the issue.

[1] https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgeneratekeypair

Closes #1372
2024-04-29 17:07:31 +02:00
323a14b2ca build: silence warnings inside FD_SET()/FD_ISSET() macros
Use an ugly workaround to silence `-Wsign-conversion` warnings triggered
by the internals of `FD_SET()`/`FD_ISSET()` macros. They've been showing
up in OmniOS CI builds when compiling `example` programs. They also have
been seen with older Cygwin and other envs and configurations.

Also scope two related variables in examples.

E.g.:
```
../../example/direct_tcpip.c:251:9: warning: conversion to 'long unsigned int' from 'libssh2_socket_t' {aka 'int'} may change the sign of the result [-Wsign-conversion]
  251 |         FD_SET(forwardsock, &fds);
      |         ^~~~~~
../../example/direct_tcpip.c:251:9: warning: conversion to 'long unsigned int' from 'libssh2_socket_t' {aka 'int'} may change the sign of the result [-Wsign-conversion]
../../example/direct_tcpip.c:251:9: warning: conversion to 'long unsigned int' from 'long int' may change the sign of the result [-Wsign-conversion]
../../example/direct_tcpip.c:251:9: warning: conversion to 'long int' from 'long unsigned int' may change the sign of the result [-Wsign-conversion]
../../example/direct_tcpip.c:259:18: warning: conversion to 'long unsigned int' from 'libssh2_socket_t' {aka 'int'} may change the sign of the result [-Wsign-conversion]
  259 |         if(rc && FD_ISSET(forwardsock, &fds)) {
      |                  ^~~~~~~~
../../example/direct_tcpip.c:259:18: warning: conversion to 'long unsigned int' from 'libssh2_socket_t' {aka 'int'} may change the sign of the result [-Wsign-conversion]
../../example/direct_tcpip.c:259:18: warning: conversion to 'long unsigned int' from 'long int' may change the sign of the result [-Wsign-conversion]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/8854199687/job/24316762831#step:3:2020

Closes #1379
2024-04-29 01:16:21 +02:00
6556bfbd43 autotools: use AM_CFLAGS
Use `AM_CFLAGS` to pass custom, per-target C flags. This replaces using
`CFLAGS` which triggered this warning when running `autoreconf -fi`:
```
tests/Makefile.am:8: warning: 'CFLAGS' is a user variable, you should not override it;
tests/Makefile.am:8: use 'AM_CFLAGS' instead
```
(Only for `tests`, even though `example` and `src` also used this
method. The warning is also missing from curl, that also uses
`CFLAGS`.)

Follow-up to 3ec53f3ea2 #1286
Closes #1378
2024-04-26 22:58:55 +02:00