]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Another set of coverity fixes
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 16:06:35 +0000 (17:06 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 16:06:35 +0000 (17:06 +0100)
pdns/ixfr.cc
pdns/recursordist/aggressive_nsec.cc
pdns/recursordist/lwres.cc
pdns/recursordist/negcache.cc
pdns/recursordist/pdns_recursor.cc
pdns/recursordist/rec-lua-conf.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-tcp.cc
pdns/recursordist/rec_channel.cc
pdns/recursordist/rec_channel_rec.cc
pdns/recursordist/rec_control.cc

index f2a6bcf7c4ef22003461753d7d7fc2492176ae7f..ac041cb0090566925727072a9d1ecba659ff43a9 100644 (file)
@@ -272,7 +272,7 @@ vector<pair<vector<DNSRecord>, vector<DNSRecord>>> getIXFRDeltas(const ComboAddr
           // we are up to date
           return ret;
         }
-        primarySOA = sr;
+        primarySOA = std::move(sr);
         ++primarySOACount;
       } else if (r.first.d_type == QType::SOA) {
         auto sr = getRR<SOARecordContent>(r.first);
index f31d2a7704ef1a1c3de7c21527f4064bb3a0d263..a91f644575195000fc4887b3338a376c290d60a4 100644 (file)
@@ -345,7 +345,7 @@ void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner,
         ++d_entriesCount;
       }
       else {
-        zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, realOwner, next, record.d_ttl});
+        zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, std::move(realOwner), next, record.d_ttl});
       }
     }
     else {
@@ -354,7 +354,7 @@ void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner,
         ++d_entriesCount;
       }
       else {
-        zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, owner, next, record.d_ttl});
+        zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, owner, std::move(next), record.d_ttl});
       }
     }
   }
@@ -503,7 +503,7 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName&
     return false;
   }
 
