1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

Don't use compile-time assertions with sizeof(dynamic length).

This commit is contained in:
Frank Denis 2014-04-15 20:16:23 -07:00 committed by evoskuil
parent 6ede7869ec
commit fdc5843176
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
@ -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);

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
@ -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);