From c6d61022a27f26e97012570c2697ecbe1aae7c1d Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 22 Feb 2018 17:25:18 +0000 Subject: [PATCH] Provide SSL_SESSION_up_ref(). --- lib/libssl/Symbols.list | 1 + lib/libssl/ssl.h | 5 +++-- lib/libssl/ssl_sess.c | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/libssl/Symbols.list b/lib/libssl/Symbols.list index ed7f9f6e64a..60e56396bfa 100644 --- a/lib/libssl/Symbols.list +++ b/lib/libssl/Symbols.list @@ -145,6 +145,7 @@ SSL_SESSION_set1_id_context SSL_SESSION_set_ex_data SSL_SESSION_set_time SSL_SESSION_set_timeout +SSL_SESSION_up_ref SSL_accept SSL_add_client_CA SSL_add_dir_cert_subjects_to_stack diff --git a/lib/libssl/ssl.h b/lib/libssl/ssl.h index 47c90fb39db..c24c729bb26 100644 --- a/lib/libssl/ssl.h +++ b/lib/libssl/ssl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.h,v 1.141 2018/02/20 18:07:11 tb Exp $ */ +/* $OpenBSD: ssl.h,v 1.142 2018/02/22 17:25:18 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1290,12 +1290,13 @@ int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, unsigned int sid_ctx_len); SSL_SESSION *SSL_SESSION_new(void); +void SSL_SESSION_free(SSL_SESSION *ses); +int SSL_SESSION_up_ref(SSL_SESSION *ss); const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len); unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s); int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses); -void SSL_SESSION_free(SSL_SESSION *ses); int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); int SSL_set_session(SSL *to, SSL_SESSION *session); int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); diff --git a/lib/libssl/ssl_sess.c b/lib/libssl/ssl_sess.c index 54e39183f51..37a02380043 100644 --- a/lib/libssl/ssl_sess.c +++ b/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.73 2018/02/20 18:07:11 tb Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.74 2018/02/22 17:25:18 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -709,6 +709,13 @@ SSL_SESSION_free(SSL_SESSION *ss) freezero(ss, sizeof(*ss)); } +int +SSL_SESSION_up_ref(SSL_SESSION *ss) +{ + int refs = CRYPTO_add(&ss->references, 1, CRYPTO_LOCK_SSL_SESSION); + return (refs > 1) ? 1 : 0; +} + int SSL_set_session(SSL *s, SSL_SESSION *session) { -- 2.20.1