-  addToRRSet(now, wcSet, wcSignatures, name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
+  addToRRSet(now, wcSet, std::move(wcSignatures), name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
   /* no need for closest encloser proof, the wildcard is there */
   // coverity[store_truncates_time_t]
   addRecordToRRSet(nextCloser.d_owner, QType::NSEC3, nextCloser.d_ttd - now, nextCloser.d_record, nextCloser.d_signatures, doDNSSEC, ret);
@@ -527,7 +527,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName&
     return false;
   }
 
-  addToRRSet(now, wcSet, wcSignatures, name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
+  addToRRSet(now, wcSet, std::move(wcSignatures), name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
   // coverity[store_truncates_time_t]
   addRecordToRRSet(nsec.d_owner, QType::NSEC, nsec.d_ttd - now, nsec.d_record, nsec.d_signatures, doDNSSEC, ret);
 
@@ -883,7 +883,7 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType
 
   ret.reserve(ret.size() + soaSet.size() + soaSignatures.size() + /* NSEC */ 1 + entry.d_signatures.size() + (needWildcard ? (/* NSEC */ 1 + wcEntry.d_signatures.size()) : 0));
 
-  addToRRSet(now, soaSet, soaSignatures, zone, doDNSSEC, ret);
+  addToRRSet(now, soaSet, std::move(soaSignatures), zone, doDNSSEC, ret);
   addRecordToRRSet(entry.d_owner, QType::NSEC, entry.d_ttd - now, entry.d_record, entry.d_signatures, doDNSSEC, ret);
 
   if (needWildcard) {
index d02e51eb54e3f4ed4260b633fcd83cf11278e6ae..010eaf480087287c4a667b6d5a66455dc651a266 100644 (file)
@@ -59,32 +59,29 @@ thread_local TCPOutConnectionManager t_tcp_manager;
 std::shared_ptr<Logr::Logger> g_slogout;
 bool g_paddingOutgoing;
 
-void remoteLoggerQueueData(RemoteLoggerInterface& r, const std::string& data)
+void remoteLoggerQueueData(RemoteLoggerInterface& rli, const std::string& data)
 {
-  auto ret = r.queueData(data);
+  auto ret = rli.queueData(data);
 
   switch (ret) {
   case RemoteLoggerInterface::Result::Queued:
     break;
   case RemoteLoggerInterface::Result::PipeFull: {
-    const auto msg = RemoteLoggerInterface::toErrorString(ret);
-    const auto name = r.name();
-    SLOG(g_log << Logger::Debug << name << ": " << msg << std::endl,
-         g_slog->withName(name)->info(Logr::Debug, msg));
+    const auto& msg = RemoteLoggerInterface::toErrorString(ret);
+    SLOG(g_log << Logger::Debug << rli.name() << ": " << msg << std::endl,
+         g_slog->withName(rli.name())->info(Logr::Debug, msg));
     break;
   }
   case RemoteLoggerInterface::Result::TooLarge: {
-    const auto msg = RemoteLoggerInterface::toErrorString(ret);
-    const auto name = r.name();
-    SLOG(g_log << Logger::Notice << name << ": " << msg << endl,
-         g_slog->withName(name)->info(Logr::Debug, msg));
+    const auto& msg = RemoteLoggerInterface::toErrorString(ret);
+    SLOG(g_log << Logger::Notice << rli.name() << ": " << msg << endl,
+         g_slog->withName(rli.name())->info(Logr::Debug, msg));
     break;
   }
   case RemoteLoggerInterface::Result::OtherError: {
-    const auto msg = RemoteLoggerInterface::toErrorString(ret);
-    const auto name = r.name();
-    SLOG(g_log << Logger::Warning << name << ": " << msg << std::endl,
-         g_slog->withName(name)->info(Logr::Warning, msg));
+    const auto& msg = RemoteLoggerInterface::toErrorString(ret);
+    SLOG(g_log << Logger::Warning << rli.name() << ": " << msg << std::endl,
+         g_slog->withName(rli.name())->info(Logr::Warning, msg));
     break;
   }
   }
index 9b0b347180fe2770f6fec9a21f60e81740832795..5bea1a06b934290dbead810ee040370fc0bd7af7 100644 (file)
@@ -65,7 +65,7 @@ bool NegCache::getRootNXTrust(const DNSName& qname, const struct timeval& now, N
   // An 'ENT' QType entry, used as "whole name" in the neg-cache context.
   auto exists = get(lastLabel, QType::ENT, now, found, true, serveStale, refresh);
   if (exists && found.d_auth.isRoot()) {
-    negEntry = found;
+    negEntry = std::move(found);
     return true;
   }
   return false;
index 9435f555e53f771ecb47847775681868ebb9218d..6409d6a0bf5b1e274eb753df6ce4d5dd1aec6762 100644 (file)
@@ -2351,9 +2351,9 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
   if (t_protobufServers.servers || t_outgoingProtobufServers.servers) {
     comboWriter->d_uuid = uniqueId;
   }
-  comboWriter->d_requestorId = requestorId;
-  comboWriter->d_deviceId = deviceId;
-  comboWriter->d_deviceName = deviceName;
+  comboWriter->d_requestorId = std::move(requestorId);
+  comboWriter->d_deviceId = std::move(deviceId);
+  comboWriter->d_deviceName = std::move(deviceName);
   comboWriter->d_kernelTimestamp = tval;
   comboWriter->d_proxyProtocolValues = std::move(proxyProtocolValues);
   comboWriter->d_routingTag = std::move(routingTag);
index 83c48cd432c3a4826032a5f8f914892b26aa1d40..6b45c54a81c0b5e2640822023e0136c18644a4b8 100644 (file)
@@ -134,7 +134,7 @@ static void parseRPZParameters(rpzOptions_t& have, std::shared_ptr<DNSFilterEngi
     }
   }
   if (have.count("tags") != 0) {
-    const auto tagsTable = boost::get<std::vector<std::pair<int, std::string>>>(have["tags"]);
+    const auto& tagsTable = boost::get<std::vector<std::pair<int, std::string>>>(have["tags"]);
     std::unordered_set<std::string> tags;
     for (const auto& tag : tagsTable) {
       tags.insert(tag.second);
@@ -463,7 +463,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de
            log->info(Logr::Info, "Loading RPZ from file"));
       zone->setName(polName);
       loadRPZFromFile(filename, zone, defpol, defpolOverrideLocal, maxTTL);
-      lci.dfe.addZone(zone);
+      lci.dfe.addZone(std::move(zone));
       SLOG(g_log << Logger::Warning << "Done loading RPZ from file '" << filename << "'" << endl,
            log->info(Logr::Info,  "Done loading RPZ from file"));
     }
@@ -557,7 +557,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de
         }
       }
 
-      lci.ztcConfigs[validZoneName] = conf;
+      lci.ztcConfigs[validZoneName] = std::move(conf);
     }
     catch (const std::exception& e) {
       SLOG(g_log << Logger::Error << "Problem configuring zoneToCache for zone '" << zoneName << "': " << e.what() << endl,
index 9cc1cde07ab463162800dd5ed8a213c02def9da4..478839ea41d555e2638bd1b4b6d4e72030e1432e 100644 (file)
@@ -590,7 +590,7 @@ void protobufLogResponse(const struct dnsheader* header, LocalStateHolder<LuaCon
   else {
     pbMessage.setSocketFamily(mappedSource.sin4.sin_family);
     Netmask requestorNM(mappedSource, mappedSource.sin4.sin_family == AF_INET ? luaconfsLocal->protobufMaskV4 : luaconfsLocal->protobufMaskV6);
-    auto requestor = requestorNM.getMaskedNetwork();
+    const auto& requestor = requestorNM.getMaskedNetwork();
     pbMessage.setFrom(requestor);
     pbMessage.setFromPort(mappedSource.getPort());
   }
@@ -1348,12 +1348,12 @@ void parseACLs()
   }
 
   g_initialAllowFrom = allowFrom;
-  broadcastFunction([=] { return pleaseSupplantAllowFrom(allowFrom); });
+  broadcastFunction([=] { return pleaseSupplantAllowFrom(std::move(allowFrom)); });
 
   auto allowNotifyFrom = parseACL("allow-notify-from-file", "allow-notify-from", log);
 
   g_initialAllowNotifyFrom = allowNotifyFrom;
-  broadcastFunction([=] { return pleaseSupplantAllowNotifyFrom(allowNotifyFrom); });
+  broadcastFunction([=] { return pleaseSupplantAllowNotifyFrom(std::move(allowNotifyFrom)); });
 
   l_initialized = true;
 }
index 7d1a8bb3d1038d6b6c33060688eb8b674e8d1d99..0eac47653b534f8eeefd95278f7df86a0a6e6cc9 100644 (file)
@@ -362,9 +362,9 @@ static void doProcessTCPQuestion(std::unique_ptr<DNSComboWriter>& comboWriter, s
   const struct dnsheader* dnsheader = headerdata.get();
 
   if (t_protobufServers.servers || t_outgoingProtobufServers.servers) {
-    comboWriter->d_requestorId = requestorId;
-    comboWriter->d_deviceId = deviceId;
-    comboWriter->d_deviceName = deviceName;
+    comboWriter->d_requestorId = std::move(requestorId);
+    comboWriter->d_deviceId = std::move(deviceId);
+    comboWriter->d_deviceName = std::move(deviceName);
     comboWriter->d_uuid = getUniqueID();
   }
 
index 3d78cd96c14a21c556fda68cb207eec1e61afa79..6abab97a35fceb94b636ad5256d7b28af751bd16 100644 (file)
@@ -217,5 +217,5 @@ RecursorControlChannel::Answer RecursorControlChannel::recv(int fd, unsigned int
     str.append(buffer, recvd);
   }
 
-  return {err, str};
+  return {err, std::move(str)};
 }
index 186befa61c067fbf153fb9f7485eec65238d945a..b096e2d9ce8b8bc7d54f206550554e5b70d15e36 100644 (file)
@@ -152,7 +152,7 @@ std::atomic<unsigned long>* getDynMetric(const std::string& str, const std::stri
     name = getPrometheusName(name);
   }
 
-  auto ret = dynmetrics{new std::atomic<unsigned long>(), name};
+  auto ret = dynmetrics{new std::atomic<unsigned long>(), std::move(name)};
   (*dm)[str] = ret;
   return ret.d_ptr;
 }
@@ -1208,7 +1208,7 @@ static StatsMap toRPZStatsMap(const string& name, const std::unordered_map<std::
       sname = name + "-rpz-" + key;
       pname = pbasename + "{type=\"rpz\",policyname=\"" + key + "\"}";
     }
-    entries.emplace(sname, StatsMapEntry{pname, std::to_string(count)});
+    entries.emplace(sname, StatsMapEntry{std::move(pname), std::to_string(count)});
     total += count;
   }
   entries.emplace(name, StatsMapEntry{pbasename, std::to_string(total)});
index 6264ae51220a7689fbab2ac05cb60dc47ea44429..37703591a2870528a461fe37b8fd809a62f63b91 100644 (file)
@@ -223,7 +223,7 @@ static RecursorControlChannel::Answer showYAML(const std::string& path)
     msg += showAllowYAML(mainsettings.incoming.allow_from_file, "incoming", "allow_from_file", pdns::rust::settings::rec::validate_allow_from);
     msg += showAllowYAML(mainsettings.incoming.allow_notify_from_file, "incoming", "allow_notify_from_file", pdns::rust::settings::rec::validate_allow_from);
     msg += showAllowYAML(mainsettings.incoming.allow_notify_for_file, "incoming", "allow_notify_for_file", pdns::rust::settings::rec::validate_allow_for);
-    return {0, msg};
+    return {0, std::move(msg)};
   }
   catch (const rust::Error& err) {
     return {1, std::string(err.what())};
@@ -344,7 +344,7 @@ int main(int argc, char** argv)
     auto timeout = arg().asNum("timeout");
     RecursorControlChannel rccS;
     rccS.connect(arg()["socket-dir"], sockname);
-    rccS.send(rccS.d_fd, {0, command}, timeout, fd);
+    rccS.send(rccS.d_fd, {0, std::move(command)}, timeout, fd);
 
     auto receive = rccS.recv(rccS.d_fd, timeout);
     if (receive.d_ret != 0) {