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
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
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
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
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)
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
* 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.
* 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
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
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
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
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
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.
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