From c739222b5ad68fa23bfdf4807106769f9428506c Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 9 Dec 2020 16:26:29 +0000 Subject: [PATCH] Fix no-threads Make OPENSSL_fork_prepare() et al always available even in a no-threads build. These functions are no-ops anyway so this shouldn't make any difference. This fixes an issue where the symbol_presence test fails in a no-threads build. This is because these functions have not been marked in libcrypto.num as being dependent on thread support. Enclosing the declarations of the functions in the header with an appropriate guard does not help because we never define OPENSSL_NO_THREADS (we define the opposite OPENSSL_THREADS). This confuses the scripts which only consider OPENSSL_NO_* guards. The simplest solution is to just make them always available. Reviewed-by: Richard Levitte Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/13647) --- crypto/build.info | 2 +- crypto/threads_lib.c | 25 +++++++++++++++++++++++++ crypto/threads_pthread.c | 15 --------------- 3 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 crypto/threads_lib.c diff --git a/crypto/build.info b/crypto/build.info index 814d8dcab75..7fe79e2296f 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -71,7 +71,7 @@ $UTIL_COMMON=\ cryptlib.c params.c params_from_text.c bsearch.c ex_data.c o_str.c \ ctype.c threads_pthread.c threads_win.c threads_none.c initthread.c \ context.c sparse_array.c asn1_dsa.c packet.c param_build.c $CPUIDASM \ - param_build_set.c der_writer.c passphrase.c + param_build_set.c der_writer.c passphrase.c threads_lib.c $UTIL_DEFINE=$CPUIDDEF SOURCE[../libcrypto]=$UTIL_COMMON \ diff --git a/crypto/threads_lib.c b/crypto/threads_lib.c new file mode 100644 index 00000000000..0c7162392df --- /dev/null +++ b/crypto/threads_lib.c @@ -0,0 +1,25 @@ +/* + * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ +#include + +#ifndef OPENSSL_NO_DEPRECATED_3_0 + +void OPENSSL_fork_prepare(void) +{ +} + +void OPENSSL_fork_parent(void) +{ +} + +void OPENSSL_fork_child(void) +{ +} + +#endif diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index d7cac6566a3..afc29b79614 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -200,21 +200,6 @@ int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) # ifndef FIPS_MODULE # ifdef OPENSSL_SYS_UNIX -# ifndef OPENSSL_NO_DEPRECATED_3_0 - -void OPENSSL_fork_prepare(void) -{ -} - -void OPENSSL_fork_parent(void) -{ -} - -void OPENSSL_fork_child(void) -{ -} - -# endif static pthread_once_t fork_once_control = PTHREAD_ONCE_INIT; static void fork_once_func(void) -- 2.47.2