Merge pull request #6337 from JacobBarthelmeh/fuzzing

add sanity check on PKCS7 index value
This commit is contained in:
Sean Parkinson 2023-04-26 08:33:25 +10:00 committed by GitHub
commit 7fb9540176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9733,6 +9733,10 @@ static int wc_PKCS7_DecryptKekri(PKCS7* pkcs7, byte* in, word32 inSz,
*idx += (dateLen + 1);
}
if (*idx > pkiMsgSz) {
return ASN_PARSE_E;
}
/* may have OPTIONAL OtherKeyAttribute */
localIdx = *idx;
if ((*idx < kekIdSz) && GetASNTag(pkiMsg, &localIdx, &tag,
@ -9745,6 +9749,10 @@ static int wc_PKCS7_DecryptKekri(PKCS7* pkcs7, byte* in, word32 inSz,
*idx += length;
}
if (*idx > pkiMsgSz) {
return ASN_PARSE_E;
}
/* get KeyEncryptionAlgorithmIdentifier */
if (GetAlgoId(pkiMsg, idx, &keyWrapOID, oidKeyWrapType, pkiMsgSz) < 0)
return ASN_PARSE_E;