]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: prevent a data race: don't modify a global table on reload zones
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 27 Nov 2024 08:35:51 +0000 (09:35 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 27 Nov 2024 08:35:51 +0000 (09:35 +0100)
Including assert to prevent future accidents and detect more instances of current abuse.

pdns/dnsparser.cc
pdns/dnsparser.hh
pdns/recursordist/rec-main.cc
pdns/recursordist/reczones.cc

index 1eecaea630e80c8461f1e15b18c3ff04de2819d3..be08f2b68a100c8048d3cc777a0aca3c0f838bbf 100644 (file)
@@ -27,6 +27,8 @@
 #include "namespaces.hh"
 #include "noinitvector.hh"
 
+bool DNSRecordContent::d_locked{false};
+
 UnknownRecordContent::UnknownRecordContent(const string& zone)
 {
   // parse the input
index 07660b90ea335540d475dda2bd31ed3ba2b2274a..556d6eb14f58f2c44bd64e035c7fa4a0415a51e8 100644 (file)
@@ -234,6 +234,7 @@ public:
 
   static void regist(uint16_t cl, uint16_t ty, makerfunc_t* f, zmakerfunc_t* z, const char* name)
   {
+    assert(!d_locked);
     if(f)
       getTypemap()[pair(cl,ty)]=f;
     if(z)
@@ -245,6 +246,7 @@ public:
 
   static void unregist(uint16_t cl, uint16_t ty)
   {
+    assert(!d_locked);
     auto key = pair(cl, ty);
     getTypemap().erase(key);
     getZmakermap().erase(key);
@@ -284,6 +286,11 @@ public:
 
   virtual uint16_t getType() const = 0;
 
+  static void lock()
+  {
+    d_locked = true;
+  }
+
 protected:
   typedef std::map<std::pair<uint16_t, uint16_t>, makerfunc_t* > typemap_t;
   typedef std::map<std::pair<uint16_t, uint16_t>, zmakerfunc_t* > zmakermap_t;
@@ -293,6 +300,7 @@ protected:
   static t2namemap_t& getT2Namemap();
   static n2typemap_t& getN2Typemap();
   static zmakermap_t& getZmakermap();
+  static bool d_locked;
 };
 
 struct DNSRecord
index 8c750d25a8948ff6156d0ae5042de5df360cc0b7..3e09545703497c02e9ff29dbb9198632cb888027 100644 (file)
@@ -3153,8 +3153,8 @@ int main(int argc, char** argv)
   g_argc = argc;
   g_argv = argv;
   versionSetProduct(ProductRecursor);
-  reportBasicTypes();
-  reportOtherTypes();
+  reportAllTypes();
+  DNSRecordContent::lock();
 
   int ret = EXIT_SUCCESS;
 
index ae48402db4445d70912842bba1fd1dc370287a21..f015b9dde2026f826573e452db2f656503c26051 100644 (file)
@@ -570,9 +570,6 @@ std::tuple<std::shared_ptr<SyncRes::domainmap_t>, std::shared_ptr<notifyset_t>>
 {
   auto log = g_slog->withName("config");
 
-  TXTRecordContent::report();
-  OPTRecordContent::report();
-
   auto newMap = std::make_shared<SyncRes::domainmap_t>();
   auto newSet = std::make_shared<notifyset_t>();