Skip to content

Commit 7f6a796

Browse files
committed
Guard against unsigned underflow in inputLength calculation
Add bounds check before computing inputLength from curStartIdx + curSize to prevent unsigned underflow if *inOutIdx ever exceeds the record content boundary.
1 parent 9d8b6c4 commit 7f6a796

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18783,6 +18783,8 @@ static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1878318783

1878418784
/* curSize has already been reduced to content-only (padSz subtracted)
1878518785
* in ProcessReply, so curStartIdx + curSize bounds the content. */
18786+
if (*inOutIdx > (word32)ssl->curStartIdx + ssl->curSize)
18787+
return BUFFER_ERROR;
1878618788
inputLength = ssl->curStartIdx + ssl->curSize - *inOutIdx;
1878718789

1878818790
/* If there is a pending fragmented handshake message,

src/tls13.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13520,6 +13520,8 @@ int DoTls13HandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1352013520

1352113521
/* curSize has already been reduced to content-only (padSz subtracted)
1352213522
* in ProcessReply, so curStartIdx + curSize bounds the content. */
13523+
if (*inOutIdx > (word32)ssl->curStartIdx + ssl->curSize)
13524+
return BUFFER_ERROR;
1352313525
inputLength = ssl->curStartIdx + ssl->curSize - *inOutIdx;
1352413526

1352513527
/* If there is a pending fragmented handshake message,

0 commit comments

Comments
 (0)