sanity check on padlen with pkcs7 decode

This commit is contained in:
Jacob Barthelmeh
2019-03-13 10:00:43 -06:00
parent 0d48a4a1a7
commit 06e5f8c39b

View File

@ -9354,6 +9354,12 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* in,
padLen = encryptedContent[encryptedContentSz-1];
/* copy plaintext to output */
if (padLen > encryptedContentSz ||
(word32)(encryptedContentSz - padLen) > outputSz) {
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
ret = BUFFER_E;
break;
}
XMEMCPY(output, encryptedContent, encryptedContentSz - padLen);
/* free memory, zero out keys */