Skip to content

Commit 8f0eab0

Browse files
committed
Various security fixes and tests
1 parent b2f1c58 commit 8f0eab0

File tree

10 files changed

+444
-10
lines changed

10 files changed

+444
-10
lines changed

src/internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9834,7 +9834,7 @@ int DtlsMsgSet(DtlsMsg* msg, word32 seq, word16 epoch, const byte* data, byte ty
98349834
done = 1;
98359835
break;
98369836
}
9837-
else if (fragOffset <= curEnd) {
9837+
else if (fragOffset <= curEnd && fragOffsetEnd >= cur->m.m.offset) {
98389838
/* found place to store fragment */
98399839
break;
98409840
}

src/ssl_sess.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,22 @@ int wolfSSL_memrestore_session_cache(const void* mem, int sz)
522522
#endif
523523

524524
XMEMCPY(&SessionCache[i], row++, SIZEOF_SESSION_ROW);
525+
#ifndef SESSION_CACHE_DYNAMIC_MEM
526+
/* Reset pointers to safe values after raw copy */
527+
{
528+
int j;
529+
for (j = 0; j < SESSIONS_PER_ROW; j++) {
530+
WOLFSSL_SESSION* s = &SessionCache[i].Sessions[j];
531+
#ifdef HAVE_SESSION_TICKET
532+
s->ticket = s->staticTicket;
533+
s->ticketLenAlloc = 0;
534+
#endif
535+
#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)
536+
s->peer = NULL;
537+
#endif
538+
}
539+
}
540+
#endif
525541
#ifdef ENABLE_SESSION_CACHE_ROW_LOCK
526542
SESSION_ROW_UNLOCK(&SessionCache[i]);
527543
#endif
@@ -681,6 +697,22 @@ int wolfSSL_restore_session_cache(const char *fname)
681697
#endif
682698

683699
ret = (int)XFREAD(&SessionCache[i], SIZEOF_SESSION_ROW, 1, file);
700+
#ifndef SESSION_CACHE_DYNAMIC_MEM
701+
/* Reset pointers to safe values after raw copy */
702+
{
703+
int j;
704+
for (j = 0; j < SESSIONS_PER_ROW; j++) {
705+
WOLFSSL_SESSION* s = &SessionCache[i].Sessions[j];
706+
#ifdef HAVE_SESSION_TICKET
707+
s->ticket = s->staticTicket;
708+
s->ticketLenAlloc = 0;
709+
#endif
710+
#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)
711+
s->peer = NULL;
712+
#endif
713+
}
714+
}
715+
#endif
684716
#ifdef ENABLE_SESSION_CACHE_ROW_LOCK
685717
SESSION_ROW_UNLOCK(&SessionCache[i]);
686718
#endif

src/tls.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9937,6 +9937,10 @@ static int TLSX_KeyShare_ProcessPqcClient_ex(WOLFSSL* ssl,
99379937
}
99389938
#endif
99399939

9940+
if (ret == 0 && keyShareEntry->keLen < ctSz) {
9941+
WOLFSSL_MSG("PQC key share data too short for ciphertext.");
9942+
ret = BUFFER_E;
9943+
}
99409944
if (ret == 0) {
99419945
ret = wc_KyberKey_Decapsulate(kem, ssOutput,
99429946
keyShareEntry->ke, ctSz);

0 commit comments

Comments
 (0)