From: Alex Rousskov Date: Thu, 11 Jul 2024 20:04:06 +0000 (+0000) Subject: Be more careful when updating nameservers global (#1862) X-Git-Tag: SQUID_7_0_1~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb8541b0fa05e7301285712288c3027655b85c8b;p=thirdparty%2Fsquid.git Be more careful when updating nameservers global (#1862) Due to I/O delays and timeouts, DNS nsvc objects may be deleted after the `nameservers` global pointing to them was cleared and then populated with new ns objects. Thus, nsvc destructor should check that nsvc and `nameservers` states are still in sync before manipulating the latter. DNS code should use similar validation in a few other places, but they are all about read-only debugging that requires a rather noisy cleanup. --- diff --git a/src/dns_internal.cc b/src/dns_internal.cc index e8c537b9eb..f264301535 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -886,7 +886,9 @@ nsvc::~nsvc() { delete queue; delete msg; - if (ns < nameservers.size()) // XXX: idnsShutdownAndFreeState may have freed nameservers[] + // we may outlive nameservers version that was pointing to us because + // reconfigurations repopulate nameservers + if (ns < nameservers.size() && nameservers[ns].vc == this) nameservers[ns].vc = nullptr; }