diff options
author | Dirkjan Bussink <d.bussink@gmail.com> | 2020-12-10 14:01:32 +0000 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2020-12-11 13:32:02 +0100 |
commit | daeee74edd8ac25c1d246d40333e78518574eded (patch) | |
tree | e6646a06bcc8e4338d3a094bcd5af034fe8a0c1f /tests | |
parent | f6a2f6190c2aa047d901547720ae6d1729e1e2c0 (diff) | |
download | libssh-daeee74edd8ac25c1d246d40333e78518574eded.tar.gz libssh-daeee74edd8ac25c1d246d40333e78518574eded.tar.xz libssh-daeee74edd8ac25c1d246d40333e78518574eded.zip |
Add safety checks for all ssh_string_fill calls
These calls can fail and the return code should always be checked. These
issues were identified when code review called it out on new code. The
updates here are to existing code with no behavior changes to make
review simpler.
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/torture_pki_ed25519.c | 6 | ||||
-rw-r--r-- | tests/unittests/torture_session_keys.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/tests/unittests/torture_pki_ed25519.c b/tests/unittests/torture_pki_ed25519.c index 07ccfd67..ff59b190 100644 --- a/tests/unittests/torture_pki_ed25519.c +++ b/tests/unittests/torture_pki_ed25519.c @@ -796,7 +796,8 @@ static void torture_pki_ed25519_verify(void **state){ assert_true(rc == SSH_OK); assert_non_null(pubkey); - ssh_string_fill(blob, ref_signature, ED25519_SIG_LEN); + rc = ssh_string_fill(blob, ref_signature, ED25519_SIG_LEN); + assert_int_equal(rc, 0); sig = pki_signature_from_blob(pubkey, blob, SSH_KEYTYPE_ED25519, SSH_DIGEST_AUTO); assert_non_null(sig); @@ -853,7 +854,8 @@ static void torture_pki_ed25519_verify_bad(void **state){ /* alter signature and expect false result */ for (i=0; i < ED25519_SIG_LEN; ++i){ - ssh_string_fill(blob, ref_signature, ED25519_SIG_LEN); + rc = ssh_string_fill(blob, ref_signature, ED25519_SIG_LEN); + assert_int_equal(rc, 0); ((uint8_t *)ssh_string_data(blob))[i] ^= 0xff; sig = pki_signature_from_blob(pubkey, blob, SSH_KEYTYPE_ED25519, SSH_DIGEST_AUTO); assert_non_null(sig); diff --git a/tests/unittests/torture_session_keys.c b/tests/unittests/torture_session_keys.c index f220e010..6ae58831 100644 --- a/tests/unittests/torture_session_keys.c +++ b/tests/unittests/torture_session_keys.c @@ -68,7 +68,9 @@ static void torture_session_keys(UNUSED_PARAM(void **state)) int rc; k_string = ssh_string_new(32); - ssh_string_fill(k_string, key, 32); + rc = ssh_string_fill(k_string, key, 32); + assert_int_equal(rc, 0); + test_crypto.shared_secret = ssh_make_string_bn(k_string); rc = ssh_generate_session_keys(&session); |