From: Otto Date: Tue, 21 Sep 2021 06:59:11 +0000 (+0200) Subject: Mostly "Large object passed by value" fixes a spoted by CodeQL. X-Git-Tag: dnsdist-1.7.0-alpha1~1^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4caba2889df9b1260c7e00c700f23c37a85c97f2;p=thirdparty%2Fpdns.git Mostly "Large object passed by value" fixes a spoted by CodeQL. 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. --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 9130bb34a3..c5daacf693 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -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); }); diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc index 61964a9b17..8777c240bb 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc @@ -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; diff --git a/pdns/histog.hh b/pdns/histog.hh index f96e4beab0..fb69528326 100644 --- a/pdns/histog.hh +++ b/pdns/histog.hh @@ -20,9 +20,9 @@ struct LogHistogramBin }; template -std::vector createLogHistogram(const T& bins, - std::deque 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 createLogHistogram(const T& bins) { + std::deque 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 createLogHistogram(const T& bins, } template -void writeLogHistogramFile(const T& bins, std::ostream& out, std::deque 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 diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index 67896eac15..e3874b21a3 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -64,7 +64,7 @@ Netmask makeNetmaskFromRPZ(const DNSName& name) return Netmask(v6); } -static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr zone, bool addOrRemove, boost::optional defpol, bool defpolOverrideLocal, uint32_t maxTTL) +static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr zone, bool addOrRemove, const boost::optional& 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 loadRPZFromServer(const shared_ptr& plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, boost::optional defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout) +static shared_ptr loadRPZFromServer(const shared_ptr& plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, const boost::optional& 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 loadRPZFromServer(const shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, boost::optional defpol, bool defpolOverrideLocal, uint32_t maxTTL) +std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL) { shared_ptr sr = nullptr; ZoneParserTNG zpt(fname); @@ -361,7 +361,7 @@ static bool dumpZoneToDisk(const shared_ptr& plogger, const DNSNam return true; } -void RPZIXFRTracker(const std::vector& primaries, boost::optional 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 sr, std::string dumpZoneFileName, uint64_t configGeneration) +void RPZIXFRTracker(const std::vector& primaries, const boost::optional& 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 sr, const std::string& dumpZoneFileName, uint64_t configGeneration) { setThreadName("pdns-r/RPZIXFR"); bool isPreloaded = sr != nullptr; diff --git a/pdns/rpzloader.hh b/pdns/rpzloader.hh index 85e10d30a4..304ab5ab08 100644 --- a/pdns/rpzloader.hh +++ b/pdns/rpzloader.hh @@ -26,8 +26,8 @@ extern bool g_logRPZChanges; -std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, boost::optional defpol, bool defpolOverrideLocal, uint32_t maxTTL); -void RPZIXFRTracker(const std::vector& primaries, boost::optional 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 sr, std::string dumpZoneFileName, uint64_t configGeneration); +std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL); +void RPZIXFRTracker(const std::vector& primaries, const boost::optional& 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 sr, const std::string& dumpZoneFileName, uint64_t configGeneration); struct rpzStats {