From 30202f9de7330d9664c852b97ce8c219ecf6dae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 4 Jan 2018 17:50:12 +0100 Subject: [PATCH] tests/ccm: check output buffer size Add static test to verify output buffer is big enough for testing. --- tests/unittests/tests-crypto/tests-crypto-modes-ccm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unittests/tests-crypto/tests-crypto-modes-ccm.c b/tests/unittests/tests-crypto/tests-crypto-modes-ccm.c index 611e2cc869..7ace8c893d 100644 --- a/tests/unittests/tests-crypto/tests-crypto-modes-ccm.c +++ b/tests/unittests/tests-crypto/tests-crypto-modes-ccm.c @@ -100,6 +100,9 @@ static void test_encrypt_op(uint8_t* key, uint8_t key_len, int len, err, cmp; size_t len_encoding = nonce_and_len_encoding_size - nonce_len; + TEST_ASSERT_MESSAGE(sizeof(data) >= output_expected_len, + "Output buffer too small"); + err = cipher_init(&cipher, CIPHER_AES_128, key, key_len); TEST_ASSERT_EQUAL_INT(1, err); @@ -126,6 +129,9 @@ static void test_decrypt_op(uint8_t* key, uint8_t key_len, int len, err, cmp; size_t len_encoding = nonce_and_len_encoding_size - nonce_len; + TEST_ASSERT_MESSAGE(sizeof(data) >= output_expected_len, + "Output buffer too small"); + err = cipher_init(&cipher, CIPHER_AES_128, key, key_len); TEST_ASSERT_EQUAL_INT(1, err);