File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21162,16 +21162,19 @@ int ProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
2116221162 ssl->keys.decryptedCur = 1;
2116321163#ifdef WOLFSSL_TLS13
2116421164 if (ssl->options.tls1_3) {
21165- /* end of plaintext */
21166- word16 i = (word16)(ssl->buffers.inputBuffer.idx +
21167- ssl->curSize - ssl->specs.aead_mac_size);
21168-
21169- /* check i isn't too big and won't wrap around on --i */
21170- if (i > ssl->buffers.inputBuffer.length || i == 0) {
21165+ /* check that the end of the logical length doesn't extend
21166+ * past the real buffer */
21167+ word32 boundsCheck = ( ssl->buffers.inputBuffer.idx +
21168+ ssl->curSize - ssl->specs.aead_mac_size);
21169+ if (boundsCheck > ssl->buffers.inputBuffer.length ||
21170+ boundsCheck == 0) {
2117121171 WOLFSSL_ERROR(BUFFER_ERROR);
2117221172 return BUFFER_ERROR;
2117321173 }
2117421174
21175+ /* end of plaintext */
21176+ word16 i = (word16)(boundsCheck);
21177+
2117521178 /* Remove padding from end of plain text. */
2117621179 for (--i; i > ssl->buffers.inputBuffer.idx; i--) {
2117721180 if (ssl->buffers.inputBuffer.buffer[i] != 0)
You can’t perform that action at this time.
0 commit comments