Make X509_OBJECT_up_ref_count return an int.
authortb <tb@openbsd.org>
Fri, 24 Aug 2018 19:21:09 +0000 (19:21 +0000)
committertb <tb@openbsd.org>
Fri, 24 Aug 2018 19:21:09 +0000 (19:21 +0000)
Based on OpenSSL commit c5ebfcab713a82a1d46a51c8c2668c419425b387

tested in a bulk by sthen
ok jsing

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

index 5121ae3..f21103c 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_lu.c,v 1.29 2018/05/18 17:46:17 tb Exp $ */
+/* $OpenBSD: x509_lu.c,v 1.30 2018/08/24 19:21:09 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -65,7 +65,6 @@
 #include "x509_lcl.h"
 
 static void X509_OBJECT_dec_ref_count(X509_OBJECT *a);
-/* static void X509_OBJECT_up_ref_count(X509_OBJECT *a); */
 
 X509_LOOKUP *
 X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
@@ -445,17 +444,16 @@ X509_OBJECT_dec_ref_count(X509_OBJECT *a)
        }
 }
 
-/*static*/ void
+int
 X509_OBJECT_up_ref_count(X509_OBJECT *a)
 {
        switch (a->type) {
        case X509_LU_X509:
-               CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509);
-               break;
+               return X509_up_ref(a->data.x509);
        case X509_LU_CRL:
-               CRYPTO_add(&a->data.crl->references, 1, CRYPTO_LOCK_X509_CRL);
-               break;
+               return X509_CRL_up_ref(a->data.crl);
        }
+       return 1;
 }
 
 int
index a29c2f0..c5eae9d 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_vfy.h,v 1.29 2018/05/18 22:02:23 tb Exp $ */
+/* $OpenBSD: x509_vfy.h,v 1.30 2018/08/24 19:21:09 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -423,7 +423,7 @@ int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
             X509_NAME *name);
 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,int type,X509_NAME *name);
 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x);
-void X509_OBJECT_up_ref_count(X509_OBJECT *a);
+int X509_OBJECT_up_ref_count(X509_OBJECT *a);
 int 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);