Skip to content

Commit 7b29362

Browse files
icingjulek-wolfssl
authored andcommitted
Updating a shared session objects needs to do copy on write
1 parent 32a07a7 commit 7b29362

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/internal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31810,6 +31810,15 @@ int SendCertificateVerify(WOLFSSL* ssl)
3181031810
#ifdef HAVE_SESSION_TICKET
3181131811
int SetTicket(WOLFSSL* ssl, const byte* ticket, word32 length)
3181231812
{
31813+
/* If the session is shared, we need to copy-on-write */
31814+
if (ssl->session->ref.count > 1) {
31815+
WOLFSSL_SESSION* nsession = wolfSSL_SESSION_dup(ssl->session);
31816+
if (nsession == NULL)
31817+
return MEMORY_E;
31818+
wolfSSL_FreeSession(ssl->ctx, ssl->session);
31819+
ssl->session = nsession;
31820+
}
31821+
3181331822
/* Free old dynamic ticket if we already had one */
3181431823
if (ssl->session->ticketLenAlloc > 0) {
3181531824
XFREE(ssl->session->ticket, ssl->heap, DYNAMIC_TYPE_SESSION_TICK);

0 commit comments

Comments
 (0)