提交 6827cb36 编写于 作者: M Matt Caswell

Deprecate ERR_free_strings() and make it a no-op

ERR_free_strings() should not be called expicitly - we should leave
auto-deinit to clean this up instead.
Reviewed-by: NTim Hudson <tjh@openssl.org>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 02a247e0
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/bio.h> #include <openssl/bio.h>
#include <openssl/err.h> #include "internal/err.h"
#include <openssl/opensslconf.h> #include <openssl/opensslconf.h>
static void err_load_strings(int lib, ERR_STRING_DATA *str); static void err_load_strings(int lib, ERR_STRING_DATA *str);
...@@ -447,7 +447,7 @@ void ERR_unload_strings(int lib, ERR_STRING_DATA *str) ...@@ -447,7 +447,7 @@ void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
CRYPTO_THREAD_unlock(err_string_lock); CRYPTO_THREAD_unlock(err_string_lock);
} }
void ERR_free_strings(void) void err_free_strings_intern(void)
{ {
CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init); CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
......
...@@ -444,9 +444,9 @@ void OPENSSL_cleanup(void) ...@@ -444,9 +444,9 @@ void OPENSSL_cleanup(void)
if (load_crypto_strings_inited) { if (load_crypto_strings_inited) {
#ifdef OPENSSL_INIT_DEBUG #ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: " fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
"ERR_free_strings()\n"); "err_free_strings_intern()\n");
#endif #endif
ERR_free_strings(); err_free_strings_intern();
} }
CRYPTO_THREAD_cleanup_local(&threadstopkey); CRYPTO_THREAD_cleanup_local(&threadstopkey);
......
...@@ -7,26 +7,36 @@ load and free error strings ...@@ -7,26 +7,36 @@ load and free error strings
=head1 SYNOPSIS =head1 SYNOPSIS
Deprecated:
#include <openssl/err.h> #include <openssl/err.h>
void ERR_load_crypto_strings(void); #if OPENSSL_API_COMPAT < 0x10100000L
void ERR_free_strings(void); # define ERR_load_crypto_strings() \
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
# define ERR_free_strings()
#endif
#include <openssl/ssl.h> #include <openssl/ssl.h>
void SSL_load_error_strings(void); #if OPENSSL_API_COMPAT < 0x10100000L
# define SSL_load_error_strings() \
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
#endif
=head1 DESCRIPTION =head1 DESCRIPTION
All of the following functions are deprecated from OpenSSL 1.1.0. No explicit
initialisation or de-initialisation is necessary. See L<OPENSSL_init_crypto(3)>
and L<OPENSSL_init_ssl(3)>.
ERR_load_crypto_strings() registers the error strings for all ERR_load_crypto_strings() registers the error strings for all
B<libcrypto> functions. SSL_load_error_strings() does the same, B<libcrypto> functions. SSL_load_error_strings() does the same,
but also registers the B<libssl> error strings. but also registers the B<libssl> error strings.
One of these functions should be called before generating In versions of OpenSSL prior to 1.1.0 ERR_free_strings() freed all previously
textual error messages. However, this is not required when memory loaded error strings. However from OpenSSL 1.1.0 it does nothing.
usage is an issue.
ERR_free_strings() frees all previously loaded error strings.
=head1 RETURN VALUES =head1 RETURN VALUES
......
...@@ -33,7 +33,6 @@ err - error codes ...@@ -33,7 +33,6 @@ err - error codes
void ERR_print_errors_fp(FILE *fp); void ERR_print_errors_fp(FILE *fp);
void ERR_load_crypto_strings(void); void ERR_load_crypto_strings(void);
void ERR_free_strings(void);
void ERR_put_error(int lib, int func, int reason, const char *file, void ERR_put_error(int lib, int func, int reason, const char *file,
int line); int line);
...@@ -49,6 +48,11 @@ Deprecated: ...@@ -49,6 +48,11 @@ Deprecated:
void ERR_remove_state(unsigned long pid); void ERR_remove_state(unsigned long pid);
#endif #endif
#if OPENSSL_API_COMPAT < 0x10100000L
# define ERR_free_strings()
#endif
=head1 DESCRIPTION =head1 DESCRIPTION
When a call to the OpenSSL library fails, this is usually signaled When a call to the OpenSSL library fails, this is usually signaled
......
...@@ -56,3 +56,4 @@ ...@@ -56,3 +56,4 @@
*/ */
void err_load_crypto_strings_intern(void); void err_load_crypto_strings_intern(void);
void err_free_strings_intern(void);
...@@ -356,10 +356,9 @@ void ERR_load_ERR_strings(void); ...@@ -356,10 +356,9 @@ void ERR_load_ERR_strings(void);
#if OPENSSL_API_COMPAT < 0x10100000L #if OPENSSL_API_COMPAT < 0x10100000L
# define ERR_load_crypto_strings() \ # define ERR_load_crypto_strings() \
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
# define ERR_free_strings()
#endif #endif
void ERR_free_strings(void);
void ERR_remove_thread_state(void); void ERR_remove_thread_state(void);
DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid)) /* if zero we DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid)) /* if zero we
* look it up */ * look it up */
......
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
#include "e_os.h" #include "e_os.h"
#include <internal/threads.h> #include "internal/threads.h"
#include "internal/err.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <assert.h> #include <assert.h>
...@@ -206,15 +207,15 @@ static void ssl_library_stop(void) ...@@ -206,15 +207,15 @@ static void ssl_library_stop(void)
if (ssl_strings_inited) { if (ssl_strings_inited) {
#ifdef OPENSSL_INIT_DEBUG #ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: ssl_library_stop: " fprintf(stderr, "OPENSSL_INIT: ssl_library_stop: "
"ERR_free_strings()\n"); "err_free_strings_intern()\n");
#endif #endif
/* /*
* If both crypto and ssl error strings are inited we will end up * If both crypto and ssl error strings are inited we will end up
* calling ERR_free_strings() twice - but that's ok. The second time * calling err_free_strings_intern() twice - but that's ok. The second
* will be a no-op. It's easier to do that than to try and track * time will be a no-op. It's easier to do that than to try and track
* between the two libraries whether they have both been inited. * between the two libraries whether they have both been inited.
*/ */
ERR_free_strings(); err_free_strings_intern();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册