]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Clear ownership when duplicating sessions
authorWatson Ladd <watsonbladd@gmail.com>
Thu, 27 Apr 2023 17:14:51 +0000 (10:14 -0700)
committerTomas Mraz <tomas@openssl.org>
Fri, 12 May 2023 08:23:29 +0000 (10:23 +0200)
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)

ssl/ssl_sess.c
test/sslapitest.c

index 28d6cc1f154355205fc9fb90fb118740502dfd27..6d5e87f6877668a30b4e6f1f7f6f4204c04351f7 100644 (file)
@@ -169,9 +169,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;
 
index eb5b5a5476ceb0d93751e34650f4d6e74e4167b2..be1d742021e080b64e1e13b12adb9eaf141f9551 100644 (file)
@@ -2285,7 +2285,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);
         }