diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 21:43:41 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-08 21:43:41 +0000 |
commit | 7be616d40221cd4bb3c0f503f786ce98e4a486f3 (patch) | |
tree | 2b588fda5b83e167f72f45fb21a0b6eee716218e /crypto | |
parent | 8633f603bab2a4dfb0652e9a686562cc377c4512 (diff) | |
download | chromium_src-7be616d40221cd4bb3c0f503f786ce98e4a486f3.zip chromium_src-7be616d40221cd4bb3c0f503f786ce98e4a486f3.tar.gz chromium_src-7be616d40221cd4bb3c0f503f786ce98e4a486f3.tar.bz2 |
Protect against NULL delegate in NSSInit.
This is a fix for http://codereview.chromium.org/7244012 when running from the command line when the tpm delegate is not initialized.
BUG=chromium-os:15829
TEST=Run chrome for ChromeOS from the command line and open Network Menu > Other Wi-Fi network > Advanced. Chrome should not crash.
Review URL: http://codereview.chromium.org/7330007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/nss_util.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index 3b393fc..aa41ba2 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -231,12 +231,13 @@ class NSSInitSingleton { // login while the PINs are being initialized, and we want to retry // if this happens. bool EnsureTPMTokenReady() { - // If EnableTPMTokenForNSS hasn't been called, or if everything is - // already initialized, then this call succeeds. - if (tpm_token_info_delegate_.get() == NULL || - (opencryptoki_module_ && tpm_slot_)) { + // If EnableTPMTokenForNSS hasn't been called, return false. + if (tpm_token_info_delegate_.get() == NULL) + return false; + + // If everything is already initialized, then return true. + if (opencryptoki_module_ && tpm_slot_) return true; - } if (tpm_token_info_delegate_->IsTokenReady()) { // This tries to load the opencryptoki module so NSS can talk to @@ -264,10 +265,16 @@ class NSSInitSingleton { } bool IsTPMTokenAvailable() { + if (tpm_token_info_delegate_.get() == NULL) + return false; return tpm_token_info_delegate_->IsTokenAvailable(); } void GetTPMTokenInfo(std::string* token_name, std::string* user_pin) { + if (tpm_token_info_delegate_.get() == NULL) { + LOG(ERROR) << "GetTPMTokenInfo called before TPM Token is ready."; + return; + } tpm_token_info_delegate_->GetTokenInfo(token_name, user_pin); } |