Deprecate OBJ_cleanup() and make it a no-op
authorMatt Caswell <matt@openssl.org>
Mon, 4 Apr 2016 14:49:21 +0000 (15:49 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 13 Apr 2016 07:52:33 +0000 (08:52 +0100)
OBJ_cleanup() 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>
13 files changed:
apps/asn1pars.c
apps/ca.c
apps/req.c
apps/srp.c
apps/ts.c
apps/x509.c
crypto/asn1/asn_moid.c
crypto/evp/names.c
crypto/include/internal/objects.h [new file with mode: 0644]
crypto/init.c
crypto/objects/obj_dat.c
doc/crypto/OBJ_nid2obj.pod
include/openssl/objects.h

index a6cc6397fad8a6d9227ca36c3739b114b34ce219..3da7e3b4c5878a1cbb14776afeba6adb3f1c4939 100644 (file)
@@ -327,7 +327,6 @@ int asn1parse_main(int argc, char **argv)
         OPENSSL_free(str);
     ASN1_TYPE_free(at);
     sk_OPENSSL_STRING_free(osk);
         OPENSSL_free(str);
     ASN1_TYPE_free(at);
     sk_OPENSSL_STRING_free(osk);
-    OBJ_cleanup();
     return (ret);
 }
 
     return (ret);
 }
 
index d2990a5673ffb012bb0ef4903fed1172386da254..95801fbf39b9ed0a0404424b87f5fdca211345d1 100644 (file)
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1307,7 +1307,6 @@ end_of_options:
     X509_CRL_free(crl);
     NCONF_free(conf);
     NCONF_free(extconf);
     X509_CRL_free(crl);
     NCONF_free(conf);
     NCONF_free(extconf);
-    OBJ_cleanup();
     return (ret);
 }
 
     return (ret);
 }
 
index e3869bab19d50f68ae2989dc4abc6dc06e00f679..7f4a946aaa1fa274e720e63a6203057c33461248 100644 (file)
@@ -867,7 +867,6 @@ int req_main(int argc, char **argv)
         OPENSSL_free(passin);
     if (passout != nofree_passout)
         OPENSSL_free(passout);
         OPENSSL_free(passin);
     if (passout != nofree_passout)
         OPENSSL_free(passout);
-    OBJ_cleanup();
     return (ret);
 }
 
     return (ret);
 }
 
index 2c4d746f88e56a4251398ebac4c782dafa0281e2..1bf2ee299a01320f8c4454505e74028d822abcec 100644 (file)
@@ -653,7 +653,6 @@ int srp_main(int argc, char **argv)
         app_RAND_write_file(randfile);
     NCONF_free(conf);
     free_index(db);
         app_RAND_write_file(randfile);
     NCONF_free(conf);
     free_index(db);
-    OBJ_cleanup();
     return (ret);
 }
 #endif
     return (ret);
 }
 #endif
index 44e6004c7855dfc1bd228fddc7a94ba24c3b16a2..ec0cfa9d92990a74d45e3146e03fcdeecb248e21 100644 (file)
--- a/apps/ts.c
+++ b/apps/ts.c
@@ -383,7 +383,6 @@ int ts_main(int argc, char **argv)
     app_RAND_write_file(NULL);
     NCONF_free(conf);
     OPENSSL_free(password);
     app_RAND_write_file(NULL);
     NCONF_free(conf);
     OPENSSL_free(password);
-    OBJ_cleanup();
     return (ret);
 }
 
     return (ret);
 }
 
index 6ee26115eea2abd8f564b42a7a762423ef7cee8a..d8be179d437db05a7a65d29ed87b8080a93188b4 100644 (file)
@@ -919,7 +919,6 @@ int x509_main(int argc, char **argv)
  end:
     if (need_rand)
         app_RAND_write_file(NULL);
  end:
     if (need_rand)
         app_RAND_write_file(NULL);
-    OBJ_cleanup();
     NCONF_free(extconf);
     BIO_free_all(out);
     X509_STORE_free(ctx);
     NCONF_free(extconf);
     BIO_free_all(out);
     X509_STORE_free(ctx);
