diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 00:59:56 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 00:59:56 +0000 |
commit | dbc13b5d232666808a29e0e787883f06082282fd (patch) | |
tree | 54e9c83e9f0431345b29ae64a7ecc01146140fae /net | |
parent | 0bbd6db7289b9b9337203715fd8d037f975bd044 (diff) | |
download | chromium_src-dbc13b5d232666808a29e0e787883f06082282fd.zip chromium_src-dbc13b5d232666808a29e0e787883f06082282fd.tar.gz chromium_src-dbc13b5d232666808a29e0e787883f06082282fd.tar.bz2 |
Do not call NSS functions if NSS initialization failed.
R=agl
BUG=36071
TEST=none
Review URL: http://codereview.chromium.org/1545034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/x509_certificate_nss.cc | 4 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss.cc | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/net/base/x509_certificate_nss.cc b/net/base/x509_certificate_nss.cc index 976435d..e311edb 100644 --- a/net/base/x509_certificate_nss.cc +++ b/net/base/x509_certificate_nss.cc @@ -5,6 +5,7 @@ #include "net/base/x509_certificate.h" #include <cert.h> +#include <nss.h> #include <pk11pub.h> #include <prerror.h> #include <prtime.h> @@ -722,6 +723,9 @@ X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( const char* data, int length) { base::EnsureNSSInit(); + if (!NSS_IsInitialized()) + return NULL; + // Make a copy of |data| since CERT_DecodeCertPackage might modify it. char* data_copy = new char[length]; memcpy(data_copy, data, length); diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index cdb8fa8..35e48e9 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -266,6 +266,8 @@ int SSLClientSocketNSS::Init() { // Initialize the NSS SSL library in a threadsafe way. This also // initializes the NSS base library. EnsureNSSSSLInit(); + if (!NSS_IsInitialized()) + return ERR_UNEXPECTED; #if !defined(OS_WIN) // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop // by MessageLoopForIO::current(). @@ -290,11 +292,13 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback, net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT); - if (Init() != OK) { - NOTREACHED() << "Couldn't initialize nss"; + int rv = Init(); + if (rv != OK) { + net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); + return rv; } - int rv = InitializeSSLOptions(); + rv = InitializeSSLOptions(); if (rv != OK) { net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); return rv; |