Remove X509_OBJECT_free_contents
authortb <tb@openbsd.org>
Fri, 14 Jan 2022 07:53:45 +0000 (07:53 +0000)
committertb <tb@openbsd.org>
Fri, 14 Jan 2022 07:53:45 +0000 (07:53 +0000)
Inline X509_OBJECT_free_contents() in X509_OBJECT_free() and
remove this dangerous API. It was left over when x509_vfy.h
was made opaque.

ok inoguchi jsing

lib/libcrypto/x509/x509_lu.c
lib/libcrypto/x509/x509_vfy.h

index 9400aec..90d7549 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_lu.c,v 1.54 2022/01/05 20:18:19 tb Exp $ */
+/* $OpenBSD: x509_lu.c,v 1.55 2022/01/14 07:53:45 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -230,7 +230,15 @@ X509_OBJECT_free(X509_OBJECT *a)
        if (a == NULL)
                return;
 
-       X509_OBJECT_free_contents(a);
+       switch (a->type) {
+       case X509_LU_X509:
+               X509_free(a->data.x509);
+               break;
+       case X509_LU_CRL:
+               X509_CRL_free(a->data.crl);
+               break;
+       }
+
        free(a);
 }
 
@@ -440,21 +448,6 @@ X509_OBJECT_get_type(const X509_OBJECT *a)
        return a->type;
 }
 
-void
-X509_OBJECT_free_contents(X509_OBJECT *a)
-{
-       switch (a->type) {
-       case X509_LU_X509:
-               X509_free(a->data.x509);
-               break;
-       case X509_LU_CRL:
-               X509_CRL_free(a->data.crl);
-               break;
-       }
-       memset(a, 0, sizeof(*a));
-       a->type = X509_LU_NONE;
-}
-
 static int
 x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
     X509_NAME *name, int *pnmatch)
index c50624a..9a649cb 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_vfy.h,v 1.49 2022/01/14 07:49:49 tb Exp $ */
+/* $OpenBSD: x509_vfy.h,v 1.50 2022/01/14 07:53:45 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -274,7 +274,6 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
 int X509_OBJECT_up_ref_count(X509_OBJECT *a);
 X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);
-void X509_OBJECT_free_contents(X509_OBJECT *a);
 X509 *X509_OBJECT_get0_X509(const X509_OBJECT *xo);
 X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo);