summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cert_store.cc
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 17:06:57 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-01 17:06:57 +0000
commit901d49a1cf6e564d002709eeb664cc5224571e99 (patch)
tree68ed7c823da09228bf4d0b081b3f2701c12711d6 /chrome/browser/cert_store.cc
parentd6aac0f6e268523654e286548fa4c2ea1ade6b63 (diff)
downloadchromium_src-901d49a1cf6e564d002709eeb664cc5224571e99.zip
chromium_src-901d49a1cf6e564d002709eeb664cc5224571e99.tar.gz
chromium_src-901d49a1cf6e564d002709eeb664cc5224571e99.tar.bz2
Ensure that CertStore::StoreCert never returns a cert_id of 0.
R=finnur,jcivelli BUG=none TEST=none Review URL: http://codereview.chromium.org/4181006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cert_store.cc')
-rw-r--r--chrome/browser/cert_store.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/chrome/browser/cert_store.cc b/chrome/browser/cert_store.cc
index 89c5ffe..e2f9c2c 100644
--- a/chrome/browser/cert_store.cc
+++ b/chrome/browser/cert_store.cc
@@ -55,6 +55,10 @@ int CertStore::StoreCert(net::X509Certificate* cert, int process_id) {
ReverseCertMap::iterator cert_iter = cert_to_id_.find(cert);
if (cert_iter == cert_to_id_.end()) {
cert_id = next_cert_id_++;
+ // We use 0 as an invalid cert_id value. In the unlikely event that
+ // next_cert_id_ wraps around, we reset it to 1.
+ if (next_cert_id_ == 0)
+ next_cert_id_ = 1;
cert->AddRef();
id_to_cert_[cert_id] = cert;
cert_to_id_[cert] = cert_id;