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

Unified Diff: chromeos/cert_loader.cc

Issue 193273002: Handle cases when user cert database has NULL slots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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
« no previous file with comments | « chrome/browser/ui/webui/options/certificate_manager_handler.cc ('k') | chromeos/cert_loader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/cert_loader.cc
diff --git a/chromeos/cert_loader.cc b/chromeos/cert_loader.cc
index 7dc0b554268360bb9e280f5223362c450edca62f..d34b6d19126b8cb806fd1cd53686c07e66551ad8 100644
--- a/chromeos/cert_loader.cc
+++ b/chromeos/cert_loader.cc
@@ -13,6 +13,7 @@
#include "base/task_runner_util.h"
#include "base/threading/worker_pool.h"
#include "crypto/nss_util.h"
+#include "crypto/scoped_nss_types.h"
#include "net/cert/nss_cert_database.h"
#include "net/cert/nss_cert_database_chromeos.h"
#include "net/cert/x509_certificate.h"
@@ -86,12 +87,21 @@ void CertLoader::RemoveObserver(CertLoader::Observer* observer) {
int CertLoader::TPMTokenSlotID() const {
if (!database_)
return -1;
- return static_cast<int>(PK11_GetSlotID(database_->GetPrivateSlot().get()));
+ crypto::ScopedPK11Slot slot(database_->GetPrivateSlot());
+ if (!slot)
+ return -1;
+ return static_cast<int>(PK11_GetSlotID(slot.get()));
}
bool CertLoader::IsHardwareBacked() const {
- return force_hardware_backed_for_test_ ||
- (database_ && PK11_IsHW(database_->GetPrivateSlot().get()));
+ if (force_hardware_backed_for_test_)
+ return true;
+ if (!database_)
+ return false;
+ crypto::ScopedPK11Slot slot(database_->GetPrivateSlot());
+ if (!slot)
+ return false;
+ return PK11_IsHW(slot.get());
}
bool CertLoader::IsCertificateHardwareBacked(
« no previous file with comments | « chrome/browser/ui/webui/options/certificate_manager_handler.cc ('k') | chromeos/cert_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698