From e5cfd1dc1ce1ef66f5c8dae179ea623094d8080e Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 22 Feb 2018 16:38:43 +0000 Subject: [PATCH] Provide BIO_up_ref(). --- lib/libcrypto/Symbols.list | 1 + lib/libcrypto/bio/bio.h | 3 ++- lib/libcrypto/bio/bio_lib.c | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 4e29e85236e..854baed64a7 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -362,6 +362,7 @@ BIO_sock_should_retry BIO_socket_ioctl BIO_socket_nbio BIO_test_flags +BIO_up_ref BIO_vfree BIO_vprintf BIO_vsnprintf diff --git a/lib/libcrypto/bio/bio.h b/lib/libcrypto/bio/bio.h index 0a05d64929b..b85f7181bcd 100644 --- a/lib/libcrypto/bio/bio.h +++ b/lib/libcrypto/bio/bio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bio.h,v 1.38 2018/02/20 18:17:17 tb Exp $ */ +/* $OpenBSD: bio.h,v 1.39 2018/02/22 16:38:43 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -603,6 +603,7 @@ BIO *BIO_new_fp(FILE *stream, int close_flag); BIO * BIO_new(BIO_METHOD *type); int BIO_set(BIO *a, BIO_METHOD *type); int BIO_free(BIO *a); +int BIO_up_ref(BIO *bio); void *BIO_get_data(BIO *a); void BIO_set_data(BIO *a, void *ptr); void BIO_set_init(BIO *a, int init); diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c index 8ad54cefd2f..ddab5428817 100644 --- a/lib/libcrypto/bio/bio_lib.c +++ b/lib/libcrypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.26 2018/02/20 17:55:26 tb Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.27 2018/02/22 16:38:43 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -151,6 +151,13 @@ BIO_vfree(BIO *a) BIO_free(a); } +int +BIO_up_ref(BIO *bio) +{ + int refs = CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO); + return (refs > 1) ? 1 : 0; +} + void * BIO_get_data(BIO *a) { -- 2.20.1