summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2021-07-20 11:58:32 -0400
committerZack Weinberg <zackw@panix.com>2021-07-22 08:11:12 -0400
commit3aa82ccd3a3fecea7e6a9d0f9c85c56e2e04bb78 (patch)
tree666c0b59a7b15cbf00a25bde94628af5966dba09 /test
parent41886a8f1f07a5bfeb1eb4e9c05d0525d16d2b15 (diff)
downloadlibxcrypt-3aa82ccd3a3fecea7e6a9d0f9c85c56e2e04bb78.tar.gz
libxcrypt-3aa82ccd3a3fecea7e6a9d0f9c85c56e2e04bb78.tar.bz2
libxcrypt-3aa82ccd3a3fecea7e6a9d0f9c85c56e2e04bb78.zip
Detect ASan in configure and disable incompatible tests.
ASan’s “interceptors” for crypt and crypt_r have a semantic conflict with libxcrypt, requiring a few tests to be disabled for builds with -fsanitize-address. See commentary in test/crypt-badargs.c for an explanation of the conflict, and commentary in build-aux/zw_detect_asan.m4 for why a configure test is required. This does not work around https://github.com/google/sanitizers/issues/1365 which is an unrelated problem affecting test/special-char-salt.c and which doesn’t currently break CI.
Diffstat (limited to 'test')
-rw-r--r--test/crypt-badargs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/crypt-badargs.c b/test/crypt-badargs.c
index 774ecbd..f627919 100644
--- a/test/crypt-badargs.c
+++ b/test/crypt-badargs.c
@@ -87,6 +87,7 @@ segv_handler (int sig)
static bool error_occurred;
+#ifndef XCRYPT_USE_ASAN /* see comments in do_tests */
static void
expect_no_fault (const char *tag,
const char *phrase, const char *setting, const char *expect,
@@ -102,6 +103,7 @@ expect_no_fault (const char *tag,
error_occurred = 1;
}
}
+#endif
static void
expect_a_fault (const char *tag,
@@ -208,6 +210,14 @@ do_tests(char *page, size_t pagesize)
const char *p2 = page + pagesize;
size_t i;
+ /* Our crypt*() functions return NULL / a failure token, with errno set
+ to EINVAL, when either the setting or the phrase argument is NULL.
+ ASan's interceptors for crypt*() instead crash the program when either
+ argument is NULL -- this is arguably a better choice, but for
+ compatibility's sake we can't change what our functions do. There is
+ no way to disable interception of specific functions as far as I can
+ tell. Therefore, these tests are skipped when compiled with ASan. */
+#ifndef XCRYPT_USE_ASAN
/* When SETTING is null, it shouldn't matter what PHRASE is. */
expect_no_fault ("0.0.crypt", 0, 0, FT0, test_crypt);
expect_no_fault ("0.0.crypt_r", 0, 0, FT0, test_crypt_r);
@@ -271,6 +281,7 @@ do_tests(char *page, size_t pagesize)
expect_a_fault ("0.p2.crypt_r", 0, p2, FT0, test_crypt_r);
expect_a_fault ("0.p2.crypt_rn", 0, p2, 0, test_crypt_rn);
expect_a_fault ("0.p2.crypt_ra", 0, p2, 0, test_crypt_ra);
+#endif /* no ASan */
/* When SETTING is valid, passing an invalid string as PHRASE should
crash reliably. */