Skip to content

Commit bcea3ea

Browse files
In wc_PKCS7_DecodeEnvelopedData, confirm encryptedContentTotalSz does not exceed the total message size before using it in the non-streaming case.
Thanks to Zou Dikai for the report.
1 parent 24d5881 commit bcea3ea

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

wolfcrypt/src/pkcs7.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13217,6 +13217,11 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1321713217
}
1321813218
wc_PKCS7_DecryptContentFree(pkcs7, encOID, pkcs7->heap);
1321913219
} else {
13220+
if ((idx + (word32)encryptedContentTotalSz) > pkiMsgSz) {
13221+
ret = BUFFER_E;
13222+
break;
13223+
}
13224+
1322013225
pkcs7->cachedEncryptedContentSz =
1322113226
(word32)encryptedContentTotalSz;
1322213227
pkcs7->totalEncryptedContentSz =

0 commit comments

Comments
 (0)