Deprecate ERR_free_strings() and make it a no-op
authorMatt Caswell <matt@openssl.org>
Mon, 4 Apr 2016 12:43:58 +0000 (13:43 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 13 Apr 2016 07:52:33 +0000 (08:52 +0100)
ERR_free_strings() should not be called expicitly - we should leave
auto-deinit to clean this up instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/err/err.c
crypto/include/internal/err.h [deleted file]
crypto/init.c
doc/crypto/ERR_load_crypto_strings.pod
doc/crypto/err.pod
include/internal/err.h [new file with mode: 0644]
include/openssl/err.h
ssl/ssl_init.c

index da6d3ee981c5ad5268d790e4d57115b4f5813366..b937155c98091ac2690ed91a49ef4172f3efcc9b 100644 (file)
 #include <openssl/crypto.h>
 #include <openssl/buffer.h>
 #include <openssl/bio.h>
-#include <openssl/err.h>
+#include "internal/err.h"
 #include <openssl/opensslconf.h>
 
 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)
     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);
 
diff --git a/crypto/include/internal/err.h b/crypto/include/internal/err.h
deleted file mode 100644 (file)
index aa48019..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Written by Matt Caswell for the OpenSSL project.
- */
-/* ====================================================================
- * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. All advertising materials mentioning features or use of this
- *    software must display the following acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
- *
- * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
- *    endorse or promote products derived from this software without
- *    prior written permission. For written permission, please contact
- *    openssl-core@openssl.org.
- *
- * 5. Products derived from this software may not be called "OpenSSL"
- *    nor may "OpenSSL" appear in their names without prior written
- *    permission of the OpenSSL Project.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- *    acknowledgment:
- *    "This product includes software developed by the OpenSSL Project
- *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
- *
- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- * ====================================================================
- *
- * This product includes cryptographic software written by Eric Young
- * (eay@cryptsoft.com).  This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
-
-void err_load_crypto_strings_intern(void);
index fe1ecd876c795f40e41b155988a740ea5aa305b7..3699145ac69af7a5508883f288eb043799fed218 100644 (file)
@@ -444,9 +444,9 @@ void OPENSSL_cleanup(void)
     if (load_crypto_strings_inited) {
 #ifdef OPENSSL_INIT_DEBUG
         fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
-                        "ERR_free_strings()\n");
+                        "err_free_strings_intern()\n");
 #endif
-        ERR_free_strings();
+        err_free_strings_intern();
     }
 
     CRYPTO_THREAD_cleanup_local(&threadstopkey);
index 88678d90205aea35011588800b73967e19ebe7be..9e960d94c9a7801b721d1048785cb94ba4265312 100644 (file)
@@ -7,26 +7,36 @@ load and free error strings
 
 =head1 SYNOPSIS
 
+Deprecated:
+
  #include <openssl/err.h>
 
- void ERR_load_crypto_strings(void);
- void ERR_free_strings(void);
+ #if OPENSSL_API_COMPAT < 0x10100000L
+ # define ERR_load_crypto_strings() \
+     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ # define ERR_free_strings()
+ #endif
 
  #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
 
+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
 B<libcrypto> functions. SSL_load_error_strings() does the same,
 but also registers the B<libssl> error strings.
 
-One of these functions should be called before generating
-textual error messages. However, this is not required when memory
-usage is an issue.
-
-ERR_free_strings() frees all previously loaded error strings.
+In versions of OpenSSL prior to 1.1.0 ERR_free_strings() freed all previously
+loaded error strings. However from OpenSSL 1.1.0 it does nothing.
 
 =head1 RETURN VALUES
 
index 6847f2153c4a6fd0f67bb6419984b8927c6b0f08..0313aa38b8356dfbffe40fed395e68e07eede121 100644 (file)
@@ -33,7 +33,6 @@ err - error codes
  void ERR_print_errors_fp(FILE *fp);
 
  void ERR_load_crypto_strings(void);
- void ERR_free_strings(void);
 
  void ERR_put_error(int lib, int func, int reason, const char *file,
          int line);
@@ -49,6 +48,11 @@ Deprecated:
  void ERR_remove_state(unsigned long pid);
  #endif
 
+ #if OPENSSL_API_COMPAT < 0x10100000L
+ # define ERR_free_strings()
+ #endif
+
+
 =head1 DESCRIPTION
 
 When a call to the OpenSSL library fails, this is usually signaled
diff --git a/include/internal/err.h b/include/internal/err.h
new file mode 100644 (file)
index 0000000..d1a413f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Written by Matt Caswell for the OpenSSL project.
+ */
+/* ====================================================================
+ * Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please contact
+ *    openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ *    nor may "OpenSSL" appear in their names without prior written
+ *    permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the OpenSSL Project
+ *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com).  This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+void err_load_crypto_strings_intern(void);
+void err_free_strings_intern(void);
index d372520d03ed6f6e47d0e0d6f0d09c46c4306c27..deb2fe246ec531e6b950944d926f54efe90ada42 100644 (file)
@@ -356,10 +356,9 @@ void ERR_load_ERR_strings(void);
 #if OPENSSL_API_COMPAT < 0x10100000L
 # define ERR_load_crypto_strings() \
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+# define ERR_free_strings()
 #endif
 
-void ERR_free_strings(void);
-
 void ERR_remove_thread_state(void);
 DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid)) /* if zero we
                                                               * look it up */
index 413fa4105bc4a3d72dc6645e7e6a22841b4943b5..2462fa5eab1329794119ab5ea0d4a592c17f4078 100644 (file)
@@ -57,7 +57,8 @@
 
 #include "e_os.h"
 
-#include <internal/threads.h>
+#include "internal/threads.h"
+#include "internal/err.h"
 #include <openssl/crypto.h>
 #include <openssl/evp.h>
 #include <assert.h>
@@ -206,15 +207,15 @@ static void ssl_library_stop(void)
     if (ssl_strings_inited) {
 #ifdef OPENSSL_INIT_DEBUG
         fprintf(stderr, "OPENSSL_INIT: ssl_library_stop: "
-                        "ERR_free_strings()\n");
+                        "err_free_strings_intern()\n");
 #endif
         /*
          * 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
-         * will be a no-op. It's easier to do that than to try and track
+         * calling err_free_strings_intern() twice - but that's ok. The second
+         * 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.
          */
-        ERR_free_strings();
+        err_free_strings_intern();
     }
 }