aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2010-03-13 16:51:52 +0100
committerAndreas Schneider <mail@cynapses.org>2010-03-13 16:51:52 +0100
commit90d72c214ece305f81573c873799b091f59f3207 (patch)
treee572f19411aef52c425325c2b3a03c28260c6051 /tests
parent8fd6c8bc02f92525ec6fe2628d2fe8ea3a57f16b (diff)
downloadlibssh-90d72c214ece305f81573c873799b091f59f3207.tar.gz
libssh-90d72c214ece305f81573c873799b091f59f3207.tar.xz
libssh-90d72c214ece305f81573c873799b091f59f3207.zip
Fixed the torture_pubkey_generate_from_privkey test.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_keyfiles.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/unittests/torture_keyfiles.c b/tests/unittests/torture_keyfiles.c
index d08d49ac..b8418ecf 100644
--- a/tests/unittests/torture_keyfiles.c
+++ b/tests/unittests/torture_keyfiles.c
@@ -87,10 +87,10 @@ static int torture_read_one_line(const char *filename, char *buffer, size_t len)
START_TEST (torture_pubkey_generate_from_privkey)
{
- ssh_private_key privkey;
- ssh_public_key pubkey;
- ssh_string pubkey_orig;
- ssh_string pubkey_new;
+ ssh_private_key privkey = NULL;
+ ssh_public_key pubkey = NULL;
+ ssh_string pubkey_orig = NULL;
+ ssh_string pubkey_new = NULL;
char pubkey_line_orig[512] = {0};
char pubkey_line_new[512] = {0};
int type_orig = 0;
@@ -101,6 +101,7 @@ START_TEST (torture_pubkey_generate_from_privkey)
rc = ssh_try_publickey_from_file(session, LIBSSH_RSA_TESTKEY, &pubkey_orig,
&type_orig);
ck_assert(rc == 0);
+ ck_assert(pubkey_orig != NULL);
rc = torture_read_one_line(LIBSSH_RSA_TESTKEY ".pub", pubkey_line_orig,
sizeof(pubkey_line_orig));
@@ -111,6 +112,7 @@ START_TEST (torture_pubkey_generate_from_privkey)
privkey = privatekey_from_file(session, LIBSSH_RSA_TESTKEY, 0, NULL);
ck_assert(privkey != NULL);
+
pubkey = publickey_from_privatekey(privkey);
type_new = privkey->type;
privatekey_free(privkey);
@@ -118,6 +120,8 @@ START_TEST (torture_pubkey_generate_from_privkey)
pubkey_new = publickey_to_string(pubkey);
publickey_free(pubkey);
+
+ ck_assert(pubkey_new != NULL);
ck_assert(memcmp(pubkey_orig->string, pubkey_new->string, pubkey_orig->size));
rc = ssh_publickey_to_file(session, LIBSSH_RSA_TESTKEY ".pub", pubkey_new, type_new);