Skip to content

Commit c99bc5d

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 6693ea3 commit c99bc5d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

wolfcrypt/src/pkcs7.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13223,6 +13223,11 @@ int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
1322313223
}
1322413224
wc_PKCS7_DecryptContentFree(pkcs7, encOID, pkcs7->heap);
1322513225
} else {
13226+
if ((idx + (word32)encryptedContentTotalSz) > pkiMsgSz) {
13227+
ret = BUFFER_E;
13228+
break;
13229+
}
13230+
1322613231
pkcs7->cachedEncryptedContentSz =
1322713232
(word32)encryptedContentTotalSz;
1322813233
pkcs7->totalEncryptedContentSz =

0 commit comments

Comments
 (0)