Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: net/cert/cert_verify_proc_mac.cc

Issue 2760723002: Check X509Certificate::CreateFromHandle result. (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/cert_verify_proc_mac.cc
diff --git a/net/cert/cert_verify_proc_mac.cc b/net/cert/cert_verify_proc_mac.cc
index f31e4023b195faf719dd72be9414c052f9dcce6a..1d198bd6f882c890e345cc09d543da5c390453a0 100644
--- a/net/cert/cert_verify_proc_mac.cc
+++ b/net/cert/cert_verify_proc_mac.cc
@@ -180,7 +180,7 @@ OSStatus CreateTrustPolicies(int flags, ScopedCFTypeRef<CFArrayRef>* policies) {
// Stores the constructed certificate chain |cert_chain| into
// |*verify_result|. |cert_chain| must not be empty.
-void CopyCertChainToVerifyResult(CFArrayRef cert_chain,
+bool CopyCertChainToVerifyResult(CFArrayRef cert_chain,
CertVerifyResult* verify_result) {
DCHECK_LT(0, CFArrayGetCount(cert_chain));
@@ -197,11 +197,12 @@ void CopyCertChainToVerifyResult(CFArrayRef cert_chain,
}
if (!verified_cert) {
NOTREACHED();
- return;
+ return false;
}
verify_result->verified_cert =
X509Certificate::CreateFromHandle(verified_cert, verified_chain);
+ return !!verify_result->verified_chain;
}
// Returns true if the certificate uses MD2, MD4, MD5, or SHA1, and false
@@ -894,7 +895,8 @@ int VerifyWithGivenFlags(X509Certificate* cert,
verify_result->cert_status |= CERT_STATUS_REVOKED;
if (CFArrayGetCount(completed_chain) > 0) {
- CopyCertChainToVerifyResult(completed_chain, verify_result);
+ if (!CopyCertChainToVerifyResult(completed_chain, verify_result))
+ return ERR_CERT_INVALID;
}
// As of Security Update 2012-002/OS X 10.7.4, when an RSA key < 1024 bits

Powered by Google App Engine
This is Rietveld 408576698