]> 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)
committerAmos Jeffries <yadij@users.noreply.github.com>
Tue, 16 Jul 2024 16:03:34 +0000 (04:03 +1200)
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 5aa311ae4b5ad37273ec3cc83389308356d214bd..b60854b09066c73d913caf85237127705b67c4a7 100644 (file)
@@ -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;
 }