index 8198874aa92217fce6652332e6a1bc1cf26e29af..ded5d018b4d310976d991841b679d9f90bf2a65f 100644 (file)
@@ -63,6 +63,7 @@
 #include <openssl/conf.h>
 #include <openssl/x509.h>
 #include "internal/asn1_int.h"
 #include <openssl/conf.h>
 #include <openssl/x509.h>
 #include "internal/asn1_int.h"
+#include "internal/objects.h"
 
 /* Simple ASN1 OID module: add all objects in a given section */
 
 
 /* Simple ASN1 OID module: add all objects in a given section */
 
@@ -92,7 +93,7 @@ static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
 
 static void oid_module_finish(CONF_IMODULE *md)
 {
 
 static void oid_module_finish(CONF_IMODULE *md)
 {
-    OBJ_cleanup();
+    obj_cleanup_intern();
 }
 
 void ASN1_add_oid_module(void)
 }
 
 void ASN1_add_oid_module(void)
index 22c725d060b6e7ca707f5bfb7483cdfb16ba46b8..5ef52b43dfa61c9bd98a7f3a7aaaf0801cb5dbb2 100644 (file)
@@ -58,7 +58,7 @@
 #include <stdio.h>
 #include "internal/cryptlib.h"
 #include <openssl/evp.h>
 #include <stdio.h>
 #include "internal/cryptlib.h"
 #include <openssl/evp.h>
-#include <openssl/objects.h>
+#include <internal/objects.h>
 #include <openssl/x509.h>
 #include "internal/evp_int.h"
 
 #include <openssl/x509.h>
 #include "internal/evp_int.h"
 
@@ -142,7 +142,7 @@ void evp_cleanup_intern(void)
     EVP_PBE_cleanup();
     if (obj_cleanup_defer == 2) {
         obj_cleanup_defer = 0;
     EVP_PBE_cleanup();
     if (obj_cleanup_defer == 2) {
         obj_cleanup_defer = 0;
-        OBJ_cleanup();
+        obj_cleanup_intern();
     }
     OBJ_sigid_free();
 }
     }
     OBJ_sigid_free();
 }
diff --git a/crypto/include/internal/objects.h b/crypto/include/internal/objects.h
new file mode 100644 (file)
index 0000000..601294f
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Licensed under the OpenSSL licenses, (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * https://www.openssl.org/source/license.html
+ * or in the file LICENSE in the source distribution.
+ */
+
+#include <openssl/objects.h>
+
+void obj_cleanup_intern(void);
index dc24c0269319a4d3ba69408594e1959a43ca9cf4..170d11b91cbd7e54418cb09963fdbc390b40c751 100644 (file)
@@ -67,6 +67,7 @@
 #include <internal/engine.h>
 #include <internal/comp.h>
 #include <internal/err.h>
 #include <internal/engine.h>
 #include <internal/comp.h>
 #include <internal/err.h>
+#include <internal/objects.h>
 #include <stdlib.h>
 #include <assert.h>
 
 #include <stdlib.h>
 #include <assert.h>
 
@@ -468,7 +469,7 @@ void OPENSSL_cleanup(void)
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "evp_cleanup_intern()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
                     "evp_cleanup_intern()\n");
     fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
