aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-08-06 09:05:40 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-06 09:36:47 +0200
commitfbfe0024604fa948e3cf865e6fb89afc5b91cabe (patch)
tree9a27e0005b7731ff24ab9180abb28f55c30813cf
parentc7525c056cd106cc0299388b16ee98080fd052d8 (diff)
downloadlibssh-fbfe0024604fa948e3cf865e6fb89afc5b91cabe.tar.gz
libssh-fbfe0024604fa948e3cf865e6fb89afc5b91cabe.tar.xz
libssh-fbfe0024604fa948e3cf865e6fb89afc5b91cabe.zip
tests: Check for memory allocation error in torture_pki_ed25519_sign()
CID 1393899 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_pki_ed25519.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unittests/torture_pki_ed25519.c b/tests/unittests/torture_pki_ed25519.c
index e397e50a..3ba6f6e2 100644
--- a/tests/unittests/torture_pki_ed25519.c
+++ b/tests/unittests/torture_pki_ed25519.c
@@ -321,13 +321,24 @@ static void torture_pki_ed25519_write_privkey(void **state)
static void torture_pki_ed25519_sign(void **state){
ssh_key privkey;
- ssh_signature sig = ssh_signature_new();
+ ssh_signature sig;
ssh_string blob;
int rc;
+
(void)state;
- rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_ED25519,0,0), NULL, NULL, NULL, &privkey);
+ sig = ssh_signature_new();
+ assert_non_null(sig);
+
+ rc = ssh_pki_import_privkey_base64(torture_get_testkey(SSH_KEYTYPE_ED25519,
+ 0,
+ 0),
+ NULL,
+ NULL,
+ NULL,
+ &privkey);
assert_true(rc == SSH_OK);
+ assert_non_null(privkey);
sig->type = SSH_KEYTYPE_ED25519;
rc = pki_ed25519_sign(privkey, sig, HASH, sizeof(HASH));