mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-13 22:50:20 +02:00
test: Import explicit_bzero() sanitizer support changes from OpenBSD
This commit is contained in:
@@ -27,6 +27,17 @@
|
|||||||
#define ASSERT_NE(a, b) assert((a) != (b))
|
#define ASSERT_NE(a, b) assert((a) != (b))
|
||||||
#define ASSERT_GE(a, b) assert((a) >= (b))
|
#define ASSERT_GE(a, b) assert((a) >= (b))
|
||||||
|
|
||||||
|
#if defined(__has_feature)
|
||||||
|
#if __has_feature(address_sanitizer)
|
||||||
|
#define __SANITIZE_ADDRESS__
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef __SANITIZE_ADDRESS__
|
||||||
|
#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
|
||||||
|
#else
|
||||||
|
#define ATTRIBUTE_NO_SANITIZE_ADDRESS
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 128 bits of random data. */
|
/* 128 bits of random data. */
|
||||||
static const char secret[16] = {
|
static const char secret[16] = {
|
||||||
0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c,
|
0xa0, 0x6c, 0x0c, 0x81, 0xba, 0xd8, 0x5b, 0x0c,
|
||||||
@@ -149,7 +160,7 @@ count_secrets(const char *buf)
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
ATTRIBUTE_NO_SANITIZE_ADDRESS static char *
|
||||||
test_without_bzero(void)
|
test_without_bzero(void)
|
||||||
{
|
{
|
||||||
char buf[SECRETBYTES];
|
char buf[SECRETBYTES];
|
||||||
@@ -162,7 +173,7 @@ test_without_bzero(void)
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
ATTRIBUTE_NO_SANITIZE_ADDRESS static char *
|
||||||
test_with_bzero(void)
|
test_with_bzero(void)
|
||||||
{
|
{
|
||||||
char buf[SECRETBYTES];
|
char buf[SECRETBYTES];
|
||||||
|
Reference in New Issue
Block a user