1
1
Граф коммитов

209 Коммитов

Автор SHA1 Сообщение Дата
Jon Simons
1c9eb4dfb9 config: fix memory leak with repeated opcodes
Fix a memory leak in the path where parsing returns early due
to seeing a repeated opcode.  A testcase is added which
demonstrates the leak and fix with valgrind.

Resolves CID 1374267.

Signed-off-by: Jon Simons <jon@jonsimons.org>
2017-09-11 16:26:41 +02:00
Nikos Mavrogiannopoulos
316ee071cf torture_options: test the setting of ciphers and MACs
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-08-24 18:01:41 +02:00
Nikos Mavrogiannopoulos
efb7635162 tests: added unit test on including config files
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 15:57:19 +02:00
Jon Simons
a4dc74064c tests: plug leak in torture_bind_options_import_key
Summary:
Hello, this is a resend for a quick memory leak fix for one of the unit
tests, originally sent to the mailing list here:

 * https://www.libssh.org/archive/libssh/2017-07/0000017.html

Test Plan:
 * Before the fix and running the test with valgrind:

```
[simonsj@simonsj-lx5 : unittests] valgrind --leak-check=full ./torture_options >/dev/null
==93134== Memcheck, a memory error detector
==93134== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==93134== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==93134== Command: ./torture_options
==93134==
[  PASSED  ] 10 test(s).
[  PASSED  ] 1 test(s).
==93134==
==93134== HEAP SUMMARY:
==93134==     in use at exit: 80 bytes in 1 blocks
==93134==   total heap usage: 977 allocs, 976 frees, 75,029 bytes allocated
==93134==
==93134== 80 bytes in 1 blocks are definitely lost in loss record 1 of 1
==93134==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==93134==    by 0x41BAB0: ssh_key_new (pki.c:107)
==93134==    by 0x40DF90: torture_bind_options_import_key (torture_options.c:222)
==93134==    by 0x4E3AA3A: cmocka_run_one_test_or_fixture (cmocka.c:2304)
==93134==    by 0x4E3ACEA: cmocka_run_one_tests (cmocka.c:2412)
==93134==    by 0x4E3B036: _cmocka_run_group_tests (cmocka.c:2517)
==93134==    by 0x40E9E3: torture_run_tests (torture_options.c:276)
==93134==    by 0x40DE68: main (torture.c:1100)
==93134==
==93134== LEAK SUMMARY:
==93134==    definitely lost: 80 bytes in 1 blocks
==93134==    indirectly lost: 0 bytes in 0 blocks
==93134==      possibly lost: 0 bytes in 0 blocks
==93134==    still reachable: 0 bytes in 0 blocks
==93134==         suppressed: 0 bytes in 0 blocks
==93134==
==93134== For counts of detected and suppressed errors, rerun with: -v
==93134== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
```

 * And after:

```
[simonsj@simonsj-lx5 : unittests] valgrind --leak-check=full ./torture_options >/dev/null
==93294== Memcheck, a memory error detector
==93294== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==93294== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==93294== Command: ./torture_options
==93294==
[  PASSED  ] 10 test(s).
[  PASSED  ] 1 test(s).
==93294==
==93294== HEAP SUMMARY:
==93294==     in use at exit: 0 bytes in 0 blocks
==93294==   total heap usage: 977 allocs, 977 frees, 75,029 bytes allocated
==93294==
==93294== All heap blocks were freed -- no leaks are possible
==93294==
==93294== For counts of detected and suppressed errors, rerun with: -v
==93294== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```

Reviewers: asn

Reviewed By: asn

Differential Revision: https://bugs.libssh.org/D3
2017-08-17 09:33:13 +02:00
Jon Simons
380390c4b6 misc: relax fatal errors in ssh_analyze_banner
Relax the cases where `ssh_analyze_banner` fails to extract a
major and minor version from banners which appear like OpenSSH
banners.

Update the tests to demonstrate that now a banner as might be
sent by `ssh-keyscan(1)` ("SSH-2.0-OpenSSH-keyscan") no longer
returns failure.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:32:31 +02:00
Andreas Schneider
d9ff44b46e tests: Fix endif
Ups.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-14 08:53:15 +02:00
Andreas Schneider
c480ac8522 tests: Only run ssh_bind test if we build with server support
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-14 08:52:08 +02:00
Jon Simons
a89a67e008 misc: fix error-checking in ssh_analyze_banner
Fix error-checking for `strtoul` in `ssh_analyze_banner`, and
enable some tests which demonstrate the fix before-and-after.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:35:34 +02:00
Jon Simons
14d8e940e6 tests: torture-misc: add torture_ssh_analyze_banner
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:32:58 +02:00
Jon Simons
effd7ba13c tests: torture-misc: fix 4-space indentation
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:32:35 +02:00
Alfredo Mazzinghi
9dc650b7fb server: Add option SSH_BIND_OPTIONS_IMPORT_KEY to server
This sets the bind private key directly from an ssh_key struct instead
of reading a file.

