certstore: avoid accessing invalid iterator
In the else branch, `s` is always an invalid iterator.
Use `us` instead.
Change-Id: Ib517dce22f3bde103f753b325e919f86db299623
diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp
index 0c2f0e8..8bd9236 100644
--- a/src/security/certstore.cpp
+++ b/src/security/certstore.cpp
@@ -604,12 +604,14 @@
auto cert = certStore_.getCertificate(cert_id);
if (!cert)
return PermissionStatus::UNDEFINED;
- auto allowed = false; auto found = false;
+ auto allowed = false;
+ auto found = false;
while (cert) {
auto s = certStatus_.find(cert->getId().toString());
if (s != std::end(certStatus_)) {
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;
if (!allowed)
@@ -618,10 +620,11 @@
auto us = unknownCertStatus_.find(cert->getId().toString());
if (us != std::end(unknownCertStatus_)) {
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;
- if (!us->second.allowed)
+ allowed &= us->second.allowed;
+ if (!allowed)
return PermissionStatus::BANNED;
}
}