diff options
| author | 2018-03-19 03:35:38 +0000 | |
|---|---|---|
| committer | 2018-03-19 03:35:38 +0000 | |
| commit | 2c91f55fb4af16eed0f852ecb5346e558a79475a (patch) | |
| tree | de61cc76e8642d022f216069da6bebceb39a8b73 /lib/libcrypto/crypto_init.c | |
| parent | NULL deref on armv7 performing NFS, within 10 seconds. (diff) | |
| download | wireguard-openbsd-2c91f55fb4af16eed0f852ecb5346e558a79475a.tar.xz wireguard-openbsd-2c91f55fb4af16eed0f852ecb5346e558a79475a.zip | |
Correct mistake of loading the default openssl.conf by default during autoinit.
This brings in the OPENSSL_INIT_LOAD_CONFIG flag with the same semantics as
OpenSSL. As a result, by default the openssl.conf file is not loaded during
autoinit, which makes autoinit safe for pledge(stdio).
ok jsing@
Diffstat (limited to 'lib/libcrypto/crypto_init.c')
| -rw-r--r-- | lib/libcrypto/crypto_init.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libcrypto/crypto_init.c b/lib/libcrypto/crypto_init.c index f3d1a2bce94..ed2b5d48100 100644 --- a/lib/libcrypto/crypto_init.c +++ b/lib/libcrypto/crypto_init.c @@ -25,6 +25,9 @@ #include <openssl/err.h> #include "cryptlib.h" +int OpenSSL_config(char *); +int OpenSSL_no_config(char *); + static pthread_t crypto_init_thread; static void @@ -35,7 +38,6 @@ OPENSSL_init_crypto_internal(void) ERR_load_crypto_strings(); OpenSSL_add_all_ciphers(); OpenSSL_add_all_digests(); - OPENSSL_config(NULL); } int @@ -46,11 +48,16 @@ OPENSSL_init_crypto(uint64_t opts, const void *settings) if (pthread_equal(pthread_self(), crypto_init_thread)) return 1; /* don't recurse */ - if (opts & OPENSSL_INIT_NO_LOAD_CONFIG) - OPENSSL_no_config(); - if (pthread_once(&once, OPENSSL_init_crypto_internal) != 0) return 0; + if ((opts & OPENSSL_INIT_NO_LOAD_CONFIG) && + (OpenSSL_no_config(NULL) == 0)) + return 0; + + if ((opts & OPENSSL_INIT_LOAD_CONFIG) && + (OpenSSL_config(NULL) == 0)) + return 0; + return 1; } |