Signed-off-by: Alfredo Mazzinghi <am2419@cl.cam.ac.uk>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-11 10:00:13 +02:00
Andreas Schneider
639dc3b5fd tests: Fix typo in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 07:50:24 +01:00
Andreas Schneider
5437deed1b callbacks: Add support for MSVC
__typeof__ is GCC specific

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 20:00:02 +01:00
Andreas Schneider
fbe8ccdf3b tests: Fix memory leak in torture_callbacks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:33:33 +01:00
Andreas Schneider
34241cbb2b tests: Reset output buffer in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:31:43 +01:00
Andreas Schneider
e9ba2da9e9 tests: Some cleanup for torture_pki
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:21:39 +01:00
Andreas Schneider
ad0ac12c40 tests: Disable x11 test which fails too often
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:22:00 +01:00
Andreas Schneider
72eb4adbf0 tests: Try to fix the x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09 15:47:38 +02:00
Andreas Schneider
3f9ce10525 tests: Fix buffer test without NARG macro support
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09 15:45:45 +02:00
Aris Adamantiadis
5c67530f1e tests: Add test for ssh_callbacks_iterate()
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:50 +02:00
Aris Adamantiadis
6f3a7d36bb tests: Add unit test for ssh_callbacks_execute_list
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:25 +02:00
Justus Winter
9a54f91bb7 torture: Fix guard
* tests/unittests/torture_pki.c (setup_ecdsa_key*): Check for
'HAVE_ECC' instead of 'HAVE_OPENSSL_ECC'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:38:57 +01:00
Andreas Schneider
1bc4176d65 torture: Use ECDSA key for x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-08 18:46:22 +01:00
Fabiano Fidêncio
05fd0acf45 buffer: do not use ssh_buffer_get_rest_len()
As ssh_buffer_get_len() actually calls ssh_buffer_get_rest_len(), let's
just use the first one. This is a preparatory step for removing
ssh_buffer_get_rest_len().

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
954341dd1f buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
adc8c20ac1 cleanup: use ssh_ prefix in the buffer (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Andreas Schneider
9ccb6864be tests: Initialize output and iv in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:15:42 +01:00
Aris Adamantiadis
677fa8ced2 tests: add test for cipher.(de|en)crypt 2015-09-23 15:09:23 +02:00
Andreas Schneider
f55b10e4ed tests: Fix return code of torture_init
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-09 09:17:46 +02:00
Axel Eppe
d8be35de7f tests: Add tests for the new ssh_pki cert functions
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 13:30:34 +02:00
Andreas Schneider
3b0b1c3ee3 pki: Use the standard logging function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 10:57:34 +02:00
Andreas Schneider
82a80b205b tests: Migrate to new cmocka API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 10:40:12 +02:00
Andreas Schneider
5b586fdfec cmake: Handle libssh threas library correctly
This should fix the build on Windows and would not install pkg files.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 07:46:11 +02:00
Andreas Schneider
d54a1ab798 tests: Add checks for ssh_key_is_private()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-08-10 13:57:47 +02:00
Andreas Schneider
8979150745 tests: Migrate torture_keyfiles to testkey functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 09:47:37 +02:00
Andreas Schneider
57afe78167 tests: Fix memory leak in torture_server_x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 09:33:51 +02:00
Andreas Schneider
9244750a63 cmake: Add missing OpenSSL include directory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 19:04:49 +02:00
Andreas Schneider
e4e3b3052f tests: Apply umask before calling mkstemp()
CID: #978660

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 11:27:09 +02:00
Andreas Schneider
d6fe9dc220 unittests: Fix memory leak in torture_pki_ed25519
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 15:05:19 +02:00
Aris Adamantiadis
5c46fbc680 tests: torture-misc: check for NULL return codes
Use the LOGNAME environment variable if USER is not set, as it sometimes
happens in cron jobs.
2015-02-12 11:38:21 +01:00
Aris Adamantiadis
d42a1a35b0 tests: allow conditionnal execution on pattern
Option can be used to filter out irrelevant tests
usage: ./torture_pki '*ed25519'

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 17:34:15 +01:00
Aris Adamantiadis
fbdb940c46 ed25519: Add test for signatures and verification
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
c8d0b724b3 tests: Add ed25519 encrypted keys export
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
b76d37b341 tests: Add ed25519 encrypted keys import
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
4f5660e081 tests: Add ed25519 OpenSSH key saving
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
119840b0a9 tests: Add ed25519 OpenSSH key loading and operations
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Andreas Schneider
f6a50aff4c tests: Fix torture_server_x11(). 2015-01-21 09:19:30 +01:00
Alan Dunn
6b7f275c32 tests: Add torture_server_x11 test.
torture_server_x11 tests whether a libssh server can correctly parse an
X11 request.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 20:23:19 +01:00
Aris Adamantiadis
86ae6b2251 buffer: Add a secure buffer mechanism to avoid memory spills
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:36:32 +02:00
Aris Adamantiadis
2cb2587b55 buffer: Implement "t" for text in ssh_buffer_pack().
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:27:35 +02:00