diff options
Diffstat (limited to 'src/lib/libcrypto/err')
-rw-r--r-- | src/lib/libcrypto/err/err.c | 32 | ||||
-rw-r--r-- | src/lib/libcrypto/err/err_all.c | 18 |
2 files changed, 44 insertions, 6 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index ffe25bf465..320078da66 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: err.c,v 1.45 2017/02/20 23:21:19 beck Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.46 2018/03/17 16:20:01 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -109,6 +109,7 @@ | |||
109 | * | 109 | * |
110 | */ | 110 | */ |
111 | 111 | ||
112 | #include <pthread.h> | ||
112 | #include <stdarg.h> | 113 | #include <stdarg.h> |
113 | #include <stdio.h> | 114 | #include <stdio.h> |
114 | #include <string.h> | 115 | #include <string.h> |
@@ -282,6 +283,8 @@ static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; | |||
282 | static int int_thread_hash_references = 0; | 283 | static int int_thread_hash_references = 0; |
283 | static int int_err_library_number = ERR_LIB_USER; | 284 | static int int_err_library_number = ERR_LIB_USER; |
284 | 285 | ||
286 | static pthread_t err_init_thread; | ||
287 | |||
285 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | 288 | /* Internal function that checks whether "err_fns" is set and if not, sets it to |
286 | * the defaults. */ | 289 | * the defaults. */ |
287 | static void | 290 | static void |
@@ -650,8 +653,9 @@ ERR_STATE_free(ERR_STATE *s) | |||
650 | } | 653 | } |
651 | 654 | ||
652 | void | 655 | void |
653 | ERR_load_ERR_strings(void) | 656 | ERR_load_ERR_strings_internal(void) |
654 | { | 657 | { |
658 | err_init_thread = pthread_self(); | ||
655 | err_fns_check(); | 659 | err_fns_check(); |
656 | #ifndef OPENSSL_NO_ERR | 660 | #ifndef OPENSSL_NO_ERR |
657 | err_load_strings(0, ERR_str_libraries); | 661 | err_load_strings(0, ERR_str_libraries); |
@@ -662,6 +666,21 @@ ERR_load_ERR_strings(void) | |||
662 | #endif | 666 | #endif |
663 | } | 667 | } |
664 | 668 | ||
669 | |||
670 | void | ||
671 | ERR_load_ERR_strings(void) | ||
672 | { | ||
673 | static pthread_once_t once = PTHREAD_ONCE_INIT; | ||
674 | |||
675 | if (pthread_equal(pthread_self(), err_init_thread)) | ||
676 | return; /* don't recurse */ | ||
677 | |||
678 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
679 | (void) OPENSSL_init_crypto(0, NULL); | ||
680 | |||
681 | (void) pthread_once(&once, ERR_load_ERR_strings_internal); | ||
682 | } | ||
683 | |||
665 | static void | 684 | static void |
666 | err_load_strings(int lib, ERR_STRING_DATA *str) | 685 | err_load_strings(int lib, ERR_STRING_DATA *str) |
667 | { | 686 | { |
@@ -683,6 +702,9 @@ ERR_load_strings(int lib, ERR_STRING_DATA *str) | |||
683 | void | 702 | void |
684 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) | 703 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) |
685 | { | 704 | { |
705 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
706 | (void) OPENSSL_init_crypto(0, NULL); | ||
707 | |||
686 | while (str->error) { | 708 | while (str->error) { |
687 | if (lib) | 709 | if (lib) |
688 | str->error |= ERR_PACK(lib, 0, 0); | 710 | str->error |= ERR_PACK(lib, 0, 0); |
@@ -694,6 +716,9 @@ ERR_unload_strings(int lib, ERR_STRING_DATA *str) | |||
694 | void | 716 | void |
695 | ERR_free_strings(void) | 717 | ERR_free_strings(void) |
696 | { | 718 | { |
719 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
720 | (void) OPENSSL_init_crypto(0, NULL); | ||
721 | |||
697 | err_fns_check(); | 722 | err_fns_check(); |
698 | ERRFN(err_del)(); | 723 | ERRFN(err_del)(); |
699 | } | 724 | } |
@@ -953,6 +978,9 @@ ERR_lib_error_string(unsigned long e) | |||
953 | ERR_STRING_DATA d, *p; | 978 | ERR_STRING_DATA d, *p; |
954 | unsigned long l; | 979 | unsigned long l; |
955 | 980 | ||
981 | if (!OPENSSL_init_crypto(0, NULL)) | ||
982 | return NULL; | ||
983 | |||
956 | err_fns_check(); | 984 | err_fns_check(); |
957 | l = ERR_GET_LIB(e); | 985 | l = ERR_GET_LIB(e); |
958 | d.error = ERR_PACK(l, 0, 0); | 986 | d.error = ERR_PACK(l, 0, 0); |
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c index 40009cbe88..24de3c9c15 100644 --- a/src/lib/libcrypto/err/err_all.c +++ b/src/lib/libcrypto/err/err_all.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: err_all.c,v 1.23 2016/10/19 16:49:11 jsing Exp $ */ | 1 | /* $OpenBSD: err_all.c,v 1.24 2018/03/17 16:20:01 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -56,6 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <pthread.h> | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | 61 | ||
61 | #include <openssl/opensslconf.h> | 62 | #include <openssl/opensslconf.h> |
@@ -103,11 +104,13 @@ | |||
103 | #include <openssl/gost.h> | 104 | #include <openssl/gost.h> |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | void | 107 | void ERR_load_ERR_strings_internal(void); |
107 | ERR_load_crypto_strings(void) | 108 | |
109 | static void | ||
110 | ERR_load_crypto_strings_internal(void) | ||
108 | { | 111 | { |
109 | #ifndef OPENSSL_NO_ERR | 112 | #ifndef OPENSSL_NO_ERR |
110 | ERR_load_ERR_strings(); /* include error strings for SYSerr */ | 113 | ERR_load_ERR_strings_internal(); /* include error strings for SYSerr */ |
111 | ERR_load_BN_strings(); | 114 | ERR_load_BN_strings(); |
112 | #ifndef OPENSSL_NO_RSA | 115 | #ifndef OPENSSL_NO_RSA |
113 | ERR_load_RSA_strings(); | 116 | ERR_load_RSA_strings(); |
@@ -153,3 +156,10 @@ ERR_load_crypto_strings(void) | |||
153 | #endif | 156 | #endif |
154 | #endif | 157 | #endif |
155 | } | 158 | } |
159 | |||
160 | void | ||
161 | ERR_load_crypto_strings(void) | ||
162 | { | ||
163 | static pthread_once_t loaded = PTHREAD_ONCE_INIT; | ||
164 | (void) pthread_once(&loaded, ERR_load_crypto_strings_internal); | ||
165 | } | ||