summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWatson Ladd <watsonbladd@gmail.com>2023-04-27 10:14:51 -0700
committerTomas Mraz <tomas@openssl.org>2023-05-12 10:24:14 +0200
commit207848ffb69c66c23d3197f33bb2daf07db9a43a (patch)
treef12ecdabe093a96f1f260b988f87a98bafedd9da
parentce616c75e04666c7575ad068a699686910e299c3 (diff)
downloadopenssl-new-207848ffb69c66c23d3197f33bb2daf07db9a43a.tar.gz
Clear ownership when duplicating sessions
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20848) (cherry picked from commit 9fdf9a44bbe3827fe653165a07281ccae8ab0947)
-rw-r--r--ssl/ssl_sess.c3
-rw-r--r--test/sslapitest.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c
index f065f2f75a..2efc44536c 100644
--- a/ssl/ssl_sess.c
+++ b/ssl/ssl_sess.c
@@ -192,9 +192,10 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
dest->ticket_appdata = NULL;
memset(&dest->ex_data, 0, sizeof(dest->ex_data));
- /* We deliberately don't copy the prev and next pointers */
+ /* As the copy is not in the cache, we remove the associated pointers */
dest->prev = NULL;
dest->next = NULL;
+ dest->owner = NULL;
dest->references = 1;
diff --git a/test/sslapitest.c b/test/sslapitest.c
index ef7eb5b660..294158387b 100644
--- a/test/sslapitest.c
+++ b/test/sslapitest.c
@@ -2257,7 +2257,9 @@ static int execute_test_session(int maxprot, int use_int_cache,
*/
if (use_int_cache && maxprot != TLS1_3_VERSION) {
if (!TEST_ptr(tmp = SSL_SESSION_dup(sess2))
- || !TEST_true(SSL_CTX_remove_session(sctx, sess2)))
+ || !TEST_true(sess2->owner != NULL)
+ || !TEST_true(tmp->owner == NULL)
+ || !TEST_true(SSL_CTX_remove_session(sctx, sess2)))
goto end;
SSL_SESSION_free(sess2);
}