1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

Avoid an expression in a assert() with side effects

This commit is contained in:
Frank Denis 2017-12-06 12:16:37 +00:00
parent e89c43edf6
commit 625e313e74

View File

@ -10,6 +10,7 @@ tv_kdf(void)
char *context;
char hex[crypto_kdf_BYTES_MAX * 2 + 1];
uint64_t i;
int ret;
context = (char *) sodium_malloc(crypto_kdf_CONTEXTBYTES);
memcpy(context, "KDF test", strlen("KDF test"));
@ -19,8 +20,9 @@ tv_kdf(void)
}
subkey = (unsigned char *) sodium_malloc(crypto_kdf_BYTES_MAX);
for (i = 0; i < 10; i++) {
assert(crypto_kdf_derive_from_key(subkey, crypto_kdf_BYTES_MAX,
i, context, master_key) == 0);
ret = crypto_kdf_derive_from_key(subkey, crypto_kdf_BYTES_MAX,
i, context, master_key);
assert(ret == 0);
sodium_bin2hex(hex, sizeof hex, subkey, crypto_kdf_BYTES_MAX);
printf("%s\n", hex);
}