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

Add extra assert() in tests allocating memory on the heap.

This commit is contained in:
Frank Denis 2014-11-25 16:19:20 -08:00
parent 6189eec330
commit d556a56c3c
3 changed files with 5 additions and 0 deletions

View File

@ -267,8 +267,10 @@ static void tv3(void)
do {
out = (char *) sodium_malloc(strlen(tests[i].out) + 1U);
assert(out != NULL);
memcpy(out, tests[i].out, strlen(tests[i].out) + 1U);
passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
assert(passwd != NULL);
memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
if (crypto_pwhash_scryptsalsa208sha256_str_verify(
out, passwd, strlen(passwd)) != 0) {

View File

@ -48,6 +48,7 @@ int main(void)
for (i = 0U; i < 10000U; i++) {
size = randombytes_uniform(100000U);
buf = sodium_malloc(size);
assert(buf != NULL);
memset(buf, i, size);
sodium_mprotect_readonly(buf);
sodium_free(buf);
@ -65,6 +66,7 @@ int main(void)
#endif
size = randombytes_uniform(100000U);
buf = sodium_malloc(size);
assert(buf != NULL);
sodium_mprotect_readonly(buf);
sodium_mprotect_readwrite(buf);
#ifndef __EMSCRIPTEN__

View File

@ -43,6 +43,7 @@ int main(void)
#endif
size = randombytes_uniform(100000U);
buf = sodium_malloc(size);
assert(buf != NULL);
sodium_mprotect_noaccess(buf);
sodium_mprotect_readwrite(buf);
#ifndef __EMSCRIPTEN__