aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-11-16 14:05:14 +0000
committerMatt Caswell <matt@openssl.org>2019-01-04 13:19:39 +0000
commit41999e7d358c3657a254b34b85fd9e948180529b (patch)
tree42267ffc53b96b3b1097a29d8678974267e2ffb7 /test
parent88d57bf83fe32b2c8ceb1264562fdd028de504bf (diff)
downloadopenssl-41999e7d358c3657a254b34b85fd9e948180529b.zip
openssl-41999e7d358c3657a254b34b85fd9e948180529b.tar.gz
openssl-41999e7d358c3657a254b34b85fd9e948180529b.tar.bz2
Introduce a no-pinshared option
This option prevents OpenSSL from pinning itself in memory. Fixes #7598 [extended tests] Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7647)
Diffstat (limited to 'test')
-rw-r--r--test/shlibloadtest.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/test/shlibloadtest.c b/test/shlibloadtest.c
index b1a8172..6934b89 100644
--- a/test/shlibloadtest.c
+++ b/test/shlibloadtest.c
@@ -104,6 +104,8 @@ static int shlib_close(SHLIB lib)
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
+static int atexit_handler_done = 0;
+
static void atexit_handler(void)
{
FILE *atexit_file = fopen(path_atexit, "w");
@@ -113,6 +115,7 @@ static void atexit_handler(void)
fprintf(atexit_file, "atexit() run\n");
fclose(atexit_file);
+ atexit_handler_done++;
}
static int test_lib(void)
@@ -261,33 +264,34 @@ static int test_lib(void)
# endif /* DSO_DLFCN */
}
- switch (test_type) {
- case JUST_CRYPTO:
- case DSO_REFTEST:
- case NO_ATEXIT:
- case CRYPTO_FIRST:
- if (!shlib_close(cryptolib)) {
- fprintf(stderr, "Failed to close libcrypto\n");
- goto end;
- }
- if (test_type != CRYPTO_FIRST)
- break;
- /* Fall through */
+ if (!shlib_close(cryptolib)) {
+ fprintf(stderr, "Failed to close libcrypto\n");
+ goto end;
+ }
- case SSL_FIRST:
- if (test_type == CRYPTO_FIRST && !shlib_close(ssllib)) {
+ if (test_type == CRYPTO_FIRST || test_type == SSL_FIRST) {
+ if (!shlib_close(ssllib)) {
fprintf(stderr, "Failed to close libssl\n");
goto end;
}
- if (test_type != SSL_FIRST)
- break;
+ }
- if (!shlib_close(cryptolib)) {
- fprintf(stderr, "Failed to close libcrypto\n");
- goto end;
- }
- break;
+# if defined(OPENSSL_NO_PINSHARED) \
+ && defined(__GLIBC__) \
+ && defined(__GLIBC_PREREQ) \
+ && defined(OPENSSL_SYS_LINUX)
+# if __GLIBC_PREREQ(2, 3)
+ /*
+ * If we didn't pin the so then we are hopefully on a platform that supports
+ * running atexit() on so unload. If not we might crash. We know this is
+ * true on linux since glibc 2.2.3
+ */
+ if (test_type != NO_ATEXIT && atexit_handler_done != 1) {
+ fprintf(stderr, "atexit() handler did not run\n");
+ goto end;
}
+# endif
+# endif
result = 1;
end: