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
5e65dd87dd ci: don't parallelize distcheck job
A while ago the `distcheck` CI job became flaky. This continued after
switching to Debian stable (from testing). Try stabilzing it by running
it single-threaded.

Closes #1339
2024-03-28 22:20:00 +00:00
97aa8388aa Dockerfile: switch to Debian stable (from testing)
This fixes flakiness experienced recently with two OpenSSL jobs and one
libgcrypt job, and/or intermittently causing all Docker-based tests to
fail.

Reported-by: András Fekete
Fixes #1328
Fixes #1329
Closes #1338
2024-03-28 22:18:45 +00:00
b27383918e Supply empty hash functions for mac_method_hmac_aesgcm to avoid a crash when e.g. setting LIBSSH2_METHOD_CRYPT_CS (#1321) 2024-02-22 15:39:12 -08:00
f1133c75da gen_publickey_from_dsa: Initialize BIGNUMs to NULL for OpenSSL 3 (#1320) 2024-02-20 16:23:03 -08:00
4bba038eb6 RELEASE-NOTES: add algo deprecation notices [ci skip]
Closes #1307
2024-01-23 23:10:26 +00:00
cd61734dad RELEASE-NOTES: sync [ci skip] 2024-01-22 16:46:28 +00:00
76e7a68ab0 wolfssl: enable debug logging in wolfSSL when compiled in (#1310)
Co-authored-by: Viktor Szakats
2024-01-22 17:02:19 +01:00
8457c37afd os400: maintain up to date (#1309)
- Handle MD5 conditionals in os400qc3.
- Check for errors in os400qc3 pbkdf1.
- Implement an optional build options override file.
- Sync ILE/RPG copy files with current C header files.
- Allow a null session within a string conversion cache.
- Add an ILE/RPG example.
- Adjust outdated copyrights in changed files.
2024-01-19 20:37:34 +01:00
aea63ad997 RELEASE-NOTES: sync 2024-01-18 23:58:16 +00:00
4718ede4e0 src: check hash update/final success
Also:
- delete unused internal macro `libssh2_md5()` where defined.
- prefix `libssh2_os400qc3_hash*()` function names with underscore.
  These are public/visible, but internal.
- add FIXMEs to OS/400 code to verify update/final calls; some OS API,
  some internal.

Ref: https://github.com/libssh2/libssh2/pull/1301#discussion_r1446861650
Reviewed-by: Michael Buckley
Reviewed-by: Patrick Monnerat
Closes #1303
2024-01-18 23:54:29 +00:00
4f551d2bac RELEASE-NOTES: sync [ci skip] 2024-01-18 21:32:05 +00:00
f2945905fb openssl: fix cppcheck found NULL dereferences (#1304)
* Fix NULL dereference in gen_publickey_from_rsa_evp and
  gen_publickey_from_dsa_evp.
* Add checks for en_publickey_from_ec_evp and en_publickey_from_ed_evp
2024-01-18 20:37:52 +01:00
34aff5ffef openssl: delete internal read_openssh_private_key_from_memory()
It was wrapping another internal function with no added logic.

Closes #1306
2024-01-12 06:37:14 +00:00
ade785d251 openssl: formatting/whitespace
Also use `NULL` instead of `0` for pointers.

Closes #1305
2024-01-12 01:14:23 +00:00
ba27bbe7c9 HACKING-CRYPTO: more fixups [ci skip]
Follow-up to f64885b6ab #1297
2024-01-12 01:11:58 +00:00
cf5364f303 HACKING-CRYPTO: fixups [ci skip]
Follow-up to f64885b6ab #1297
2024-01-12 01:00:53 +00:00
4558f0c2e8 RELEASE-NOTES: sync [ci skip] 2024-01-10 16:35:34 +00:00
2ed9eb92f3 src: check hash init success
Before this patch, SHA2 and SHA1 init function results were cast to
`void`. This patch makes sure to verify these values.

Also:
- exclude an `assert(0)` from release builds in `_libssh2_sha_algo_ctx_init()`.
  (return error instead)
- fix indentation / whitespace

Reviewed-by: Michael Buckley
Closes #1301
2024-01-10 16:32:26 +00:00
f64885b6ab mac: handle low-level errors
- update low-level hmac functions from macros to functions.
- libgcrypt: propagate low-level hmac errors.
- libgcrypt: add error checks for hmac calls.
- os400qc3: add error checks, propagate them.
  Assisted-by: Patrick Monnerat
- mbedtls: fix propagating low-level hmac errors.
- wincng: fix propagating low-level hmac errors.
- mac: verify success of low-level hmac functions.
- knownhost: verify success of low-level hmac functions.
- transport: verify success of MAC hash call.
- minor type cleanup in wincng.
- delete unused ripemd wrapper in wincng.
- delete unused SHA384 wrapper in mbedtls.

Reported-by: Paul Howarth
Reviewed-by: Michael Buckley
Closes #1297
2024-01-10 16:32:22 +00:00
f52ffc1ccd Fix an out-of-bounds read in _libssh2_kex_agree_instr when searching for a KEX not in the server list (#1302) 2024-01-08 15:04:52 -08:00
b109f304cf RELEASE-NOTES: sync [ci skip] 2023-12-21 21:50:21 +00:00
e190e5b269 ci/appveyor: re-enable parallel mode
The comment cited earlier is no longer true with recent CMake versions.
This options does actually enable parallel builds with MSVC since CMake
v3.26.0: https://gitlab.kitware.com/cmake/cmake/-/issues/20564

The effect isn't much for libssh2, because it spends most time in tests,
but let's enable it anyway for efficiency.

Ref: 0d08974633 #884
Ref: 7a039d9a7a #867

Closes #1294
2023-12-21 21:42:02 +00:00
b08cfbc99f ci/gha: review/fixup auto-cancel settings
- use the group expression from `reuse.yml` (via curl).
- add auto-cancel for `ci` and `cifuzz`.
- add auto-cancel to `appveyor_docker`. I'm just guessing here.
  The hope is that it fixes AppVeyor CI runs when re-pushing a PR.
  This frequently caused the freshly pushed session to fail waiting for
  a connection.
- sync group expression in `appveyor_status` with `reuse`.

Closes #1292
2023-12-21 21:41:41 +00:00
b7050d9e0a RELEASE-NOTES: fix casing in GitHub names [ci skip] 2023-12-19 16:06:09 +00:00
f0e23dae91 RELEASE-NOTES: synced [ci skip]
Closes #1279
2023-12-19 12:33:45 +00:00
d34d9258b8 src: add 'strict KEX' to fix CVE-2023-48795 "Terrapin Attack"
Refs:
https://terrapin-attack.com/
https://seclists.org/oss-sec/2023/q4/292
https://osv.dev/list?ecosystem=&q=CVE-2023-48795
https://github.com/advisories/GHSA-45x7-px36-x8w8
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-48795

Fixes #1290
Closes #1291
2023-12-19 12:25:36 +00:00
c0f69548be session: add libssh2_session_callback_set2()
Add new `libssh2_session_callback_set2()` API that deprecates
`libssh2_session_callback_set()`.

The new implementation offers the same functionality, but accepts and
returns a generic function pointer (of type `libssh2_cb_generic *`), as
opposed to the old function that used data pointers (`void *`). The new
solution thus avoids data to function (and vice versa) pointer
conversions, which has undefined behaviour in standard C.

About the name: It seems the `*2` suffix was used in the past for
replacement functions for deprecated ones. Let's stick with that.
`*_ex` was preferred for new functions that extend existing ones with
new features.

Closes #1285
2023-12-18 15:02:17 +00:00
3ec53f3ea2 build: enable -pedantic-errors
According to the manual, this isn't the same as `-Werror -pedantic`.
Enable it together with `-Werror`.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1

This option results in autotools feature detection going into crazies.
To avoid this, we add it to `CFLAGS` late. Idea copied from curl.

This option has an effect only with gcc 5.0 and newer as of this commit.
Let's enable it for clang and older versions too for simplicity. Ref:
d5c0351055
https://github.com/curl/curl/pull/2747

Closes #1286
2023-12-17 15:15:34 +00:00
f8c4579439 build: add mingw-w64 support to LIBSSH2_PRINTF() attribute
And fix the warning it detected.

Closes #1287
2023-12-17 15:12:55 +00:00
9839ebe5e9 libssh2.h: add deprecated function warnings
With deprecated-at versions and suggested replacement function.

It's possible to silence them by defining `LIBSSH2_DISABLE_DEPRECATION`.

Also add depcreated-at versions to documentation, and unify wording.

Ref: https://github.com/libssh2/libssh2/pull/1260#issuecomment-1837017987
Closes #1289
2023-12-16 17:43:02 +00:00
fc24735f61 ci/spellcheck: delete redundant option [ci skip]
`--check-hidden` not necessary when passing filenames explicitly.

Follow-up to a79218d3a0
2023-12-14 20:20:39 +00:00
7010049969 tidy-up: add empty line for clarity [ci skip] 2023-12-14 20:14:55 +00:00
ac68fbe475 build: FIXME -Wsign-conversion to be errors [ci skip] 2023-12-13 06:33:54 +00:00
6e451669ea src: disable -Wsign-conversion warnings, add option to re-enable
To avoid the log noise till we fix those ~360 compiler warnings.

Also add macro `LIBSSH2_WARN_SIGN_CONVERSION` to re-enable them.

Follow-up to afa6b86560 #1257

Closes #1284
2023-12-13 04:39:58 +00:00
0f45dafe5e cmake: fix indentation [ci skip] 2023-12-13 02:41:05 +00:00
94b6bad3c8 example, tests: call WSACleanup() for each WSAStartup()
On Windows.

Closes #1283
2023-12-13 01:28:14 +00:00
52c382f7aa RELEASE-NOTES: update credits [ci skip]
Ref: https://github.com/libssh2/libssh2/pull/1241#issuecomment-1830118584
2023-12-09 21:02:27 +00:00
b77504837c RELEASE-NOTES: avoid splitting names, fix typo, refine order [ci skip] 2023-12-09 19:00:31 +00:00
747862c0e2 RELEASE-NOTES: synced [ci skip] 2023-12-09 18:02:06 +00:00
28dbf01667 add portable LIBSSH2_SOCKET_CLOSE() macro
Add `LIBSSH2_SOCKET_CLOSE()` to the public `libssh2.h` header, for user
code. It translates to `closesocket()` on Windows and `close()` on other
platforms.

Use it in example code.

It makes them more readable by reducing the number of `_WIN32` guards.

Closes #1278
2023-12-08 11:19:04 +00:00
46333adfb8 ci: add FreeBSD 14 job, fix issues
- install bash to fix error when running tests:
  ```
  ERROR: test_sshd.test - missing test plan
  ERROR: test_sshd.test - exited with status 127 (command not found?)
  =====================================
  [...]
  # TOTAL: 4
  # PASS:  2
  # SKIP:  0
  # XFAIL: 0
  # FAIL:  0
  # XPASS: 0
  # ERROR: 2
  [...]
  env: bash: No such file or directory
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/7133852508/job/19427420687#step:3:3998

- fix sshd issue when running tests:
  ```
    # sshd log:
    #  Server listening on :: port 4711.
    #  Server listening on 0.0.0.0 port 4711.
    #  Authentication refused: bad ownership or modes for file /home/runner/work/libssh2/libssh2/tests/key_rsa.pub
    #  Authentication refused: bad ownership or modes for file /home/runner/work/libssh2/libssh2/tests/openssh_server/authorized_keys
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/7134629175/job/19429828342#step:3:4059

Cherry-picked from #1277
Closes #1277
2023-12-08 02:04:18 +00:00
5e0ec99134 ci: add OmniOS job, fix issues
- use GNU Make, to avoid errors:
  ```
  make: Fatal error in reader: Makefile, line 983: Badly formed macro assignment
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/7134629175/job/19429838379#step:3:1956

  Caused by `?=` in `Makefile.am`. Fix it just in case.

  ```
  make: Fatal error in reader: Makefile, line 438: Unexpected end of line seen
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/7135524843/job/19432451767#step:3:1966

  It's around line 43 in `Makefile.am`, reason undiscovered.

- fix error:
  ```
  ../../src/hostkey.c:1227:44: error: pointer targets in passing argument 5 of '_libssh2_ed25519_sign' differ in signedness [-Werror=pointer-sign]
     1227 |                                  datavec[0].iov_base, datavec[0].iov_len);
          |                                  ~~~~~~~~~~^~~~~~~~~
          |                                            |
          |                                            caddr_t {aka char *}
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/7135102832/job/19431233967#step:3:2225

  https://docs.oracle.com/cd/E36784_01/html/E36887/iovec-9s.html

- FIXME: new `-Wsign-conversion` warnings appeared in examples:
  ```
  ../../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/7136086865/job/19433997429#step:3:3450

Cherry-picked from #1277
2023-12-08 02:02:44 +00:00
3f60ccb76b example: use libssh2_socket_t in X11 example
Cherry-picked from #1277
2023-12-08 02:01:18 +00:00
798ed4a7e5 Handle EINTR from send/recv/poll/select to try again as the error is not fatal
Integration-patches-by: Viktor Szakats
Fixes #955
Closes #1058
2023-12-06 15:46:32 +00:00
d0a7f1da21 appveyor: delete UWP job broken since Visual Studio upgrade
Few days ago UWP job started permafailing.

fail: https://ci.appveyor.com/project/libssh2org/libssh2/builds/48678129/job/yb8n2pox8mfjwv6m
good: https://ci.appveyor.com/project/libssh2org/libssh2/builds/48673013

Other projects also affected:
https://ci.appveyor.com/project/c-ares/c-ares/builds/48687390/job/l0fo4b0sijvqkw9r

No related local update. Same CMake version. Same CI image.

This seems to be the culprit, which could mean that this update broke
CMake detection, needs a different CMake configuration on our end, or
that this MSVC update pulled support for UWP apps:

fail: -- The C compiler identification is MSVC 19.38.33130.0 (~ Visual Studio 2022 v17.8)
good: -- The C compiler identification is MSVC 19.37.32825.0 (~ Visual Studio 2022 v17.7)

If this is v17.8, release notes don't readily suggest a feature removal:
https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8

So it might just be UWP accidentally broken in this release.

Closes #1275
2023-12-06 14:56:15 +00:00
8cd473c930 checksrc: sync with curl
Closes #1272
2023-12-06 01:13:15 +00:00
e051ae343a autotools: delete --disable-tests option, fix CI tests
Originally added to improve build performance by skipping building
tests. But, there seems to be no point in this, because autotools
doesn't build tests by default, unless explicitly invoking
`make check`.

Delete this option from Cygwin and FreeBSD CI tests, where it caused
`make check` to do nothing. Tests are built now, and runtime tests are
too, where supported.

Also disable Docker-based tests for these, and add a missing `make -j3`
for FreeBSD.

Reverts 7483edfada #715

Closes #1271
2023-12-06 00:55:15 +00:00
b1414503f5 build: add LIBSSH2_NO_DEPRECATED option (#1266)
The following APIs have been deprecated for over 10 years and
use `LIBSSH2_NO_DEPRECATED` to mark them as deprecated:

libssh2_session_startup()
libssh2_banner_set()
libssh2_channel_receive_window_adjust()
libssh2_channel_handle_extended_data()
libssh2_scp_recv()

Add these options to disable them:
- autotools: `--disable-deprecated`
- cmake: `-DLIBSSH2_NO_DEPRECATED=ON`
- `CPPFLAGS`: `-DLIBSSH2_NO_DEPRECATED`

Fixes #1259
Replaces #1260
Co-authored-by: Viktor Szakats
Closes #1267
2023-12-06 00:14:53 +01:00
a3f5594a96 autotools: show the default for hidden-symbols option
Closes #1269
2023-12-05 02:14:23 +00:00
2e5a8719d7 tidy-up: bump casts from int to long for large C99 types in printfs
Cast large integer types to avoid dealing with printf masks for
`size_t` and other C99 types. Some of existing code used `int`
for this, bump them to `long`.

Ref: afa6b86560 #1257

Closes #1264
2023-12-04 13:11:28 +00:00