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_6_11~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8e9ce2eef1c5c7739ce578ebb21985bab049327;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 5aa311ae4b..b60854b090 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -885,7 +885,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; }