mirror of
https://github.com/anope/anope.git
synced 2026-07-06 11:13:13 +02:00
Fixed possible unsafe iteration when purging dns cache, and fixed the dns cache to not expire all of the records for specific hosts if the records have different TTLs
(cherry picked from commit 736df4bd98b952aad459fdf7914735e88f97c4b2)
This commit is contained in:
+4
-3
@@ -557,15 +557,16 @@ void DNSManager::Tick(time_t now)
|
||||
{
|
||||
Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache";
|
||||
|
||||
for (std::multimap<Anope::string, DNSRecord *>::iterator it = this->cache.begin(), it_end = this->cache.end(); it != it_end;)
|
||||
for (std::multimap<Anope::string, DNSRecord *>::iterator it = this->cache.begin(), it_next; it != this->cache.end(); it = it_next)
|
||||
{
|
||||
Anope::string host = it->first;
|
||||
DNSRecord *req = it->second;
|
||||
++it;
|
||||
it_next = it;
|
||||
++it_next;
|
||||
|
||||
if (req->created + req->ttl < now)
|
||||
{
|
||||
this->cache.erase(host);
|
||||
this->cache.erase(it);
|
||||
delete req;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user