From f288d119107bf2a913e3c95eda2024a001ad516b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 15 Apr 2014 20:16:23 -0700 Subject: [PATCH] Don't use compile-time assertions with sizeof(dynamic length). --- src/libsodium/crypto_box/crypto_box_easy.c | 5 +++-- src/libsodium/crypto_secretbox/crypto_secretbox_easy.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_box/crypto_box_easy.c b/src/libsodium/crypto_box/crypto_box_easy.c index 4687cf90..80da4333 100644 --- a/src/libsodium/crypto_box/crypto_box_easy.c +++ b/src/libsodium/crypto_box/crypto_box_easy.c @@ -1,4 +1,5 @@ +#include #include #include #include @@ -41,8 +42,8 @@ crypto_box_easy(unsigned char *c, const unsigned char *m, free(c_boxed); return -1; } - (void) sizeof(char[m_boxed_len - crypto_box_BOXZEROBYTES == - mlen + crypto_box_MACBYTES ? 1 : -1]); + assert(m_boxed_len - crypto_box_BOXZEROBYTES == + mlen + crypto_box_MACBYTES); memcpy(c, c_boxed + crypto_box_BOXZEROBYTES, mlen + crypto_box_MACBYTES); free(c_boxed); diff --git a/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c b/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c index 2199d9f9..e64aae05 100644 --- a/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +++ b/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c @@ -1,4 +1,5 @@ +#include #include #include #include @@ -41,8 +42,8 @@ crypto_secretbox_easy(unsigned char *c, const unsigned char *m, free(c_boxed); return -1; } - (void) sizeof(char[m_boxed_len - crypto_secretbox_BOXZEROBYTES == - mlen + crypto_secretbox_MACBYTES ? 1 : -1]); + assert(m_boxed_len - crypto_secretbox_BOXZEROBYTES == + mlen + crypto_secretbox_MACBYTES); memcpy(c, c_boxed + crypto_secretbox_BOXZEROBYTES, mlen + crypto_secretbox_MACBYTES); free(c_boxed);