From 8ee4950eb36f97645eae6c28d34451c2fd770b8a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 9 Sep 2015 10:00:18 +0200 Subject: [PATCH] Use sodium_malloc() for the secretbox_*() tests --- test/default/secretbox_easy.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/default/secretbox_easy.c b/test/default/secretbox_easy.c index 5a063af4..ead65b96 100644 --- a/test/default/secretbox_easy.c +++ b/test/default/secretbox_easy.c @@ -24,12 +24,15 @@ unsigned char m[131] 0x60, 0x90, 0x2e, 0x52, 0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37, 0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 }; -unsigned char c[147 + crypto_secretbox_MACBYTES + 1]; -unsigned char mac[crypto_secretbox_MACBYTES]; - int main(void) { - size_t i; + unsigned char *c; + unsigned char *mac; + size_t i; + + c = sodium_malloc(131 + crypto_secretbox_MACBYTES + 1); + mac = sodium_malloc(crypto_secretbox_MACBYTES); + assert(c != NULL && mac != NULL); crypto_secretbox_easy(c, m, 131, nonce, firstkey); for (i = 0; i < 131 + crypto_secretbox_MACBYTES; ++i) { @@ -83,5 +86,8 @@ int main(void) assert(crypto_secretbox_easy(c, m, SIZE_MAX - 1U, nonce, firstkey) == -1); + sodium_free(mac); + sodium_free(c); + return 0; }