-                    "OBJ_cleanup()\n");
+                    "obj_cleanup_intern()\n");
 #endif
     /*
      * Note that cleanup order is important:
 #endif
     /*
      * Note that cleanup order is important:
@@ -489,7 +490,7 @@ void OPENSSL_cleanup(void)
     bio_sock_cleanup_intern();
 #endif
     evp_cleanup_intern();
     bio_sock_cleanup_intern();
 #endif
     evp_cleanup_intern();
-    OBJ_cleanup();
+    obj_cleanup_intern();
     base_inited = 0;
 }
 
     base_inited = 0;
 }
 
index 21b4187a25fedabaecc8826b218c9ad0a093d9cb..90db56bbd810ee5a196ad1b973c976ab82129936 100644 (file)
@@ -61,7 +61,7 @@
 #include "internal/cryptlib.h"
 #include <openssl/lhash.h>
 #include <openssl/asn1.h>
 #include "internal/cryptlib.h"
 #include <openssl/lhash.h>
 #include <openssl/asn1.h>
-#include <openssl/objects.h>
+#include "internal/objects.h"
 #include <openssl/bn.h>
 #include "internal/asn1_int.h"
 #include "obj_lcl.h"
 #include <openssl/bn.h>
 #include "internal/asn1_int.h"
 #include "obj_lcl.h"
@@ -210,7 +210,7 @@ void check_defer(int nid)
         obj_cleanup_defer = 1;
 }
 
         obj_cleanup_defer = 1;
 }
 
-void OBJ_cleanup(void)
+void obj_cleanup_intern(void)
 {
     if (obj_cleanup_defer) {
         obj_cleanup_defer = 2;
 {
     if (obj_cleanup_defer) {
         obj_cleanup_defer = 2;
index b2b815db65a90b2a0c78437bcc524a8f841a02ba..2db96a132f8d047d5037391d47bf0ebb9b69d3c9 100644 (file)
@@ -27,11 +27,16 @@ functions
  ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
 
  int OBJ_create(const char *oid,const char *sn,const char *ln);
  ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
 
  int OBJ_create(const char *oid,const char *sn,const char *ln);
- void OBJ_cleanup(void);
 
  size_t OBJ_length(const ASN1_OBJECT *obj);
  const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);
 
 
  size_t OBJ_length(const ASN1_OBJECT *obj);
  const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);
 
+Deprecated:
+
+ #if OPENSSL_API_COMPAT < 0x10100000L
+ # define OBJ_cleanup()
+ #endif
+
 =head1 DESCRIPTION
 
 The ASN1 object utility functions process ASN1_OBJECT structures which are
 =head1 DESCRIPTION
 
 The ASN1 object utility functions process ASN1_OBJECT structures which are
@@ -69,15 +74,17 @@ OBJ_create() adds a new object to the internal table. B<oid> is the
 numerical form of the object, B<sn> the short name and B<ln> the
 long name. A new NID is returned for the created object.
 
 numerical form of the object, B<sn> the short name and B<ln> the
 long name. A new NID is returned for the created object.
 
-OBJ_cleanup() cleans up OpenSSLs internal object table: this should
-be called before an application exits if any new objects were added
-using OBJ_create().
-
 OBJ_length() returns the size of the content octets of B<obj>.
 
 OBJ_get0_data() returns a pointer to the content octets of B<obj>.
 The returned pointer is an internal pointer which B<must not> be freed.
 
 OBJ_length() returns the size of the content octets of B<obj>.
 
 OBJ_get0_data() returns a pointer to the content octets of B<obj>.
 The returned pointer is an internal pointer which B<must not> be freed.
 
+In OpenSSL versions prior to 1.1.0 OBJ_cleanup() cleaned up OpenSSLs internal
+object table and was called before an application exits if any new objects were
+added using OBJ_create(). This function is deprecated in version 1.1.0 and now
+does nothing if called. No explicit de-initialisation is now required. See
+L<OPENSSL_init_crypto(3)> for further information.
+
 =head1 NOTES
 
 Objects in OpenSSL can have a short name, a long name and a numerical
 =head1 NOTES
 
 Objects in OpenSSL can have a short name, a long name and a numerical
@@ -160,6 +167,6 @@ L<ERR_get_error(3)>
 
 =head1 HISTORY
 
 
 =head1 HISTORY
 
-TBA
+OBJ_cleanup() was deprecated in OpenSSL 1.1.0.
 
 =cut
 
 =cut
index 05bc9b02486bfa48e47550d7e971fbe22b9c078d..c61e49ea35e66630d164718abbf1ca36c90672fd 100644 (file)
@@ -1103,7 +1103,9 @@ const void *OBJ_bsearch_ex_(const void *key, const void *base, int num,
 int OBJ_new_nid(int num);
 int OBJ_add_object(const ASN1_OBJECT *obj);
 int OBJ_create(const char *oid, const char *sn, const char *ln);
 int OBJ_new_nid(int num);
 int OBJ_add_object(const ASN1_OBJECT *obj);
 int OBJ_create(const char *oid, const char *sn, const char *ln);
-void OBJ_cleanup(void);
+#if OPENSSL_API_COMPAT < 0x10100000L
+# define OBJ_cleanup()
+#endif
 int OBJ_create_objects(BIO *in);
 
 size_t OBJ_length(const ASN1_OBJECT *obj);
 int OBJ_create_objects(BIO *in);
 
 size_t OBJ_length(const ASN1_OBJECT *obj);