Skip to content

Commit

Permalink
CryptoPkg: Fix the pkcs7 get cert fuzz
Browse files Browse the repository at this point in the history
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
  • Loading branch information
Wenxing-hou committed Mar 19, 2024
1 parent 9c3a481 commit 98fab3d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ Pkcs7GetSignedData (
goto End;
}

if (CertNum != 0) {
FreePool (MoreCert);
}

LastCert = &(SignedData->Certificates);

while (CertNum--) {
Expand All @@ -487,8 +491,10 @@ Pkcs7GetSignedData (
Ret = MbedTlsPkcs7GetSignersInfoSet (&P, End, &SignedData->SignerInfos);
}

return Ret;

End:
if (MoreCert != NULL) {
if ((MoreCert != NULL) && (CertNum !=0)) {
FreePool (MoreCert);
MoreCert = NULL;
}
Expand Down Expand Up @@ -1085,6 +1091,9 @@ Pkcs7GetSigners (
while (SignerInfo != NULL) {
// Find signers cert
Cert = MbedTlsPkcs7FindSignerCert (SignerInfo, &(Pkcs7.SignedData.Certificates));
if (Cert == NULL) {
goto _Exit;
}

CertSize = Cert->raw.len;
OldSize = BufferSize;
Expand Down

0 comments on commit 98fab3d

Please sign in to comment.