mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 16:06:12 +03:00
Merge pull request #3117 from airween/v3/eualrangebyfind
fix: Changed 'equal_range()' + loop by 'find()' in resolveFirst() methods
This commit is contained in:
commit
4b38435a6e
@ -99,12 +99,11 @@ void AnchoredSetVariable::resolve(const std::string &key,
|
|||||||
|
|
||||||
std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
|
std::unique_ptr<std::string> AnchoredSetVariable::resolveFirst(
|
||||||
const std::string &key) {
|
const std::string &key) {
|
||||||
auto range = equal_range(key);
|
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
if (auto search = this->find(key); search != this->end()) {
|
||||||
std::unique_ptr<std::string> b(new std::string());
|
return std::make_unique<std::string>(search->second->getValue());
|
||||||
b->assign(it->second->getValue());
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +67,13 @@ bool InMemoryPerProcess::storeOrUpdateFirst(const std::string &key,
|
|||||||
bool InMemoryPerProcess::updateFirst(const std::string &key,
|
bool InMemoryPerProcess::updateFirst(const std::string &key,
|
||||||
const std::string &value) {
|
const std::string &value) {
|
||||||
pthread_mutex_lock(&m_lock);
|
pthread_mutex_lock(&m_lock);
|
||||||
auto range = this->equal_range(key);
|
|
||||||
|
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
if (auto search = this->find(key); search != this->end()) {
|
||||||
it->second.setValue(value);
|
search->second.setValue(value);
|
||||||
pthread_mutex_unlock(&m_lock);
|
pthread_mutex_unlock(&m_lock);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&m_lock);
|
pthread_mutex_unlock(&m_lock);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -97,11 +97,11 @@ void InMemoryPerProcess::delIfExpired(const std::string& key) {
|
|||||||
|
|
||||||
void InMemoryPerProcess::setExpiry(const std::string& key, int32_t expiry_seconds) {
|
void InMemoryPerProcess::setExpiry(const std::string& key, int32_t expiry_seconds) {
|
||||||
pthread_mutex_lock(&m_lock);
|
pthread_mutex_lock(&m_lock);
|
||||||
auto range = this->equal_range(key);
|
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
if (auto search = this->find(key); search != this->end()) {
|
||||||
it->second.setExpiry(expiry_seconds);
|
search->second.setExpiry(expiry_seconds);
|
||||||
pthread_mutex_unlock(&m_lock);
|
pthread_mutex_unlock(&m_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We allow an expiry value to be set for a key that has not (yet) had a value set.
|
// We allow an expiry value to be set for a key that has not (yet) had a value set.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user