Skip to content

Commit e092484

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 72864a2 commit e092484

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
@@ -13231,6 +13231,11 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1323113231
}
1323213232
wc_PKCS7_DecryptContentFree(pkcs7, encOID, pkcs7->heap);
1323313233
} else {
13234+
if ((idx + (word32)encryptedContentTotalSz) > pkiMsgSz) {
13235+
ret = BUFFER_E;
13236+
break;
13237+
}
13238+
1323413239
pkcs7->cachedEncryptedContentSz =
1323513240
(word32)encryptedContentTotalSz;
1323613241
pkcs7->totalEncryptedContentSz =

0 commit comments

Comments
 (0)