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

Add a workaround for old asan versions (CentOS 7)

This commit is contained in:
Frank Denis 2017-06-23 17:30:48 +02:00
parent 2864701f1b
commit 7334060f43
2 changed files with 14 additions and 0 deletions

View File

@ -79,13 +79,20 @@ main(void)
size = 1U + randombytes_uniform(100000U);
buf = sodium_malloc(size);
assert(buf != NULL);
/* old versions of asan emit a warning because they don't support mlock*() */
#ifndef __SANITIZE_ADDRESS__
sodium_mprotect_readonly(buf);
sodium_mprotect_readwrite(buf);
#endif
#if defined(HAVE_CATCHABLE_SEGV) && !defined(__EMSCRIPTEN__) && !defined(__SANITIZE_ADDRESS__)
sodium_memzero(((unsigned char *) buf) + size, 1U);
sodium_mprotect_noaccess(buf);
sodium_free(buf);
printf("Overflow not caught\n");
#else
segv_handler(0);
#endif
return 0;
}

View File

@ -49,13 +49,20 @@ main(void)
size = 1U + randombytes_uniform(100000U);
buf = sodium_malloc(size);
assert(buf != NULL);
/* old versions of asan emit a warning because they don't support mlock*() */
#ifndef __SANITIZE_ADDRESS__
sodium_mprotect_noaccess(buf);
sodium_mprotect_readwrite(buf);
#endif
#if defined(HAVE_CATCHABLE_SEGV) && !defined(__EMSCRIPTEN__) && !defined(__SANITIZE_ADDRESS__)
sodium_memzero(((unsigned char *) buf) - 8, 8U);
sodium_mprotect_readonly(buf);
sodium_free(buf);
printf("Underflow not caught\n");
#else
segv_handler(0);
#endif
return 0;
}