aboutsummaryrefslogtreecommitdiff
path: root/tests/client
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2011-01-04 23:10:01 +0100
committerAndreas Schneider <asn@cynapses.org>2011-01-04 23:10:01 +0100
commitec12da273e0cf1989674d271864785cc89c6e9de (patch)
treec0884728e6d4b66a0e60264506f54604920654d3 /tests/client
parentfdffa42c0259f35e80ad37661d7ae48f2138f3a9 (diff)
downloadlibssh-ec12da273e0cf1989674d271864785cc89c6e9de.tar.gz
libssh-ec12da273e0cf1989674d271864785cc89c6e9de.tar.xz
libssh-ec12da273e0cf1989674d271864785cc89c6e9de.zip
tests: Fixed the segfault in torture_knownhosts.
Diffstat (limited to 'tests/client')
-rw-r--r--tests/client/torture_knownhosts.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/client/torture_knownhosts.c b/tests/client/torture_knownhosts.c
index 9c44c9e..8f9db8e 100644
--- a/tests/client/torture_knownhosts.c
+++ b/tests/client/torture_knownhosts.c
@@ -36,9 +36,12 @@ static void setup(void **state) {
}
static void teardown(void **state) {
- ssh_free(*state);
+ ssh_session session = *state;
+
+ ssh_disconnect(session);
+ ssh_free(session);
+
unlink(KNOWNHOSTFILES);
- ssh_finalize();
}
static void torture_knownhosts_port(void **state) {
@@ -64,9 +67,6 @@ static void torture_knownhosts_port(void **state) {
rc = ssh_write_knownhost(session);
assert_true(rc == SSH_OK);
- ssh_disconnect(session);
- ssh_free(session);
-
file = fopen(KNOWNHOSTFILES, "r");
assert_true(file != NULL);
fgets(buffer, sizeof(buffer), file);
@@ -74,21 +74,21 @@ static void torture_knownhosts_port(void **state) {
buffer[sizeof(buffer) - 1] = '\0';
assert_true(strstr(buffer,"[localhost]:1234 ") != NULL);
+ ssh_disconnect(session);
+ ssh_free(session);
+
/* Now, connect back to the ssh server and verify the known host line */
- session = ssh_new();
+ *state = session = ssh_new();
+
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, KNOWNHOSTFILES);
-#if 0
- ssh_options_set(session,SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
-#endif
+
rc = ssh_connect(session);
assert_true(rc == SSH_OK);
session->port = 1234;
rc = ssh_is_server_known(session);
assert_true(rc == SSH_SERVER_KNOWN_OK);
-
- ssh_disconnect(session);
}
int torture_run_tests(void) {
@@ -100,7 +100,7 @@ int torture_run_tests(void) {
ssh_init();
rc = run_tests(tests);
- ssh_finalize();
+ ssh_finalize();
return rc;
}