Skip to content
Snippets Groups Projects
Commit d8fb8d92 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

certstore: avoid accessing invalid iterator

In the else branch, `s` is always an invalid iterator.
Use `us` instead.

Change-Id: Ib517dce22f3bde103f753b325e919f86db299623
parent b1bcdecb
No related branches found
No related tags found
No related merge requests found
...@@ -604,12 +604,14 @@ TrustStore::getCertificateStatus(const std::string& cert_id) const ...@@ -604,12 +604,14 @@ TrustStore::getCertificateStatus(const std::string& cert_id) const
auto cert = certStore_.getCertificate(cert_id); auto cert = certStore_.getCertificate(cert_id);
if (!cert) if (!cert)
return PermissionStatus::UNDEFINED; return PermissionStatus::UNDEFINED;
auto allowed = false; auto found = false; auto allowed = false;
auto found = false;
while (cert) { while (cert) {
auto s = certStatus_.find(cert->getId().toString()); auto s = certStatus_.find(cert->getId().toString());
if (s != std::end(certStatus_)) { if (s != std::end(certStatus_)) {
if (!found) { if (!found) {
found = true; allowed = true; // we need to find at least a certificate found = true;
allowed = true; // we need to find at least a certificate
} }
allowed &= s->second.second.allowed; allowed &= s->second.second.allowed;
if (!allowed) if (!allowed)
...@@ -618,10 +620,11 @@ TrustStore::getCertificateStatus(const std::string& cert_id) const ...@@ -618,10 +620,11 @@ TrustStore::getCertificateStatus(const std::string& cert_id) const
auto us = unknownCertStatus_.find(cert->getId().toString()); auto us = unknownCertStatus_.find(cert->getId().toString());
if (us != std::end(unknownCertStatus_)) { if (us != std::end(unknownCertStatus_)) {
if (!found) { if (!found) {
found = true; allowed = true; // we need to find at least a certificate found = true;
allowed = true; // we need to find at least a certificate
} }
allowed &= s->second.second.allowed; allowed &= us->second.allowed;
if (!us->second.allowed) if (!allowed)
return PermissionStatus::BANNED; return PermissionStatus::BANNED;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment