]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix 'auto causes a copy'/'copy instead of move' warnings from Coverity
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 21 Nov 2023 10:10:35 +0000 (11:10 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 21 Nov 2023 10:10:35 +0000 (11:10 +0100)
modules/bindbackend/bindbackend2.cc
modules/geoipbackend/geoipbackend.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/gss_context.cc
pdns/ixfrdist.cc
pdns/pdnsutil.cc
pdns/tcpreceiver.cc
pdns/ueberbackend.cc
pdns/ws-auth.cc

index 481658453c72701fa1374a89396e0ec76b38e94d..013c9eb8ac7e7fb953c956ad4ab0a51d6965ff21 100644 (file)
@@ -520,7 +520,7 @@ void Bind2Backend::parseZoneFile(BB2DomainInfo* bbd)
   bbd->d_status = "parsed into memory at " + nowTime();
   bbd->d_records = LookButDontTouch<recordstorage_t>(std::move(records));
   bbd->d_nsec3zone = nsec3zone;
-  bbd->d_nsec3param = ns3pr;
+  bbd->d_nsec3param = std::move(ns3pr);
 }
 
 /** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching
@@ -1475,7 +1475,7 @@ bool Bind2Backend::searchRecords(const string& pattern, size_t maxResults, vecto
         DNSName name = ri->qname.empty() ? i.d_name : (ri->qname + i.d_name);
         if (sm.match(name) || sm.match(ri->content)) {
           DNSResourceRecord r;
-          r.qname = name;
+          r.qname = std::move(name);
           r.domain_id = i.d_id;
           r.content = ri->content;
           r.qtype = ri->qtype;
index 1f8e997663b4ca231aa3b1871449864473120d2d..014aa24f0055782575d8ea03508deef91a0a867c 100644 (file)
@@ -197,7 +197,7 @@ void GeoIPBackend::setupNetmasks(const YAML::Node& domain, GeoIPDomain& dom)
         throw PDNSException(string("%mp is not allowed in mapping lookup formats of domain ") + dom.domain.toLogString());
       }
 
-      dom.mapping_lookup_formats = mapping_lookup_formats;
+      dom.mapping_lookup_formats = std::move(mapping_lookup_formats);
     }
     else {
       dom.mapping_lookup_formats = d_global_mapping_lookup_formats;
@@ -654,9 +654,10 @@ static string queryGeoIP(const Netmask& addr, GeoIPInterface::GeoIPQueryAttribut
       break;
     }
 
-    if (!found || val.empty() || val == "--")
+    if (!found || val.empty() || val == "--") {
       continue; // try next database
-    ret = val;
+    }
+    ret = std::move(val);
     std::transform(ret.begin(), ret.end(), ret.begin(), ::tolower);
     break;
   }
index d3351d16dd4e93977ff967b06719714c0e0fd16c..fcc5cc85d4351442cd588279fc7b7fe47dc3b36e 100644 (file)
@@ -1678,12 +1678,13 @@ bool GSQLBackend::createSecondaryDomain(const string& ip, const DNSName& domain,
       if (!d_result.empty()) {
         // collect all IP addresses
         vector<ComboAddress> tmp;
-        for(const auto& row: d_result) {
-          if (account == row[1])
+        for (const auto& row: d_result) {
+          if (account == row[1]) {
             tmp.emplace_back(row[0], 53);
+          }
         }
         // set them as domain's primaries, comma separated
-        primaries = tmp;
+        primaries = std::move(tmp);
       }
     }
     createDomain(domain, DomainInfo::Secondary, primaries, account);
index a59296df6ce6d5807f5d4cdf9f347943deebd38e..1297356a0ae4e02ecf56c002c3c278bd86e96e68 100644 (file)
@@ -143,7 +143,7 @@ public:
     if (!cred->valid()) {
       throw PDNSException("Invalid credential " + cred->d_nameS);
     }
-    d_cred = cred;
+    d_cred = std::move(cred);
   }
 
   ~GssSecContext()
index da522ddb8af6d946c784918b3192ea3993ed7d40..147c004d1487cc928fce181081619d28352be1f4 100644 (file)
@@ -471,7 +471,7 @@ static void updateThread(const string& workdir, const uint16_t& keep, const uint
 
         g_log<<Logger::Debug<<"Zone "<<domain<<" previously contained "<<(oldZoneInfo ? oldZoneInfo->latestAXFR.size() : 0)<<" entries, "<<records.size()<<" now"<<endl;
         ixfrInfo->latestAXFR = std::move(records);
-        ixfrInfo->soa = soa;
+        ixfrInfo->soa = std::move(soa);
         ixfrInfo->soaTTL = soaTTL;
         updateCurrentZoneInfo(domain, ixfrInfo);
       } catch (PDNSException &e) {
index a3d6d148a4f0a5fbcaec27eed215fc0b564f8693..94167c39ce0d14488dda371df88561672ebb054d 100644 (file)
@@ -677,7 +677,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con
       }
     }
 
-    auto trueTarget = target.isRoot() ? name : target;
+    const auto& trueTarget = target.isRoot() ? name : target;
     if (prio > 0) {
       if(v4hintsAuto && arecords.find(trueTarget) == arecords.end()) {
         cout << "[warning] SVCB record for "<< name << " has automatic IPv4 hints, but no A-record for the target at "<< trueTarget <<" exists."<<endl;
index 556df61e902606694ab87910449aabcd3978f8e9..e76be9000100ffb2458cd6fc1d7d95bef0119fab 100644 (file)
@@ -197,10 +197,10 @@ static bool maxConnectionDurationReached(unsigned int maxConnectionDuration, tim
 {
   if (maxConnectionDuration) {
     time_t elapsed = time(nullptr) - start;
-    if (elapsed >= maxConnectionDuration) {
+    if (elapsed > 0 && elapsed >= maxConnectionDuration) {
       return true;
     }
-    remainingTime = maxConnectionDuration - elapsed;
+    remainingTime = static_cast<unsigned int >(maxConnectionDuration - elapsed);
   }
   return false;
 }
index ebf0129a57796c2f106ae09e3ce0464f5e8d0b70..1d9950fb79ccab5b281891d681df7fe98e9006e8 100644 (file)
@@ -531,7 +531,7 @@ bool UeberBackend::getAuth(const DNSName& target, const QType& qtype, SOAData* s
         resourceRecord.dr.d_ttl = soaData->ttl;
         resourceRecord.domain_id = soaData->domain_id;
 
-        addCache(d_question, {resourceRecord});
+        addCache(d_question, {std::move(resourceRecord)});
       }
     }
 
index e8460e26f7cbf4ee96f49bbca6a4119c2972b77b..d3c0e243ec9e5ebff848dc0554a66210da92c0c8 100644 (file)
@@ -1597,7 +1597,7 @@ static void apiServerTSIGKeyDetail(HttpRequest* req, HttpResponse* resp) {
   struct TSIGKey tsk;
   tsk.name = keyname;
   tsk.algorithm = algo;
-  tsk.key = content;
+  tsk.key = std::move(content);
 
   if (req->method == "GET") {
     resp->setJsonBody(makeJSONTSIGKey(tsk));
@@ -1623,7 +1623,7 @@ static void apiServerTSIGKeyDetail(HttpRequest* req, HttpResponse* resp) {
       if (B64Decode(new_content, decoded) == -1) {
         throw ApiException("Can not base64 decode key content '" + new_content + "'");
       }
-      tsk.key = new_content;
+      tsk.key = std::move(new_content);
     }
     if (!B.setTSIGKey(tsk.name, tsk.algorithm, tsk.key)) {
       throw HttpInternalServerErrorException("Unable to save TSIG Key");