aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-11-23 16:38:54 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-11-23 17:31:29 +0100
commitfd844cac6d281849aff97f525427c4ba43b73550 (patch)
tree41588e4ccea54268ad6547810a6b2a97a29ff35c
parenta106a00e0dde9abd295dc921306b8de63025571f (diff)
downloadlibssh-fd844cac6d281849aff97f525427c4ba43b73550.tar.gz
libssh-fd844cac6d281849aff97f525427c4ba43b73550.tar.xz
libssh-fd844cac6d281849aff97f525427c4ba43b73550.zip
tests: Verify setting NULL knownhosts does not crash
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_options.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index 448fbfbf..1b3c9f67 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -12,6 +12,7 @@
#include <libssh/session.h>
#include <libssh/misc.h>
#include <libssh/pki_priv.h>
+#include <libssh/options.h>
static int setup(void **state)
{
@@ -392,6 +393,16 @@ static void torture_options_set_knownhosts(void **state)
assert_ssh_return_code(session, rc);
assert_string_equal(session->opts.knownhosts,
"/home/libssh/.ssh/known_hosts");
+
+ /* The NULL value should not crash the libssh */
+ rc = ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, NULL);
+ assert_ssh_return_code(session, rc);
+ assert_null(session->opts.knownhosts);
+
+ /* ssh_options_apply() should set the path to correct value */
+ rc = ssh_options_apply(session);
+ assert_ssh_return_code(session, rc);
+ assert_true(session->opts.knownhosts != NULL);
}
static void torture_options_get_knownhosts(void **state)