Add extra assert() in tests allocating memory on the heap.
This commit is contained in:
parent
6189eec330
commit
d556a56c3c
@ -267,8 +267,10 @@ static void tv3(void)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
out = (char *) sodium_malloc(strlen(tests[i].out) + 1U);
|
out = (char *) sodium_malloc(strlen(tests[i].out) + 1U);
|
||||||
|
assert(out != NULL);
|
||||||
memcpy(out, tests[i].out, strlen(tests[i].out) + 1U);
|
memcpy(out, tests[i].out, strlen(tests[i].out) + 1U);
|
||||||
passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
|
passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
|
||||||
|
assert(passwd != NULL);
|
||||||
memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
|
memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
|
||||||
if (crypto_pwhash_scryptsalsa208sha256_str_verify(
|
if (crypto_pwhash_scryptsalsa208sha256_str_verify(
|
||||||
out, passwd, strlen(passwd)) != 0) {
|
out, passwd, strlen(passwd)) != 0) {
|
||||||
|
@ -48,6 +48,7 @@ int main(void)
|
|||||||
for (i = 0U; i < 10000U; i++) {
|
for (i = 0U; i < 10000U; i++) {
|
||||||
size = randombytes_uniform(100000U);
|
size = randombytes_uniform(100000U);
|
||||||
buf = sodium_malloc(size);
|
buf = sodium_malloc(size);
|
||||||
|
assert(buf != NULL);
|
||||||
memset(buf, i, size);
|
memset(buf, i, size);
|
||||||
sodium_mprotect_readonly(buf);
|
sodium_mprotect_readonly(buf);
|
||||||
sodium_free(buf);
|
sodium_free(buf);
|
||||||
@ -65,6 +66,7 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
size = randombytes_uniform(100000U);
|
size = randombytes_uniform(100000U);
|
||||||
buf = sodium_malloc(size);
|
buf = sodium_malloc(size);
|
||||||
|
assert(buf != NULL);
|
||||||
sodium_mprotect_readonly(buf);
|
sodium_mprotect_readonly(buf);
|
||||||
sodium_mprotect_readwrite(buf);
|
sodium_mprotect_readwrite(buf);
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
|
@ -43,6 +43,7 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
size = randombytes_uniform(100000U);
|
size = randombytes_uniform(100000U);
|
||||||
buf = sodium_malloc(size);
|
buf = sodium_malloc(size);
|
||||||
|
assert(buf != NULL);
|
||||||
sodium_mprotect_noaccess(buf);
|
sodium_mprotect_noaccess(buf);
|
||||||
sodium_mprotect_readwrite(buf);
|
sodium_mprotect_readwrite(buf);
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
|
Loading…
Reference in New Issue
Block a user