Skip to content

Commit 0463e37

Browse files
Pad session ID with 0s if session ticket length is less than ID_LEN.
Prevents underflow in SetTicket. Thanks to Arjuna Arya for discovering and reporting this.
1 parent a08efc9 commit 0463e37

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/internal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34824,6 +34824,8 @@ int SendCertificateVerify(WOLFSSL* ssl)
3482434824
#ifdef HAVE_SESSION_TICKET
3482534825
int SetTicket(WOLFSSL* ssl, const byte* ticket, word32 length)
3482634826
{
34827+
word32 sessIdLen = (length >= ID_LEN) ? ID_LEN : length;
34828+
3482734829
if (!HaveUniqueSessionObj(ssl))
3482834830
return MEMORY_ERROR;
3482934831

@@ -34856,15 +34858,17 @@ int SetTicket(WOLFSSL* ssl, const byte* ticket, word32 length)
3485634858
ssl->options.haveSessionId = 1;
3485734859
#ifdef WOLFSSL_TLS13
3485834860
if (ssl->options.tls1_3) {
34861+
XMEMSET(ssl->session->sessionID, 0, ID_LEN);
3485934862
XMEMCPY(ssl->session->sessionID,
34860-
ssl->session->ticket + length - ID_LEN, ID_LEN);
34863+
ssl->session->ticket + length - sessIdLen, sessIdLen);
3486134864
ssl->session->sessionIDSz = ID_LEN;
3486234865
}
3486334866
else
3486434867
#endif
3486534868
{
34869+
XMEMSET(ssl->arrays->sessionID, 0, ID_LEN);
3486634870
XMEMCPY(ssl->arrays->sessionID,
34867-
ssl->session->ticket + length - ID_LEN, ID_LEN);
34871+
ssl->session->ticket + length - sessIdLen, sessIdLen);
3486834872
ssl->arrays->sessionIDSz = ID_LEN;
3486934873
}
3487034874
}

0 commit comments

Comments
 (0)