Skip to content

Commit 397fb1b

Browse files
committed
CryptoPkg: Fix the pkcs7 get cert fuzz
Signed-off-by: Wenxing Hou <[email protected]>
1 parent 9c3a481 commit 397fb1b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CryptoPkg/Library/BaseCryptLibMbedTls/Pk/CryptPkcs7VerifyCommon.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ Pkcs7GetSignedData (
470470
goto End;
471471
}
472472

473+
if (CertNum != 0) {
474+
FreePool (MoreCert);
475+
}
476+
473477
LastCert = &(SignedData->Certificates);
474478

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

494+
return Ret;
495+
490496
End:
491-
if (MoreCert != NULL) {
497+
if ((MoreCert != NULL) && (CertNum !=0)) {
492498
FreePool (MoreCert);
493499
MoreCert = NULL;
494500
}

0 commit comments

Comments
 (0)