]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Be more careful when updating nameservers global (#1862)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 11 Jul 2024 20:04:06 +0000 (20:04 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 11 Jul 2024 22:11:28 +0000 (22:11 +0000)
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.

src/dns_internal.cc

index e8c537b9ebaab97e9bd92c07842f1c6c4f2529ce..f2643015350d9fa1030ca72af1b09498a1166965 100644 (file)
@@ -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;
 }