]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Mostly "Large object passed by value" fixes a spoted by CodeQL.
authorOtto <otto.moerbeek@open-xchange.com>
Tue, 21 Sep 2021 06:59:11 +0000 (08:59 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 21 Sep 2021 09:54:50 +0000 (11:54 +0200)
Plus a sign issue in a test as detected by OpenBSD/clang.
I simplified the hostog.hh template since it is used in only one place (dnsscope)
and the argument is not used there.

pdns/dnsdist-lua.cc
pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc
pdns/histog.hh
pdns/rpzloader.cc
pdns/rpzloader.hh

index 9130bb34a35d3d5bfd1a3941ecfe0a80aeef41cc..c5daacf693c99a94681f14832fab8e76c8d0e73b 100644 (file)
@@ -1992,7 +1992,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       }
     });
 
-  luaCtx.writeFunction("setServerPolicy", [](ServerPolicy policy) {
+  luaCtx.writeFunction("setServerPolicy", [](const ServerPolicy& policy) {
       setLuaSideEffect();
       g_policy.setState(policy);
     });
index 61964a9b178344891c04966f6942b5fb07d05c3e..8777c240bb5f6f6a3d8274af55771cf3dfe9c933 100644 (file)
@@ -262,7 +262,7 @@ private:
       }
       else if (qname == DNSName("wrong-stream-id.powerdns.com.") && (id % 2) == 0) {
         /* we return a wrong stremad ID on the first query only */
-        BOOST_CHECK_EQUAL(frame->hd.stream_id, 1U);
+        BOOST_CHECK_EQUAL(frame->hd.stream_id, 1);
         conn->d_responses[frame->hd.stream_id] = expected.d_response;
         /* use an invalid stream ID! */
         conn->d_idMapping[frame->hd.stream_id] = frame->hd.stream_id + 4;
index f96e4beab0fd280084ff56517b47862d427ebfd4..fb695283264f5f8ed031a67a8a20c046f1b157b5 100644 (file)
@@ -20,9 +20,9 @@ struct LogHistogramBin
 };
 
 template<typename T>
-std::vector<LogHistogramBin> createLogHistogram(const T& bins,
-                        std::deque<double> percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999})
+std::vector<LogHistogramBin> createLogHistogram(const T& bins)
 {
+  std::deque<double> percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999};
   uint64_t totcumul=0, sum=0;
 
   for(const auto& c: bins) {
@@ -60,10 +60,9 @@ std::vector<LogHistogramBin> createLogHistogram(const T& bins,
 }
 
 template<typename T>
-void writeLogHistogramFile(const T& bins, std::ostream& out, std::deque<double> percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999} )
+void writeLogHistogramFile(const T& bins, std::ostream& out)
 {
-
-  auto vec = createLogHistogram(bins, percentiles);
+  auto vec = createLogHistogram(bins);
   out<< R"(# set logscale xy
 # set mxtics 10
 # set mytics 10
index 67896eac1564c293c0a5b988008df8cd437185fa..e3874b21a3e8fe37a4c0c0259d2ce1d7911fdde0 100644 (file)
@@ -64,7 +64,7 @@ Netmask makeNetmaskFromRPZ(const DNSName& name)
   return Netmask(v6);
 }
 
-static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngine::Zone> zone, bool addOrRemove, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL)
+static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngine::Zone> zone, bool addOrRemove, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL)
 {
   static const DNSName drop("rpz-drop."), truncate("rpz-tcp-only."), noaction("rpz-passthru.");
   static const DNSName rpzClientIP("rpz-client-ip"), rpzIP("rpz-ip"),
@@ -188,7 +188,7 @@ static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngi
   }
 }
 
-static shared_ptr<SOARecordContent> loadRPZFromServer(const shared_ptr<Logr::Logger>& plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr<DNSFilterEngine::Zone> zone, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout)
+static shared_ptr<SOARecordContent> loadRPZFromServer(const shared_ptr<Logr::Logger>& plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr<DNSFilterEngine::Zone> zone, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout)
 {
 
   auto logger = plogger->withValues("primary", Logging::Loggable(primary));
@@ -239,7 +239,7 @@ static shared_ptr<SOARecordContent> loadRPZFromServer(const shared_ptr<Logr::Log
 }
 
 // this function is silent - you do the logging
-std::shared_ptr<SOARecordContent> loadRPZFromFile(const std::string& fname, std::shared_ptr<DNSFilterEngine::Zone> zone, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL)
+std::shared_ptr<SOARecordContent> loadRPZFromFile(const std::string& fname, std::shared_ptr<DNSFilterEngine::Zone> zone, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL)
 {
   shared_ptr<SOARecordContent> sr = nullptr;
   ZoneParserTNG zpt(fname);
@@ -361,7 +361,7 @@ static bool dumpZoneToDisk(const shared_ptr<Logr::Logger>& plogger, const DNSNam
   return true;
 }
 
-void RPZIXFRTracker(const std::vector<ComboAddress>& primaries, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, const uint32_t refreshFromConf, std::shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration)
+void RPZIXFRTracker(const std::vector<ComboAddress>& primaries, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, const uint32_t refreshFromConf, std::shared_ptr<SOARecordContent> sr, const std::string& dumpZoneFileName, uint64_t configGeneration)
 {
   setThreadName("pdns-r/RPZIXFR");
   bool isPreloaded = sr != nullptr;
index 85e10d30a4357aaa3907eb0224a04250648bd3f9..304ab5ab081fc27e1be02fe1e000a4e692ba496e 100644 (file)
@@ -26,8 +26,8 @@
 
 extern bool g_logRPZChanges;
 
-std::shared_ptr<SOARecordContent> loadRPZFromFile(const std::string& fname, std::shared_ptr<DNSFilterEngine::Zone> zone, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL);
-void RPZIXFRTracker(const std::vector<ComboAddress>& primaries, boost::optional<DNSFilterEngine::Policy> defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, const uint32_t reloadFromConf, shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration);
+std::shared_ptr<SOARecordContent> loadRPZFromFile(const std::string& fname, std::shared_ptr<DNSFilterEngine::Zone> zone, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL);
+void RPZIXFRTracker(const std::vector<ComboAddress>& primaries, const boost::optional<DNSFilterEngine::Policy>& defpol, bool defpolOverrideLocal, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, const uint32_t reloadFromConf, shared_ptr<SOARecordContent> sr, const std::string& dumpZoneFileName, uint64_t configGeneration);
 
 struct rpzStats
 {