aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2018-09-24 18:24:53 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-09-27 15:21:30 +0200
commit143b5e2e5065ce3f0f6b8871f1766d5b2cfb74cf (patch)
tree924762c29f5bd0ea8de5c3dcf7f76fe8f04a9037
parent11d480134ce2124b3220269737abfa12a8191e41 (diff)
downloadlibssh-143b5e2e5065ce3f0f6b8871f1766d5b2cfb74cf.tar.gz
libssh-143b5e2e5065ce3f0f6b8871f1766d5b2cfb74cf.tar.xz
libssh-143b5e2e5065ce3f0f6b8871f1766d5b2cfb74cf.zip
tests: Use SSH_STRING_FREE_CHAR
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_config.c10
-rw-r--r--tests/unittests/torture_hashes.c43
-rw-r--r--tests/unittests/torture_pki_dsa.c4
-rw-r--r--tests/unittests/torture_pki_ecdsa.c4
-rw-r--r--tests/unittests/torture_pki_rsa.c4
-rw-r--r--tests/unittests/torture_threads_pki_rsa.c4
6 files changed, 36 insertions, 33 deletions
diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c
index d3df41cf..8fe4a2c4 100644
--- a/tests/unittests/torture_config.c
+++ b/tests/unittests/torture_config.c
@@ -170,21 +170,21 @@ static void torture_config_from_file(void **state) {
assert_non_null(v);
assert_string_equal(v, PROXYCMD);
- ssh_string_free_char(v);
+ SSH_STRING_FREE_CHAR(v);
ret = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &v);
assert_true(ret == 0);
assert_non_null(v);
assert_string_equal(v, ID_FILE);
- ssh_string_free_char(v);
+ SSH_STRING_FREE_CHAR(v);
ret = ssh_options_get(session, SSH_OPTIONS_USER, &v);
assert_true(ret == 0);
assert_non_null(v);
assert_string_equal(v, USERNAME);
- ssh_string_free_char(v);
+ SSH_STRING_FREE_CHAR(v);
assert_string_equal(session->opts.wanted_methods[SSH_KEX], KEXALGORITHMS);
@@ -223,14 +223,14 @@ static void torture_config_glob(void **state) {
assert_non_null(v);
assert_string_equal(v, PROXYCMD);
- ssh_string_free_char(v);
+ SSH_STRING_FREE_CHAR(v);
ret = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &v);
assert_true(ret == 0);
assert_non_null(v);
assert_string_equal(v, ID_FILE);
- ssh_string_free_char(v);
+ SSH_STRING_FREE_CHAR(v);
#endif /* HAVE_GLOB */
}
diff --git a/tests/unittests/torture_hashes.c b/tests/unittests/torture_hashes.c
index 104aa7c9..76149dc2 100644
--- a/tests/unittests/torture_hashes.c
+++ b/tests/unittests/torture_hashes.c
@@ -48,81 +48,84 @@ static int teardown(void **state)
static void torture_md5_hash(void **state)
{
ssh_key pubkey = *state;
- unsigned char *hash = NULL;
+ char *hash = NULL;
char *hexa = NULL;
size_t hlen;
int rc = 0;
- rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_MD5, &hash, &hlen);
+ rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_MD5,
+ (unsigned char **)&hash, &hlen);
assert_true(rc == 0);
- hexa = ssh_get_hexa(hash, hlen);
- ssh_string_free_char((char *)hash);
+ hexa = ssh_get_hexa((unsigned char *)hash, hlen);
+ SSH_STRING_FREE_CHAR(hash);
assert_string_equal(hexa,
"50:15:a0:9b:92:bf:33:1c:01:c5:8c:fe:18:fa:ce:78");
- ssh_string_free_char(hexa);
+ SSH_STRING_FREE_CHAR(hexa);
}
static void torture_sha1_hash(void **state)
{
ssh_key pubkey = *state;
- unsigned char *hash = NULL;
+ char *hash = NULL;
char *sha1 = NULL;
int rc = 0;
size_t hlen;
- rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA1, &hash, &hlen);
+ rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA1,
+ (unsigned char **)&hash, &hlen);
assert_true(rc == 0);
- sha1 = ssh_get_b64_unpadded(hash, hlen);
- ssh_string_free_char((char *)hash);
+ sha1 = ssh_get_b64_unpadded((unsigned char *)hash, hlen);
+ SSH_STRING_FREE_CHAR(hash);
assert_string_equal(sha1, "6wP+houujQmxLBiFugTcoeoODCM");
- ssh_string_free_char(sha1);
+ SSH_STRING_FREE_CHAR(sha1);
}
static void torture_sha256_hash(void **state)
{
ssh_key pubkey = *state;
- unsigned char *hash = NULL;
+ char *hash = NULL;
char *sha256 = NULL;
int rc = 0;
size_t hlen;
- rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256, &hash, &hlen);
+ rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256,
+ (unsigned char **)&hash, &hlen);
assert_true(rc == 0);
- sha256 = ssh_get_b64_unpadded(hash, hlen);
- ssh_string_free_char((char *)hash);
+ sha256 = ssh_get_b64_unpadded((unsigned char *)hash, hlen);
+ SSH_STRING_FREE_CHAR(hash);
assert_string_equal(sha256, "jXstVLLe84fSDo1kEYGn6iumnPCSorhaiWxnJz8VTII");
- ssh_string_free_char(sha256);
+ SSH_STRING_FREE_CHAR(sha256);
}
static void torture_sha256_fingerprint(void **state)
{
ssh_key pubkey = *state;
- unsigned char *hash = NULL;
+ char *hash = NULL;
char *sha256 = NULL;
int rc = 0;
size_t hlen;
rc = ssh_get_publickey_hash(pubkey,
SSH_PUBLICKEY_HASH_SHA256,
- &hash,
+ (unsigned char **)&hash,
&hlen);
assert_true(rc == 0);
sha256 = ssh_get_fingerprint_hash(SSH_PUBLICKEY_HASH_SHA256,
- hash,
+ (unsigned char *)hash,
hlen);
- ssh_string_free_char(discard_const(hash));
+ SSH_STRING_FREE_CHAR(hash);
assert_string_equal(sha256,
"SHA256:jXstVLLe84fSDo1kEYGn6iumnPCSorhaiWxnJz8VTII");
- ssh_string_free_char(sha256);
+ SSH_STRING_FREE_CHAR(sha256);
}
int torture_run_tests(void) {
diff --git a/tests/unittests/torture_pki_dsa.c b/tests/unittests/torture_pki_dsa.c
index e8d03904..ebb3c8b2 100644
--- a/tests/unittests/torture_pki_dsa.c
+++ b/tests/unittests/torture_pki_dsa.c
@@ -533,8 +533,8 @@ static void torture_pki_dsa_duplicate_key(void **state)
ssh_key_free(pubkey);
ssh_key_free(privkey);
ssh_key_free(privkey_dup);
- ssh_string_free_char(b64_key);
- ssh_string_free_char(b64_key_gen);
+ SSH_STRING_FREE_CHAR(b64_key);
+ SSH_STRING_FREE_CHAR(b64_key_gen);
}
static void torture_pki_dsa_generate_key(void **state)
diff --git a/tests/unittests/torture_pki_ecdsa.c b/tests/unittests/torture_pki_ecdsa.c
index 497c7379..43d9fadb 100644
--- a/tests/unittests/torture_pki_ecdsa.c
+++ b/tests/unittests/torture_pki_ecdsa.c
@@ -310,8 +310,8 @@ static void torture_pki_ecdsa_duplicate_key(void **state)
ssh_key_free(pubkey);
ssh_key_free(privkey);
ssh_key_free(privkey_dup);
- ssh_string_free_char(b64_key);
- ssh_string_free_char(b64_key_gen);
+ SSH_STRING_FREE_CHAR(b64_key);
+ SSH_STRING_FREE_CHAR(b64_key_gen);
}
/* Test case for bug #147: Private ECDSA key duplication did not carry
diff --git a/tests/unittests/torture_pki_rsa.c b/tests/unittests/torture_pki_rsa.c
index 0d5e97fa..d0203545 100644
--- a/tests/unittests/torture_pki_rsa.c
+++ b/tests/unittests/torture_pki_rsa.c
@@ -385,8 +385,8 @@ static void torture_pki_rsa_duplicate_key(void **state)
ssh_key_free(pubkey);
ssh_key_free(privkey);
ssh_key_free(privkey_dup);
- ssh_string_free_char(b64_key);
- ssh_string_free_char(b64_key_gen);
+ SSH_STRING_FREE_CHAR(b64_key);
+ SSH_STRING_FREE_CHAR(b64_key_gen);
}
static void torture_pki_rsa_generate_key(void **state)
diff --git a/tests/unittests/torture_threads_pki_rsa.c b/tests/unittests/torture_threads_pki_rsa.c
index d19d8bbf..33478a37 100644
--- a/tests/unittests/torture_threads_pki_rsa.c
+++ b/tests/unittests/torture_threads_pki_rsa.c
@@ -492,8 +492,8 @@ static void *thread_pki_rsa_duplicate_key(void *threadid)
ssh_key_free(pubkey);
ssh_key_free(privkey);
ssh_key_free(privkey_dup);
- ssh_string_free_char(b64_key);
- ssh_string_free_char(b64_key_gen);
+ SSH_STRING_FREE_CHAR(b64_key);
+ SSH_STRING_FREE_CHAR(b64_key_gen);
pthread_exit(NULL);
}