Skip to content

Commit

Permalink
Clear ownership when duplicating sessions
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20848)

(cherry picked from commit 9fdf9a4)
  • Loading branch information
wbl authored and t8m committed May 12, 2023
1 parent ce616c7 commit 207848f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ssl/ssl_sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion test/sslapitest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 207848f

Please sign in to comment.