From a0d81d22e89ef62627c06fd19917add3917923f7 Mon Sep 17 00:00:00 2001
From: jsing <>
Date: Thu, 22 Feb 2018 17:29:25 +0000
Subject: Provide SSL_up_ref().

---
 src/lib/libssl/Symbols.list | 1 +
 src/lib/libssl/ssl.h        | 5 +++--
 src/lib/libssl/ssl_lib.c    | 9 ++++++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/lib/libssl/Symbols.list b/src/lib/libssl/Symbols.list
index 8169cf8d66..ad32b98677 100644
--- a/src/lib/libssl/Symbols.list
+++ b/src/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/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index 7756a71230..1b92bde9d4 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/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/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 941a230ab1..aa629a2848 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/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)
 {
-- 
cgit v1.2.3-55-g6feb