From d17a940535e45c64cc4e6ef3e6e08209c54bd384 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 22 Feb 2018 17:29:24 +0000 Subject: [PATCH] Provide SSL_up_ref(). --- lib/libssl/Symbols.list | 1 + lib/libssl/ssl.h | 5 +++-- lib/libssl/ssl_lib.c | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libssl/Symbols.list b/lib/libssl/Symbols.list index 8169cf8d668..ad32b98677d 100644 --- a/lib/libssl/Symbols.list +++ b/lib/libssl/Symbols.list @@ -269,6 +269,7 @@ SSL_shutdown SSL_state SSL_state_string SSL_state_string_long +SSL_up_ref SSL_use_PrivateKey SSL_use_PrivateKey_ASN1 SSL_use_PrivateKey_file diff --git a/lib/libssl/ssl.h b/lib/libssl/ssl.h index 7756a71230e..1b92bde9d41 100644 --- a/lib/libssl/ssl.h +++ b/lib/libssl/ssl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.h,v 1.143 2018/02/22 17:27:07 jsing Exp $ */ +/* $OpenBSD: ssl.h,v 1.144 2018/02/22 17:29:24 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1337,7 +1337,6 @@ int SSL_check_private_key(const SSL *ctx); int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, unsigned int sid_ctx_len); -SSL *SSL_new(SSL_CTX *ctx); int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, unsigned int sid_ctx_len); int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); @@ -1350,7 +1349,9 @@ int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm); X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm); +SSL *SSL_new(SSL_CTX *ctx); void SSL_free(SSL *ssl); +int SSL_up_ref(SSL *ssl); int SSL_accept(SSL *ssl); int SSL_connect(SSL *ssl); int SSL_read(SSL *ssl, void *buf, int num); diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index 941a230ab1f..aa629a28487 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.177 2018/02/22 17:27:07 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.178 2018/02/22 17:29:25 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -568,6 +568,13 @@ SSL_free(SSL *s) free(s); } +int +SSL_up_ref(SSL *s) +{ + int refs = CRYPTO_add(&s->references, 1, CRYPTO_LOCK_SSL); + return (refs > 1) ? 1 : 0; +} + void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio) { -- 2.20.1