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
Gabriel Smith
bd9c65d68c sftp: Prevent files from being skipped if the output buffer is too small (#746)
Notes:
LIBSSH2_ERROR_BUFFER_TOO_SMALL is returned if the buffer is too small
to contain a returned directory entry. On this condition we jump to the
label `end`. At this point the number of names left is decremented
despite no name being returned.

As suggested in #714, this commit moves the error label after the
decrement of `names_left`.

Fixes #714

Credit:
Co-authored-by: Gabriel Smith <gabriel.smith@precisionot.com>
2022-09-23 10:03:56 -07:00
bgermann
91adeae486 Drop advertisement clause on Blowfish (#747)
Originally driven by https://github.com/pyca/bcrypt/issues/169, OpenBSD
removed Niels Provos's BSD advertisement clause in version 7.1:

https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/lib/libsa/blowfish.c.diff?r1=1.1&r2=1.2
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/lib/libsa/blowfish.h.diff?r1=1.1&r2=1.2

This enables using libssh2 in GPL software.
2022-09-20 15:29:05 -07:00
zhaochongliu
09f0ffd9fb Support building with gcc < version 8
Files: CMakeLists.txt

Notes: don't use gcc arguments that don't exist in gcc versions lower than 8 if building with older gcc.

Credit:
zhaochongliu
2022-09-07 10:54:25 -07:00
Miguel de Icaza
6c59eea5a9 Document the obscure LIBSSH2_ERROR_BAD_USE when writing to a channel (#713)
Document the obscure LIBSSH2_ERROR_BAD_USE when writing to a channel

Credit:
Miguel de Icaza
2022-08-16 09:13:51 -07:00
Michael Buckley
31ae48885d Don't erroneously log SSH_MSG_REQUEST_FAILURE packets from keepalive (#727)
Notes:
When setting a ServerAliveInterval using libssh2_keepalive_config() with want_reply set to true, some servers will reply to the keep-alive requests with a single SSH_MSG_REQUEST_FAILURE packet. This is an allowed behavior in RFC 4254, section 4.

Credit:
Michael Buckley
2022-08-16 09:09:47 -07:00
Ryan Kelley
891ee16ab6 Updating docs for libssh2_channel_flush_ex (#728)
Notes:
In #614 it was identified the docs do not accurately show how libssh2_channel_flush_ex() return value is set. I have updated the doc's to correctly show what the function is returning.

Credit:
Ryan Kelley
2022-08-09 17:05:35 -07:00
Sandeep Bansal
4b21e49d9d Support RSA certificate authentication (#710)
* Adding support for signed RSA keys and unit test

Credit:
Sandeep Bansal
2022-07-28 08:57:34 -07:00
Viktor Szakats
7483edfada configure: add --disable-tests option 2022-07-02 11:54:39 +02:00
Viktor Szakats
3adc8e9081 cmake: do not add libssh2.rc to the static library 2022-05-26 15:12:11 +02:00
AyushiN
3af1f4f446 Fixed typo #697 (#701)
Credit:
AyushiN
2022-05-23 10:35:28 -07:00
Viktor Szakats
b952674f12 Openssl: add support for LibreSSL 3.5.x (#700)
LibreSSL 3.5.0 made more structures opaque, so let's enable existing
support for that when building against these LibreSSL versions.

Ref: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.5.0-relnotes.txt

Credit:
Viktor Szakats
2022-05-19 09:35:16 -07:00
Michael Buckley
4b057bd2d9 Ensure KEX replies don't include extra bytes (#696)
Addresses #695

Credit:
Michael Buckley, reported by Harry Sintonen
2022-05-06 08:40:19 -07:00
Zenju
dba9ad9d3d Fix buffer overflow during SSH_MSG_USERAUTH_BANNER (#693)
File: userauth.c
Notes:
This patch fixes application crashes due to heap corruption. Turns out the null terminator is written one byte outside of the allocated area.
Credit:
Zenju
2022-04-25 11:49:11 -07:00
Will Cosgrove
dd0b5b2d2b Changed NULL check to avoid logic change 2022-04-11 09:49:00 -07:00
Will Cosgrove
3489ee9a6f NULL check before calling session_handshake 2022-04-11 09:46:52 -07:00
Harry Sintonen
b95e758239 Fix build since openssl 1.1.0 when ECDSA and/or RIPEMD are disabled (#666)
File: openssl.h

Notes:
In openssl 1.1.0 and later openssl decided to change some of the defines used to check if certain features are not compiled in the libraries. This updates the define checks.

Credit:
Harry Sintonen
Co-authored-by: Harry Sintonen <sintonen@iki.fi>
2022-04-04 17:00:04 -07:00
gbaraldi
79855b37d2 Add RSA-SHA2 support for the mbedtls backend (#688)
File: mbedtls.c

Notes: 
* Add sha2 support for RSA key upgrading to mbedTLS backend

Credit:
gbaraldi
2022-04-04 16:57:10 -07:00
Daniel Stenberg
e7e1312b0c misc/libssh2_copy_string: avoid malloc zero bytes
Avoids the inconsistent malloc return code for malloc(0)

Closes #686
2022-03-21 15:11:05 +01:00
Marc Hoersken
049003c3d6 wincng: rename struct field referring to the DH private big number
Closes #684
2022-03-17 04:35:10 +01:00
Marc Hoersken
c2c877b70b tests/openssh_fixture.c: print command after variable expansion 2022-03-16 22:54:33 +01:00
Marc Hoersken
87d208c95d CI: store and reuse OpenSSH Server docker image used for tests
Supersedes #588
Fixes #665
Closes #685
2022-03-16 22:37:07 +01:00
Will Cosgrove
292830abb8 Added LibreSSL to crypto backend list 2022-02-26 10:53:14 -08:00
Will Cosgrove
b0b2b3112c Added crypto backend list to template
Added OS version as well
2022-02-23 09:20:38 -08:00
Will Cosgrove
ec7f782d7f Revert "Option to build both static and shared libraries (#547)" (#675)
This reverts commit b60dca8b64.

#547 doesn't build clean anymore with the keyboard interactive changes.
2022-02-19 15:57:12 -08:00
berney
b60dca8b64 Option to build both static and shared libraries (#547)
files: cmakelists.txt

Notes:
* Option to build both static and shared libraries when using CMake

Credit:
berney
2022-02-19 15:50:48 -08:00
xalopp
83853f8aea Use modern API in userauth_keyboard_interactive() (#663)
Files: userauth_kbd_packet.c, userauth_kbd_packet.h, test_keyboard_interactive_auth_info_request.c, userauth.c

Notes:
This refactors `SSH_MSG_USERAUTH_INFO_REQUEST` processing in `userauth_keyboard_interactive()` in order to improve robustness, correctness and readability or the code.

* Refactor userauth_keyboard_interactive to use new api for packet parsing
* add unit test for userauth_keyboard_interactive_parse_response()
* add _libssh2_get_boolean() and _libssh2_get_byte() utility functions

Credit:
xalopp
2022-02-19 15:46:40 -08:00
xalopp
ead7000d28 Fix formatting in manual page (#667)
Fixed formatting of `LIBSSH2_ERROR_AUTHENTICATION_FAILED` in the errors section.

credit: xalopp
2022-02-03 10:13:36 -08:00
tihmstar
2a2aaed3b6 NULL terminate server_sign_algorithms string (#669)
files: packet.c, libssh2_priv.h

notes:
* Fix heap buffer overflow in _libssh2_key_sign_algorithm

When allocating `session->server_sign_algorithms` which is a `char*` is is important to also allocate space for the string-terminating null byte at the end and make sure the string is actually null terminated.

Without this fix, the `strchr()` call inside the `_libssh2_key_sign_algorithm` (line 1219) function will try to parse the string and go out of buffer on the last invocation.

Credit: tihmstar
Co-authored-by: Will Cosgrove <will@panic.com>
2022-02-03 10:11:36 -08:00
Will Cosgrove
30fc410b97 free RSA2 related memory (#664)
Free `server_sign_algorithms` and `sign_algo_prefs`.
2022-01-18 11:28:13 -08:00
Will Cosgrove
de7a74aff2 Legacy Agent support for rsa2 key upgrading/downgrading #659 (#662)
Files: libssh2.h, agent.c, userauth.c

Notes:
Part 2 of the fix for #659. This adds rsa key downgrading for agents that don't support sha2 upgrading. It also adds better trace output for debugging/logging around key upgrading.

Credit:
Will Cosgrove (signed off by Michael Buckley)
2022-01-14 11:55:18 -08:00
Ian Hattendorf
50a1262772 Support rsa-sha2 agent flags (#661)
File: agent.c
Notes: implements rsa-sha2 flags used to tell the agent which signing algo to use.
 https://tools.ietf.org/id/draft-miller-ssh-agent-01.html#rfc.section.4.5.1

Credit:
Ian Hattendorf
2022-01-13 15:05:53 -08:00
Sunil Nimmagadda
d5ed0e6536 ssh: Add support for userauth banner.
The new libssh2_userauth_banner API allows to get an optional
userauth banner sent with SSH_MSG_USERAUTH_BANNER packet by the
server.

Closes #610
2022-01-13 15:35:29 +01:00
Michael Buckley
13ad7b2f5c Fix a memcmp errors in code that was changed from memmem to memcmp (#656)
Notes:
Fixed supported algo prefs list check when upgrading rsa keys

Credit: Michael Buckley
2022-01-06 13:56:22 -08:00
Hayden Roche
17c9c1fcdf Add support for a wolfSSL crypto backend. (#629)
It uses wolfSSL's OpenSSL compatibility layer, so rather than introduce new
wolfssl.h/c files, the new backend just reuses openssl.h/c. Additionally,
replace EVP_Cipher() calls with EVP_CipherUpdate(), since EVP_Cipher() is not
recommended.

Credit: Hayden Roche
2022-01-06 10:25:34 -08:00
Bastien Durel
e24a4a9d48 Runtime engine detection with libssh2_crypto_engine() (#643)
File:
version.c, HACKING-CRYPTO, libssh2.h, libssh2_crypto_engine.3, makefile.

Notes:
libssh2_crypto_engine() API to get crypto engine at runtime.

Credit: Bastien Durel
2022-01-06 10:06:02 -08:00
Will Cosgrove
64a555d6f5 RSA SHA2 256/512 key upgrade support RFC 8332 #536 (#626)
Notes:
* Host Key RSA 256/512 support #536
* Client side key hash upgrading for RFC 8332
* Support for server-sig-algs, ext-info-c server messages
* Customizing preferred server-sig-algs via the preference LIBSSH2_METHOD_SIGN_ALGO

Credit: Anders Borum, Will Cosgrove
2022-01-06 09:50:58 -08:00
xalopp
967792c896 fix: use userauth name length to check memory boundaries for userauth name, fixes #653 (#654)
File: userauth.c

Notes:
Fixes `userauth_kybd_auth_name_len` length check 

Co-authored-by: Xaver Lopenstedt <xaver@lopenstedt.de>
2022-01-05 10:35:26 -08:00
Daniel Stenberg
552e20df38 agent: handle overly large comment lengths (#651)
Reported-by: Harry Sintonen
2021-12-17 08:56:29 -08:00
Daniel Stenberg
37ee0aa214 userauth: check for too large userauth_kybd_auth_name_len (#650)
... before using it.

Reported-by: MarcoPoloPie
Fixes #649
2021-12-17 08:46:29 -08:00
Daniel Stenberg
6c662e7b17 .github/SECURITY.md: fix the URL 2021-12-17 16:50:20 +01:00
Daniel Stenberg
1494e6c9f4 .github/SECURITY.md: add security policy 2021-12-17 16:48:53 +01:00
Will Cosgrove
9990b38d27 hostkey_method_ssh_ed25519_init() check key bounds (#645)
* hostkey_method_ssh_ed25519_init() check key bounds

File: hostkey.c

Notes:
Additional key length checking before calling _libssh2_ed25519_new_public()

Credit:
Will Cosgrove
2021-11-30 13:21:36 -08:00
Will Cosgrove
69f3cf0bea Fix error message in memory_read_privatekey #636
file: userauth.c
note: fix error message
credit:
volund
2021-11-18 10:38:32 -08:00
cntrump
3332d95396 Update maketgz for macOS (#543)
File:
maketgz

Notes:
Fix error on macOS: sed: -e: No such file or directory

Credit:
cntrump
2021-11-11 11:35:47 -08:00
Jun Tseng
a77ca0fcd3 CMake update minimum version to 2.8.12 (#639)
File:
CMakeLists.txt

Notes:
Following CMake's advice, Update the minimum required version.

Credit:
Jun Tseng
2021-11-10 16:09:04 -08:00
David Korczynski
1a799d30ca ci: Add CIFuzz integration
Notes:
Add CIFuzz integration to run fuzzer using the OSS-Fuzz infrastructure
at each PR.

Signed-off-by: David Korczynski <david@adalogics.com>
Closes #635
2021-11-08 17:35:40 +01:00
Uwe L. Korn
1f0fe7443a Use libssh2_EXPORTS as an alternative to _WINDLL (#470)
Files: libssh2.h

Notes:
`_WINDLL` is only defined when a Visual Studio CMake generator is used, `libssh2_EXPORTS` is used though for all CMake generator if a shared libssh2 library is being built.

Credit:
Uwe L. Korn
2021-10-26 09:21:56 -07:00
Viktor Szakats
d39e9ccc5e windows: fix clang and WinCNG warnings
Fix these categories of warning:

- in `wincng.c` disagreement in signed/unsigned char when passing around
  the passphrase string:
  `warning: pointer targets in passing argument [...] differ in signedness [-Wpointer-sign]`
  Fixed by using `const unsigned char *` in all static functions and
  applying/updating casts as necessary.

- in each use of `libssh2_*_init()` macros where the result is not used:
  `warning: value computed is not used [-Wunused-value]`
  Fixed by using `(void)` casts.

- `channel.c:1171:7: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  Fixed by initializing this variable with `LIBSSH2_ERROR_CHANNEL_UNKNOWN`.
  While there I replaced a few 0 literals with `LIBSSH2_ERROR_NONE`.

- in `sftp.c`, several of these two warnings:
  `warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  `warning: 'data_len' may be used uninitialized in this function [-Wmaybe-uninitialized]`
  Fixed by initializing these variables with NULL and 0 respectively.

- Also removed the exec attribute from `wincng.h`.

Notes:
- There are many pre-existing checksrc issues.
- The `sftp.c` and `channel.c` warnings may apply to other platforms as well.

Closes #628
2021-10-01 20:09:03 +00:00
Daniel Stenberg
db34d2c400 README: use www.libssh2.org for the license link 2021-09-25 16:21:33 +02:00
Daniel Stenberg
4bcf8415a7 libssh2.h: bump it to 1.10.1-dev 2021-09-16 12:56:20 +02:00