CryptoPkg/BaseCryptLib: Add NULL pointer checks in DH and P7Verify
Add more NULL pointer checks before using them in DhGenerateKey and
Pkcs7GetCertificatesList functions to eliminate possible dereferenced
pointer issue.
Cc: Ting Ye <ting.ye@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
(cherry picked from commit a9fb7b7803
)
This commit is contained in:
@ -232,7 +232,9 @@ DhGenerateKey (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (PublicKey != NULL) {
|
||||
BN_bn2bin (DhPubKey, PublicKey);
|
||||
}
|
||||
*PublicKeySize = Size;
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,9 @@ Pkcs7GetCertificatesList (
|
||||
}
|
||||
}
|
||||
CtxUntrusted = X509_STORE_CTX_get0_untrusted (CertCtx);
|
||||
if (CtxUntrusted != NULL) {
|
||||
(VOID)sk_X509_delete_ptr (CtxUntrusted, Signer);
|
||||
}
|
||||
|
||||
//
|
||||
// Build certificates stack chained from Signer's certificate.
|
||||
@ -711,8 +713,10 @@ _Error:
|
||||
}
|
||||
sk_X509_free (Signers);
|
||||
|
||||
if (CertCtx != NULL) {
|
||||
X509_STORE_CTX_cleanup (CertCtx);
|
||||
X509_STORE_CTX_free (CertCtx);
|
||||
}
|
||||
|
||||
if (SingleCert != NULL) {
|
||||
free (SingleCert);
|
||||
|
Reference in New Issue
Block a user