1
1

1194 Коммитов

Автор SHA1 Сообщение Дата
Marc Hoersken
6c99a18577
wincng: add and improve checks in bit counting function 2020-06-14 19:36:32 +02:00
Marc Hoersken
e7d5439119
wincng: align bits to bytes calculation in all functions 2020-06-14 19:35:21 +02:00
Marc Hoersken
cc00ece962
wincng: do not disable key validation that can be enabled
The modular exponentiation also works with key validation enabled.
2020-06-14 19:34:18 +02:00
Marc Hoersken
93206a7acd
wincng: fix return value in _libssh2_dh_secret
Do not ignore return value of modular exponentiation.
2020-06-14 19:32:49 +02:00
Marc Hoersken
ffab6960b5
src: add new and align include guards in header files (#480)
Make sure all include guards exist and follow the same format.
2020-05-31 23:08:15 +02:00
Marc Hoersken
ba149e804e
wincng: fix multiple definition of `_libssh2_wincng' (#479)
Add missing include guard and move global state
from header to source file by using extern.
2020-05-31 23:07:39 +02:00
Will Cosgrove
0b44e558f3
transport.c: moving total_num check from #476 (#478)
file: transport.c

notes:
moving total_num zero length check from #476 up to the prior bounds check which already includes a total_num check. Makes it slightly more readable.

credit:
Will Cosgrove
2020-05-28 14:20:08 -07:00
lutianxiong
642eec48ff
transport.c: fix use-of-uninitialized-value (#476)
file:transport.c

notes:
return error if malloc(0)

credit:
lutianxiong
2020-05-28 10:25:40 -07:00
monnerat
4e75a59e29
os400qc3.c: constify libssh2_os400qc3_hash_update() data parameter. (#469)
Files: os400qc3.c, os400qc3.h

Notes:
Fixes building on OS400. #426

Credit:
Reported-by: hjindra on github, dev by Monnerat
2020-05-15 10:26:52 -07:00
Harry Sintonen
1a082247a7
kex.c: Add diffie-hellman-group14-sha256 Key Exchange Method (#464)
File: kex.c

Notes: Added diffie-hellman-group14-sha256 kex

Credit: Harry Sintonen <sintonen@iki.fi>
2020-05-01 10:26:20 -07:00
Will Cosgrove
e238df7353
os400qc3.h: define sha512 macros (#465)
file: os400qc3.h
notes: fixes for building libssh2 1.9.x
2020-04-30 11:27:41 -07:00
Will Cosgrove
1e57d61b01
os400qc3.h: define EC types to fix building #426 (#462)
File: os400qc3.h
Notes: define missing EC types which prevents building
Credit: hjindra
2020-04-17 15:28:20 -07:00
Brendan Shanks
bfcac7ccda
hostkey.c: Fix 'unsigned int'/'uint32_t' mismatch (#461)
File: hostkey.c

Notes: 
These types are the same size so most compilers are fine with it, but CodeWarrior (on classic MacOS) throws an ‘illegal implicit conversion’ error

Credit: Brendan Shanks
2020-04-06 10:13:54 -07:00
Tseng Jun
ee3abe0408
openssl.c: minor changes of coding style (#454)
File: openssl.c

Notes:
minor changes of coding style and align preprocessor conditional for #439

Credit:
Tseng Jun
2020-03-03 11:57:21 -08:00
Hans Meier
b3b45813d6
openssl.c: Fix for use of uninitialized aes_ctr_cipher.key_len (#453)
File: 
Openssl.c

Notes:
* Fix for use of uninitialized aes_ctr_cipher.key_len when using HAVE_OPAQUE_STRUCTS, regression from #439 

Credit:
Hans Meirer, Tseng Jun
2020-02-27 09:35:35 -08:00
Zenju
0effd5d415
agent.c: Fix Unicode builds on Windows (#417)
File: agent.c

Notes:
Fixes unicode builds for Windows in Visual Studio 16.3.2.

Credit:
Zenju
2020-02-26 11:35:33 -08:00
Hans Meier
508203da9b
openssl.c: Fix use-after-free crash in openssl backend without memory leak (#439)
Files: openssl.c

Notes:
Fixes memory leaks and use after free AES EVP_CIPHER contexts when using OpenSSL 1.0.x.

Credit:
Hans Meier
2020-02-26 11:06:12 -08:00
Romain Geissler @ Amadeus
ff9f228389
Session.c: Fix undefined warning when mixing with LTO-enabled libcurl. (#449)
File: Session.c

Notes:
With gcc 9, libssh2, libcurl and LTO enabled for all binaries I see this
warning (error with -Werror):

vssh/libssh2.c: In function ‘ssh_statemach_act’:
/data/mwrep/rgeissler/ospack/ssh2/BUILD/libssh2-libssh2-03c7c4a/src/session.c:579:9: error: ‘seconds_to_next’ is used uninitialized in this function [-Werror=uninitialized]
  579 |     int seconds_to_next;
      |         ^
lto1: all warnings being treated as errors

Gcc normally issues -Wuninitialized when it is sure there is a problem,
and -Wmaybe-uninitialized when it's not sure, but it's possible. Here
the compiler seems to have find a real case where this could happen. I
looked in your code and overall it seems you always check if the return
code is non null, not often that it's below zero. I think we should do
the same here. With this patch, gcc is fine.

Credit:
Romain-Geissler-1A
2020-02-18 11:59:00 -08:00
Zenju
03c7c4a351
transport.c: Fix crash with delayed compression (#443)
Files: transport.c

Notes:
Fixes crash with delayed compression option using Bitvise server.

Contributor:
Zenju
2020-02-05 15:02:56 -08:00
Zenju
24fd419bde ssh-ed25519: Support PKIX + calc pubkey from private (#416)
Files: openssl.c/h
Author: Zenju
Notes:
Adds support for PKIX key reading by fixing:

_libssh2_pub_priv_keyfile() is missing the code to extract the ed25519 public key from a given private key

_libssh2_ed25519_new_private_frommemory is only parsing the openssh key format but does not understand PKIX (as retrieved via PEM_read_bio_PrivateKey)
2019-12-13 13:35:00 -08:00
Will Cosgrove
336bd86d2c
packet.c: improved parsing in packet_x11_open (#410)
Use new API to parse data in packet_x11_open() for better bounds checking.
2019-09-13 09:45:34 -07:00
Michael Buckley
e5dbd6f20c knownhost.c: Double the static buffer size when reading and writing known hosts (#409)
Notes:
We had a user who was being repeatedly prompted to accept a server key repeatedly. It turns out the base64-encoded key was larger than the static buffers allocated to read and write known hosts. I doubled the size of these buffers.

Credit:
Michael Buckley
2019-09-12 14:51:45 -07:00
Will Cosgrove
80d3ea5b41
packet.c: improved packet parsing in packet_queue_listener (#404)
* improved bounds checking in packet_queue_listener

file: packet.c

notes:
improved parsing packet in packet_queue_listener
2019-09-04 12:16:52 -07:00
Will Cosgrove
dedcbd106f
packet.c: improve message parsing (#402)
* packet.c: improve parsing of packets

file: packet.c

notes:
Use _libssh2_get_string API in SSH_MSG_DEBUG/SSH_MSG_DISCONNECT. Additional uint32 bounds check in SSH_MSG_GLOBAL_REQUEST.
2019-08-30 09:57:38 -07:00
Will Cosgrove
e5732992b1
misc.c: _libssh2_ntohu32 cast bit shifting (#401)
To quite overly aggressive analyzers. 

Note, the builds pass, Travis is having some issues with Docker images.
2019-08-29 12:12:21 -07:00
Will Cosgrove
43f24eb152
kex.c: improve bounds checking in kex_agree_methods() (#399)
file: kex.c

notes:
use _libssh2_get_string instead of kex_string_pair which does additional checks
2019-08-27 10:58:52 -07:00
jethrogb
3319335f40 Generate debug info when building with MSVC (#178)
files: CMakeLists.txt

notes: Generate debug info when building with MSVC

credit:
jethrogb
2019-08-12 14:25:20 -07:00
Panos
378ffa9ba8 Add agent forwarding implementation (#219)
files: channel.c, test_agent_forward_succeeds.c, libssh2_priv.h, libssh2.h, ssh2_agent_forwarding.c

notes:
* Adding SSH agent forwarding.
* Fix agent forwarding message, updated example.
Added integration test code and cmake target. Added example to cmake list.

credit: 
pkittenis
2019-08-12 14:23:19 -07:00
Will Cosgrove
0ceb477ff6
global.c : fixed call to libssh2_crypto_exit #394 (#396)
* global.c : fixed call to libssh2_crypto_exit #394

File: global.c 

Notes: Don't call `libssh2_crypto_exit()` until `_libssh2_initialized` count is down to zero.

Credit: seba30
2019-07-31 13:29:29 -07:00
hlefebvre
92f76866a8 misc.c : Add an EWOULDBLOCK check for better portability (#172)
File: misc.c

Notes: Added support for all OS' that implement EWOULDBLOCK, not only VMS

Credit: hlefebvre
2019-07-30 15:50:25 -07:00
Etienne Samson
4820556950 userauth.c: fix off by one error when loading public keys with no id (#386)
File: userauth.c

Credit: 
Etienne Samson

Notes: 
Caught by ASAN:

=================================================================
==73797==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700001bcf0 at pc 0x00010026198d bp 0x7ffeefbfed30 sp 0x7ffeefbfe4d8
READ of size 69 at 0x60700001bcf0 thread T0
2019-07-04 08:35:30.292502+0200 atos[73890:2639175] examining /Users/USER/*/libssh2_clar [73797]
    #0 0x10026198c in wrap_memchr (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x1f98c)
    #1 0x1000f8e66 in file_read_publickey userauth.c:633
    #2 0x1000f2dc9 in userauth_publickey_fromfile userauth.c:1513
    #3 0x1000f2948 in libssh2_userauth_publickey_fromfile_ex userauth.c:1590
    #4 0x10000e254 in test_userauth_publickey__ed25519_auth_ok publickey.c:69
    #5 0x1000090c3 in clar_run_test clar.c:260
    #6 0x1000038f3 in clar_run_suite clar.c:343
    #7 0x100003272 in clar_test_run clar.c:522
    #8 0x10000c3cc in main runner.c:60
    #9 0x7fff5b43b3d4 in start (libdyld.dylib:x86_64+0x163d4)

0x60700001bcf0 is located 0 bytes to the right of 80-byte region [0x60700001bca0,0x60700001bcf0)
allocated by thread T0 here:
    #0 0x10029e053 in wrap_malloc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5c053)
    #1 0x1000b4978 in libssh2_default_alloc session.c:67
    #2 0x1000f8aba in file_read_publickey userauth.c:597
    #3 0x1000f2dc9 in userauth_publickey_fromfile userauth.c:1513
    #4 0x1000f2948 in libssh2_userauth_publickey_fromfile_ex userauth.c:1590
    #5 0x10000e254 in test_userauth_publickey__ed25519_auth_ok publickey.c:69
    #6 0x1000090c3 in clar_run_test clar.c:260
    #7 0x1000038f3 in clar_run_suite clar.c:343
    #8 0x100003272 in clar_test_run clar.c:522
    #9 0x10000c3cc in main runner.c:60
    #10 0x7fff5b43b3d4 in start (libdyld.dylib:x86_64+0x163d4)

SUMMARY: AddressSanitizer: heap-buffer-overflow (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x1f98c) in wrap_memchr
Shadow bytes around the buggy address:
  0x1c0e00003740: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fd fd
  0x1c0e00003750: fd fd fd fd fd fd fd fa fa fa fa fa 00 00 00 00
  0x1c0e00003760: 00 00 00 00 00 00 fa fa fa fa 00 00 00 00 00 00
  0x1c0e00003770: 00 00 00 fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x1c0e00003780: fd fd fa fa fa fa fd fd fd fd fd fd fd fd fd fa
=>0x1c0e00003790: fa fa fa fa 00 00 00 00 00 00 00 00 00 00[fa]fa
  0x1c0e000037a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0e000037e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
2019-07-15 15:49:47 -07:00
Thilo Schulz
d333e539f8 openssl.c : Fix use-after-free crash on reinitialization of openssl backend
file : openssl.c

notes : 
libssh2's openssl backend has a use-after-free condition if HAVE_OPAQUE_STRUCTS is defined and you call libssh2_init() again after prior initialisation/deinitialisation of libssh2

credit : Thilo Schulz
2019-07-12 09:56:55 -07:00
axjowa
ff2bce3057 openssl.h : Use of ifdef where if should be used (#389)
File : openssl.h

Notes : 
LIBSSH2_ECDSA and LIBSSH2_ED25519 are always defined so the #ifdef
checks would never be false.

This change makes it possible to build libssh2 against OpenSSL built
without EC support.

Change-Id: I0a2f07c2d80178314dcb7d505d1295d19cf15afd

Credit : axjowa
2019-07-12 09:55:09 -07:00
Zenju
81b2548fef Agent.c : Preserve error info from agent_list_identities() (#374)
Files : agent.c

Notes : 
Currently the error details as returned by agent_transact_pageant() are overwritten by a generic "agent list id failed" message by int agent_list_identities(LIBSSH2_AGENT* agent).

Credit :
Zenju
2019-07-01 15:01:13 -07:00
Who? Me?!
bc564e9167 Channel.c: Make sure the error code is set in _libssh2_channel_open() (#381)
File : Channel.c

Notes :
if _libssh2_channel_open() fails, set the error code.

Credit : 
mark-i-m
2019-07-01 10:03:06 -07:00
Orgad Shaneh
7d2c21c527 Kex.c, Remove unneeded call to strlen (#373)
File : Kex.c

Notes : 
Removed call to strlen

Credit : 
Orgad Shaneh
2019-07-01 10:01:04 -07:00
Pedro Monreal
f4663f9f12 Spelling corrections (#380)
Files : 
libssh2.h, libssh2_sftp.h, bcrypt_pbkdf.c, mbedtls.c, sftp.c, ssh2.c

Notes :
* Fixed misspellings

Credit :
Pedro Monreal
2019-07-01 10:00:09 -07:00
Sebastián Katzer
fd8b28658d Fix Potential typecast error for _libssh2_ecdsa_key_get_curve_type (#383)
Issue : #383 

Files : hostkey.c, crypto.h, openssl.c

Notes : 
* Fix potential typecast error for `_libssh2_ecdsa_key_get_curve_type`
* Rename _libssh2_ecdsa_key_get_curve_type to _libssh2_ecdsa_get_curve_type

Credit : 
Sebastián Katzer
2019-07-01 09:58:05 -07:00
Alexander Curtiss
86e52ba63c libgcrypt.c : Fixed _libssh2_rsa_sha1_sign memory leak. (#370)
File: libgcrypt.c

Notes : Added calls to gcry_sexp_release to free memory allocated by gcry_sexp_find_token

Credit : 
Reporter : beckmi
PR by: Alexander Curtiss
2019-05-17 10:05:16 -07:00
Orivej Desh
1130615eeb libssh2_priv.h : Fix musl build warning on sys/poll.h (#346)
File : libssh2_priv.h

Notes :
musl prints `redirecting incorrect #include <sys/poll.h> to <poll.h>`
http://git.musl-libc.org/cgit/musl/commit/include/sys/poll.h?id=54446d730cfb17c5f7bcf57f139458678f5066cc

poll is defined by POSIX to be in poll.h:
http://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html

Credit : Orivej Desh
2019-05-08 15:26:31 -07:00
Will Cosgrove
16f2d2bf86
kex.c : additional bounds checks in diffie_hellman_sha1/256 (#361)
Files : kex.c, misc.c, misc.h

Notes :
Fixed possible out of bounds memory access when reading malformed data in diffie_hellman_sha1() and diffie_hellman_sha256().

Added _libssh2_copy_string() to misc.c to return an allocated and filled char buffer from a string_buf offset. Removed no longer needed s var in kmdhgGPshakex_state_t.
2019-05-01 16:45:13 -07:00
Tseng Jun
dd74f2465b sftp.c : sftp_bin2attr() Correct attrs->gid assignment (#366)
Regression with fix for #339

Credit : Tseng Jun
2019-04-26 10:05:32 -07:00
Tseng Jun
460fe32f7d kex.c : Correct type cast in curve25519_sha256() (#365) 2019-04-25 09:55:56 -07:00
Will Cosgrove
934537c449
transport.c : scope local total_num var (#364)
file : transport.c
notes : move local `total_num` variable inside of if block to prevent scope access issues which caused #360.
2019-04-24 13:26:04 -07:00
doublex
f5e84ae241 transport.c : fixes bounds check if partial packet is read
Files : transport.c

Issue : #360

Notes : 
 'p->total_num' instead of local value total_num when doing bounds check.

Credit : Doublex
2019-04-24 09:55:59 -07:00
Will Cosgrove
8ab5c36a32
misc.c : String buffer API improvements (#332)
Files : misc.c, hostkey.c, kex.c, misc.h, openssl.c, sftp.c

Notes : 
* updated _libssh2_get_bignum_bytes and _libssh2_get_string. Now pass in length as an argument instead of returning it to keep signedness correct. Now returns -1 for failure, 0 for success.

_libssh2_check_length now returns 0 on success and -1 on failure to match the other string_buf functions. Added comment to _libssh2_check_length.

Credit : Will Cosgrove
2019-04-23 10:28:01 -07:00
doublex
a19d85319d mbedtls.c : _libssh2_mbedtls_rsa_new_private_frommemory() allow private-key from memory (#359)
File : mbedtls.c

Notes: _libssh2_mbedtls_rsa_new_private_frommemory() fixes private-key from memory reading to by adding NULL terminator before parsing; adds passphrase support.

Credit: doublex
2019-04-19 14:26:03 -07:00
Ryan Kelley
9d13d86627 Session.c : banner_receive() from leaking when accessing non ssh ports (#356)
File : session.c

Release previous banner in banner_receive() if the session is reused after a failed connection.

Credit : Ryan Kelley
2019-04-17 17:18:11 -07:00
Will Cosgrove
2b45dfcad7
Formatting in agent.c
Removed whitespace.
2019-04-11 12:12:19 -07:00
Will Cosgrove
12343f11da
Fixed formatting in agent.c
Quiet linter around a couple if blocks and pointer.
2019-04-11 12:08:43 -07:00