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

Unified Diff: net/base/x509_certificate_openssl.cc

Issue 10883012: net: don't crash when processing a certificate with an unknown public key. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 years, 4 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
« no previous file with comments | « net/base/cert_verify_proc_unittest.cc ('k') | net/base/x509_certificate_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_openssl.cc
diff --git a/net/base/x509_certificate_openssl.cc b/net/base/x509_certificate_openssl.cc
index 43198dc76c1879660766785bf0a63248732fd537..18afa5838968657efdd9fd5dc900e2fc9c07eb20 100644
--- a/net/base/x509_certificate_openssl.cc
+++ b/net/base/x509_certificate_openssl.cc
@@ -440,8 +440,14 @@ bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle,
void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
size_t* size_bits,
PublicKeyType* type) {
+ *type = kPublicKeyTypeUnknown;
+ *size_bits = 0;
+
crypto::ScopedOpenSSL<EVP_PKEY, EVP_PKEY_free> scoped_key(
X509_get_pubkey(cert_handle));
+ if (!scoped_key.get())
+ return;
+
CHECK(scoped_key.get());
EVP_PKEY* key = scoped_key.get();
@@ -462,10 +468,6 @@ void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
*type = kPublicKeyTypeDH;
*size_bits = EVP_PKEY_size(key) * 8;
break;
- default:
- *type = kPublicKeyTypeUnknown;
- *size_bits = 0;
- break;
}
}
« no previous file with comments | « net/base/cert_verify_proc_unittest.cc ('k') | net/base/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698