Skip to content

Commit

Permalink
do bounds check on full word32 size to match
Browse files Browse the repository at this point in the history
inputBuffer length
  • Loading branch information
jpbland1 committed Jan 3, 2024
1 parent e641c6b commit e1435e9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21162,16 +21162,19 @@ int ProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
ssl->keys.decryptedCur = 1;
#ifdef WOLFSSL_TLS13
if (ssl->options.tls1_3) {
/* end of plaintext */
word16 i = (word16)(ssl->buffers.inputBuffer.idx +
ssl->curSize - ssl->specs.aead_mac_size);

/* check i isn't too big and won't wrap around on --i */
if (i > ssl->buffers.inputBuffer.length || i == 0) {
/* check that the end of the logical length doesn't extend
* past the real buffer */
word32 boundsCheck = (ssl->buffers.inputBuffer.idx +
ssl->curSize - ssl->specs.aead_mac_size);
if (boundsCheck > ssl->buffers.inputBuffer.length ||
boundsCheck == 0) {
WOLFSSL_ERROR(BUFFER_ERROR);
return BUFFER_ERROR;
}

/* end of plaintext */
word16 i = (word16)(boundsCheck);

/* Remove padding from end of plain text. */
for (--i; i > ssl->buffers.inputBuffer.idx; i--) {
if (ssl->buffers.inputBuffer.buffer[i] != 0)
Expand Down

0 comments on commit e1435e9

Please sign in to comment.