sanity check on pkcs7 stream amount read

This commit is contained in:
Jacob Barthelmeh 2021-07-30 22:11:45 +07:00
parent a802c270e1
commit 293755917e

View File

@ -8357,6 +8357,11 @@ static int wc_PKCS7_DecryptKtri(PKCS7* pkcs7, byte* in, word32 inSz,
/* @TODO getting total amount left because of GetInt call later on
* this could be optimized to stream better */
if (pkcs7->stream->totalRd > pkcs7->stream->maxLen) {
WOLFSSL_MSG("PKCS7 read more than expected");
ret = BUFFER_E;
break;
}
pkcs7->stream->expected = (pkcs7->stream->maxLen -
pkcs7->stream->totalRd) + pkcs7->stream->length;
#endif