From: Remi Gacogne Date: Mon, 23 Oct 2017 10:16:52 +0000 (+0200) Subject: rec: Don't shadow variables X-Git-Tag: rec-4.1.0-rc2~1^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2010ac9550af0950ac46f75c6807b2f1c3cce377;p=pdns rec: Don't shadow variables --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index ccfec1805..61f4f5e4c 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -1309,9 +1309,9 @@ bool Bind2Backend::searchRecords(const string &pattern, int maxResults, vectord_id, &h); - shared_ptr handle = h.d_records.get(); + shared_ptr rhandle = h.d_records.get(); - for(recordstorage_t::const_iterator ri = handle->begin(); result.size() < static_cast::size_type>(maxResults) && ri != handle->end(); ri++) { + for(recordstorage_t::const_iterator ri = rhandle->begin(); result.size() < static_cast::size_type>(maxResults) && ri != rhandle->end(); ri++) { DNSName name = ri->qname.empty() ? i->d_name : (ri->qname+i->d_name); if (sm.match(name) || sm.match(ri->content)) { DNSResourceRecord r; diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 929f5345b..b02b475d3 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -91,20 +91,20 @@ void GeoIPBackend::initialize() { YAML::Node config; vector tmp_domains; - string mode = getArg("database-cache"); + string modeStr = getArg("database-cache"); int flags; - if (mode == "standard") + if (modeStr == "standard") flags = GEOIP_STANDARD; - else if (mode == "memory") + else if (modeStr == "memory") flags = GEOIP_MEMORY_CACHE; - else if (mode == "index") + else if (modeStr == "index") flags = GEOIP_INDEX_CACHE; #ifdef HAVE_MMAP - else if (mode == "mmap") + else if (modeStr == "mmap") flags = GEOIP_MMAP_CACHE; #endif else - throw PDNSException("Invalid cache mode " + mode + " for GeoIP backend"); + throw PDNSException("Invalid cache mode " + modeStr + " for GeoIP backend"); s_geoip_files.clear(); // reset pointers @@ -376,15 +376,15 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket const NetmaskTree >::node_type* node = target->second.lookup(ComboAddress(ip)); if (node == NULL) return; // no hit, again. - DNSName format; + DNSName sformat; gl.netmask = node->first.getBits(); // note that this means the array format won't work with indirect for(auto it = node->second.begin(); it != node->second.end(); it++) { - format = DNSName(format2str(*it, ip, v6, &gl)); + sformat = DNSName(format2str(*it, ip, v6, &gl)); // see if the record can be found - if (this->lookup_static(dom, format, qtype, qdomain, ip, gl, v6)) + if (this->lookup_static(dom, sformat, qtype, qdomain, ip, gl, v6)) return; } @@ -404,7 +404,7 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket rr.domain_id = dom.id; rr.qtype = QType::CNAME; rr.qname = qdomain; - rr.content = format.toString(); + rr.content = sformat.toString(); rr.auth = 1; rr.ttl = dom.ttl; rr.scopeMask = gl.netmask; @@ -735,7 +735,7 @@ string GeoIPBackend::queryGeoIP(const string &ip, bool v6, GeoIPQueryAttribute a return ret; } -string GeoIPBackend::format2str(string format, const string& ip, bool v6, GeoIPLookup* gl) { +string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIPLookup* gl) { string::size_type cur,last; time_t t = time((time_t*)NULL); GeoIPLookup tmp_gl; // largest wins @@ -743,62 +743,62 @@ string GeoIPBackend::format2str(string format, const string& ip, bool v6, GeoIPL gmtime_r(&t, >m); last=0; - while((cur = format.find("%", last)) != string::npos) { + while((cur = sformat.find("%", last)) != string::npos) { string rep; int nrep=3; tmp_gl.netmask = 0; - if (!format.compare(cur,3,"%cn")) { + if (!sformat.compare(cur,3,"%cn")) { rep = queryGeoIP(ip, v6, Continent, &tmp_gl); - } else if (!format.compare(cur,3,"%co")) { + } else if (!sformat.compare(cur,3,"%co")) { rep = queryGeoIP(ip, v6, Country, &tmp_gl); - } else if (!format.compare(cur,3,"%cc")) { + } else if (!sformat.compare(cur,3,"%cc")) { rep = queryGeoIP(ip, v6, Country2, &tmp_gl); - } else if (!format.compare(cur,3,"%af")) { + } else if (!sformat.compare(cur,3,"%af")) { rep = (v6?"v6":"v4"); - } else if (!format.compare(cur,3,"%as")) { + } else if (!sformat.compare(cur,3,"%as")) { rep = queryGeoIP(ip, v6, ASn, &tmp_gl); - } else if (!format.compare(cur,3,"%re")) { + } else if (!sformat.compare(cur,3,"%re")) { rep = queryGeoIP(ip, v6, Region, &tmp_gl); - } else if (!format.compare(cur,3,"%na")) { + } else if (!sformat.compare(cur,3,"%na")) { rep = queryGeoIP(ip, v6, Name, &tmp_gl); - } else if (!format.compare(cur,3,"%ci")) { + } else if (!sformat.compare(cur,3,"%ci")) { rep = queryGeoIP(ip, v6, City, &tmp_gl); - } else if (!format.compare(cur,3,"%hh")) { + } else if (!sformat.compare(cur,3,"%hh")) { rep = boost::str(boost::format("%02d") % gtm.tm_hour); tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,3,"%yy")) { + } else if (!sformat.compare(cur,3,"%yy")) { rep = boost::str(boost::format("%02d") % (gtm.tm_year + 1900)); tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,3,"%dd")) { + } else if (!sformat.compare(cur,3,"%dd")) { rep = boost::str(boost::format("%02d") % (gtm.tm_yday + 1)); tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,4,"%wds")) { + } else if (!sformat.compare(cur,4,"%wds")) { nrep=4; rep = GeoIP_WEEKDAYS[gtm.tm_wday]; tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,4,"%mos")) { + } else if (!sformat.compare(cur,4,"%mos")) { nrep=4; rep = GeoIP_MONTHS[gtm.tm_mon]; tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,3,"%wd")) { + } else if (!sformat.compare(cur,3,"%wd")) { rep = boost::str(boost::format("%02d") % (gtm.tm_wday + 1)); tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,3,"%mo")) { + } else if (!sformat.compare(cur,3,"%mo")) { rep = boost::str(boost::format("%02d") % (gtm.tm_mon + 1)); tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,3,"%ip")) { + } else if (!sformat.compare(cur,3,"%ip")) { rep = ip; tmp_gl.netmask = (v6?128:32); - } else if (!format.compare(cur,2,"%%")) { + } else if (!sformat.compare(cur,2,"%%")) { last = cur + 2; continue; } else { last = cur + 1; continue; } if (tmp_gl.netmask > gl->netmask) gl->netmask = tmp_gl.netmask; - format.replace(cur, nrep, rep); + sformat.replace(cur, nrep, rep); last = cur + rep.size(); // move to next attribute } - return format; + return sformat; } void GeoIPBackend::reload() { diff --git a/modules/gpgsqlbackend/spgsql.cc b/modules/gpgsqlbackend/spgsql.cc index f02d87e9d..10fb8c7df 100644 --- a/modules/gpgsqlbackend/spgsql.cc +++ b/modules/gpgsqlbackend/spgsql.cc @@ -82,7 +82,6 @@ public: } d_res_set = PQexecPrepared(d_db(), d_stmt.c_str(), d_nparams, paramValues, paramLengths, NULL, 0); ExecStatusType status = PQresultStatus(d_res_set); - string errmsg(PQresultErrorMessage(d_res_set)); if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK && status != PGRES_NONFATAL_ERROR) { string errmsg(PQresultErrorMessage(d_res_set)); releaseStatement(); diff --git a/modules/pipebackend/coprocess.cc b/modules/pipebackend/coprocess.cc index 1f8677fe0..ecc7e1089 100644 --- a/modules/pipebackend/coprocess.cc +++ b/modules/pipebackend/coprocess.cc @@ -125,8 +125,8 @@ void CoProcess::checkStatus() throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno))); else if(ret) { if(WIFEXITED(status)) { - int ret=WEXITSTATUS(status); - throw PDNSException("Coprocess exited with code "+itoa(ret)); + int exitStatus=WEXITSTATUS(status); + throw PDNSException("Coprocess exited with code "+itoa(exitStatus)); } if(WIFSIGNALED(status)) { int sig=WTERMSIG(status); diff --git a/modules/remotebackend/pipeconnector.cc b/modules/remotebackend/pipeconnector.cc index 6cd5ae7f4..54cdb0319 100644 --- a/modules/remotebackend/pipeconnector.cc +++ b/modules/remotebackend/pipeconnector.cc @@ -24,17 +24,17 @@ #endif #include "remotebackend.hh" -PipeConnector::PipeConnector(std::map options) { - if (options.count("command") == 0) { +PipeConnector::PipeConnector(std::map optionsMap) { + if (optionsMap.count("command") == 0) { L<command = options.find("command")->second; - this->options = options; + this->command = optionsMap.find("command")->second; + this->options = optionsMap; d_timeout=2000; - if (options.find("timeout") != options.end()) { - d_timeout = std::stoi(options.find("timeout")->second); + if (optionsMap.find("timeout") != optionsMap.end()) { + d_timeout = std::stoi(optionsMap.find("timeout")->second); } d_pid = -1; @@ -190,8 +190,8 @@ bool PipeConnector::checkStatus() throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno))); else if(ret) { if(WIFEXITED(status)) { - int ret=WEXITSTATUS(status); - throw PDNSException("Coprocess exited with code "+itoa(ret)); + int exitStatus=WEXITSTATUS(status); + throw PDNSException("Coprocess exited with code "+itoa(exitStatus)); } if(WIFSIGNALED(status)) { int sig=WTERMSIG(status); diff --git a/modules/remotebackend/unixconnector.cc b/modules/remotebackend/unixconnector.cc index 92e82a975..8b0188cf1 100644 --- a/modules/remotebackend/unixconnector.cc +++ b/modules/remotebackend/unixconnector.cc @@ -30,17 +30,17 @@ #define UNIX_PATH_MAX 108 #endif -UnixsocketConnector::UnixsocketConnector(std::map options) { - if (options.count("path") == 0) { +UnixsocketConnector::UnixsocketConnector(std::map optionsMap) { + if (optionsMap.count("path") == 0) { L<timeout = 2000; - if (options.find("timeout") != options.end()) { - this->timeout = std::stoi(options.find("timeout")->second); + if (optionsMap.find("timeout") != optionsMap.end()) { + this->timeout = std::stoi(optionsMap.find("timeout")->second); } - this->path = options.find("path")->second; - this->options = options; + this->path = optionsMap.find("path")->second; + this->options = optionsMap; this->connected = false; this->fd = -1; } diff --git a/pdns/auth-querycache.hh b/pdns/auth-querycache.hh index 5e6d4360d..21e35add3 100644 --- a/pdns/auth-querycache.hh +++ b/pdns/auth-querycache.hh @@ -107,7 +107,7 @@ private: uint64_t d_maxEntries{0}; time_t d_lastclean; // doesn't need to be atomic - unsigned long d_nextclean{4906}; + unsigned long d_nextclean{4096}; unsigned int d_cleaninterval{4096}; bool d_cleanskipped{false}; diff --git a/pdns/calidns.cc b/pdns/calidns.cc index fcebd5a27..0edbded54 100644 --- a/pdns/calidns.cc +++ b/pdns/calidns.cc @@ -253,8 +253,8 @@ try while(getline(ifs, line)) { vector packet; boost::trim(line); - auto p = splitField(line, ' '); - DNSPacketWriter pw(packet, DNSName(p.first), DNSRecordContent::TypeToNumber(p.second)); + const auto fields = splitField(line, ' '); + DNSPacketWriter pw(packet, DNSName(fields.first), DNSRecordContent::TypeToNumber(fields.second)); pw.getHeader()->rd=wantRecursion; pw.getHeader()->id=random(); if(pw.getHeader()->id % 2) { diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 07e4a9778..eb4aead42 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -645,9 +645,9 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, bool doTransa set nsec3set; if (haveNSEC3 && !narrow) { - for (auto &rr: rrs) { + for (auto &loopRR: rrs) { bool skip=false; - DNSName shorter = rr.qname; + DNSName shorter = loopRR.qname; if (shorter != zone && shorter.chopOff() && shorter != zone) { do { if(nsset.count(shorter)) { @@ -656,8 +656,8 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, bool doTransa } } while(shorter.chopOff() && shorter != zone); } - shorter = rr.qname; - if(!skip && (rr.qtype.getCode() != QType::NS || !isOptOut)) { + shorter = loopRR.qname; + if(!skip && (loopRR.qtype.getCode() != QType::NS || !isOptOut)) { do { if(!nsec3set.count(shorter)) { diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 6a442ac57..c255391f1 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2477,8 +2477,8 @@ catch(const LuaContext::ExecutionErrorException& e) { try { errlog("Fatal Lua error: %s", e.what()); std::rethrow_if_nested(e); - } catch(const std::exception& e) { - errlog("Details: %s", e.what()); + } catch(const std::exception& ne) { + errlog("Details: %s", ne.what()); } catch(PDNSException &ae) { diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 2e1135214..4c5f218c9 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -649,17 +649,17 @@ bool sendPacketFromPR(PcapPacketReader& pr, const ComboAddress& remote, int stam s_origanswers++; qids_t::const_iterator iter=qids.find(qi); if(iter != qids.end()) { - QuestionData qd=*iter; - qd.d_origAnswers=mdp.d_answers; - qd.d_origRcode=mdp.d_header.rcode; + QuestionData eqd=*iter; + eqd.d_origAnswers=mdp.d_answers; + eqd.d_origRcode=mdp.d_header.rcode; if(!dh->ra) { s_norecursionavailable++; - qd.d_norecursionavailable=true; + eqd.d_norecursionavailable=true; } - qids.replace(iter, qd); + qids.replace(iter, eqd); - if(qd.d_newRcode!=-1) { + if(eqd.d_newRcode!=-1) { measureResultAndClean(iter); } diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index 02b4a15ed..773d71090 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -84,8 +84,8 @@ AuthLua4::AuthLua4(const std::string& fname) { cas.insert(ComboAddress(*s)); } else if(auto v = boost::get > >(&in)) { - for(const auto& s : *v) - cas.insert(ComboAddress(s.second)); + for(const auto& str : *v) + cas.insert(ComboAddress(str.second)); } else cas.insert(boost::get(in)); @@ -136,8 +136,8 @@ AuthLua4::AuthLua4(const std::string& fname) { if(auto rec = std::dynamic_pointer_cast(dr.d_content)) ret=rec->getCA(53); - else if(auto rec = std::dynamic_pointer_cast(dr.d_content)) - ret=rec->getCA(53); + else if(auto aaaarec = std::dynamic_pointer_cast(dr.d_content)) + ret=aaaarec->getCA(53); return ret; }); diff --git a/pdns/nproxy.cc b/pdns/nproxy.cc index b31387a73..f65496911 100644 --- a/pdns/nproxy.cc +++ b/pdns/nproxy.cc @@ -91,8 +91,7 @@ try if(res < 0) throw runtime_error("reading packet from remote: "+stringerror()); - string packet(buffer, res); - MOADNSParser mdp(true, packet); + MOADNSParser mdp(true, string(buffer,res)); nif.domain = mdp.d_qname; nif.origID = mdp.d_header.id; diff --git a/pdns/nsec3dig.cc b/pdns/nsec3dig.cc index a26e87b02..82345f532 100644 --- a/pdns/nsec3dig.cc +++ b/pdns/nsec3dig.cc @@ -212,17 +212,17 @@ try set proven; set denied; namesseen.insert(qname); - for(const auto &n: namesseen) + for(const auto &name: namesseen) { - DNSName shorter(n); + DNSName shorter(name); do { namestocheck.insert(shorter); } while(shorter.chopOff()); } - for(const auto &n: namestocheck) + for(const auto &name: namestocheck) { - proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied); - proveOrDeny(nsec3s, g_wildcarddnsname+n, nsec3salt, nsec3iters, proven, denied); + proveOrDeny(nsec3s, name, nsec3salt, nsec3iters, proven, denied); + proveOrDeny(nsec3s, g_wildcarddnsname+name, nsec3salt, nsec3iters, proven, denied); } if(names.count(qname)) diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index dd33e75a9..3b3bcbd16 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -582,7 +582,6 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const DNSName& target, bool doNextcloser = false; string before, after, hashed; DNSName unhashed, closest; - DNSZoneRecord rr; if (mode == 2 || mode == 3 || mode == 4) { closest=wildcard; @@ -622,8 +621,7 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const DNSName& target, if (!after.empty()) { DLOG(L<<"Done calling for matching, hashed: '"<addRecord(rr); + } } // add covering NSEC3 RR @@ -1382,10 +1380,10 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p) } if(weRedirected) { - for(auto& rr: rrset) { - if(rr.dr.d_type == QType::CNAME) { - r->addRecord(rr); - target = getRR(rr.dr)->getTarget(); + for(auto& loopRR: rrset) { + if(loopRR.dr.d_type == QType::CNAME) { + r->addRecord(loopRR); + target = getRR(loopRR.dr)->getTarget(); retargetcount++; goto retargeted; } @@ -1393,9 +1391,9 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p) } else if(weDone) { bool haveRecords = false; - for(const auto& rr: rrset) { - if((p->qtype.getCode() == QType::ANY || rr.dr.d_type == p->qtype.getCode()) && rr.dr.d_type && rr.dr.d_type != QType::ALIAS && rr.auth) { - r->addRecord(rr); + for(const auto& loopRR: rrset) { + if((p->qtype.getCode() == QType::ANY || loopRR.dr.d_type == p->qtype.getCode()) && loopRR.dr.d_type && loopRR.dr.d_type != QType::ALIAS && loopRR.auth) { + r->addRecord(loopRR); haveRecords = true; } } @@ -1433,8 +1431,8 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p) editSOA(d_dk, sd.qname, r); - for(const auto& rr: r->getRRS()) { - if(rr.scopeMask) { + for(const auto& loopRR: r->getRRS()) { + if(loopRR.scopeMask) { noCache=true; break; } diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 6ea920f86..64efdd758 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1267,8 +1267,8 @@ static void startDoResolve(void *p) // Luawrapper nests the exception from Lua, so we unnest it here try { std::rethrow_if_nested(e); - } catch(const std::exception& e) { - L<<". Extra info: "< records; if(!suppliedrecords) { + DNSResourceRecord drr; sd.db->list(zone, sd.domain_id, g_verbose); - while(sd.db->get(rr)) { - records.push_back(rr); + while(sd.db->get(drr)) { + records.push_back(drr); } } else @@ -841,11 +841,11 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) { } cmdline.clear(); ZoneParserTNG zpt(tmpnam, g_rootdnsname); - DNSResourceRecord rr; + DNSResourceRecord zrr; map, vector > grouped; - while(zpt.get(rr)) { + while(zpt.get(zrr)) { try { - DNSRecord dr(rr); + DNSRecord dr(zrr); post.push_back(dr); grouped[{dr.d_name,dr.d_type}].push_back(dr); } @@ -923,14 +923,14 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) { else if(changed.empty() || c!='a') goto reAsk2; - for(const auto& c : changed) { + for(const auto& change : changed) { vector vrr; - for(const DNSRecord& rr : grouped[c.first]) { - DNSResourceRecord drr = DNSResourceRecord::fromWire(rr); - drr.domain_id = di.id; - vrr.push_back(drr); + for(const DNSRecord& rr : grouped[change.first]) { + DNSResourceRecord crr = DNSResourceRecord::fromWire(rr); + crr.domain_id = di.id; + vrr.push_back(crr); } - di.backend->replaceRRSet(di.id, c.first.first, QType(c.first.second), vrr); + di.backend->replaceRRSet(di.id, change.first.first, QType(change.first.second), vrr); } rectifyZone(dk, zone); return EXIT_SUCCESS; diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index 7b9ff8139..045bae2b5 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -74,27 +74,27 @@ protected: buflen = 0; }; public: - P11KitAttribute(CK_ATTRIBUTE_TYPE type, const std::string& value) { + P11KitAttribute(CK_ATTRIBUTE_TYPE type_, const std::string& value) { Init(); - this->type = type; + this->type = type_; setString(value); } - P11KitAttribute(CK_ATTRIBUTE_TYPE type, char value) { + P11KitAttribute(CK_ATTRIBUTE_TYPE type_, char value) { Init(); - this->type = type; + this->type = type_; setByte(value); } - P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned char value) { + P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned char value) { Init(); - this->type = type; + this->type = type_; setByte(value); } - P11KitAttribute(CK_ATTRIBUTE_TYPE type, unsigned long value) { + P11KitAttribute(CK_ATTRIBUTE_TYPE type_, unsigned long value) { Init(); - this->type = type; + this->type = type_; setLong(value); } @@ -571,9 +571,9 @@ class Pkcs11Token { } // then allocate memory - for(size_t k=0; k < attributes.size(); k++) { - if (attributes[k].valueType() == Attribute_String) { - attr[k].pValue = attributes[k].allocate(attr[k].ulValueLen); + for(size_t idx=0; idx < attributes.size(); idx++) { + if (attributes[idx].valueType() == Attribute_String) { + attr[idx].pValue = attributes[idx].allocate(attr[idx].ulValueLen); } } @@ -582,9 +582,9 @@ class Pkcs11Token { logError("C_GetAttributeValue"); // copy values to map and release allocated memory - for(size_t k=0; k < attributes.size(); k++) { - if (attributes[k].valueType() == Attribute_String) { - attributes[k].commit(attr[k].ulValueLen); + for(size_t idx=0; idx < attributes.size(); idx++) { + if (attributes[idx].valueType() == Attribute_String) { + attributes[idx].commit(attr[idx].ulValueLen); } } diff --git a/pdns/recursordist/test-recursorcache_cc.cc b/pdns/recursordist/test-recursorcache_cc.cc index 5ea108cb0..7d42aa03f 100644 --- a/pdns/recursordist/test-recursorcache_cc.cc +++ b/pdns/recursordist/test-recursorcache_cc.cc @@ -574,12 +574,12 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) { size_t found = 0; for (size_t i = 0; i <= 255; i++) { retrieved.clear(); - ComboAddress who("192.0.2." + std::to_string(i)); + ComboAddress whoLoop("192.0.2." + std::to_string(i)); - auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, who); + auto ret = MRC.get(now, power1, QType(QType::A), false, &retrieved, whoLoop); if (ret > 0) { BOOST_REQUIRE_EQUAL(retrieved.size(), 1); - BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), who.toString()); + BOOST_CHECK_EQUAL(getRR(retrieved.at(0))->getCA().toString(), whoLoop.toString()); found++; } else { diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index 3527a1770..c473ea82a 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -1911,7 +1911,6 @@ BOOST_AUTO_TEST_CASE(test_no_rd) { BOOST_AUTO_TEST_CASE(test_cache_min_max_ttl) { std::unique_ptr sr; - const time_t now = time(nullptr); initSR(sr); primeHints(); @@ -1938,6 +1937,7 @@ BOOST_AUTO_TEST_CASE(test_cache_min_max_ttl) { return 0; }); + const time_t now = time(nullptr); SyncRes::s_minimumTTL = 60; SyncRes::s_maxcachettl = 3600; @@ -7343,7 +7343,6 @@ BOOST_AUTO_TEST_CASE(test_nsec3_insecure_delegation_denial) { BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) { std::unique_ptr sr; - const time_t now = time(nullptr); initSR(sr, true); setDNSSECValidation(sr, DNSSECMode::ValidateAll); @@ -7381,6 +7380,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) { return 0; }); + const time_t now = time(nullptr); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); BOOST_CHECK_EQUAL(res, RCode::NoError); @@ -7409,7 +7409,6 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_negcache_validity) { BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) { std::unique_ptr sr; - const time_t now = time(nullptr); initSR(sr, true); setDNSSECValidation(sr, DNSSECMode::ValidateAll); @@ -7446,6 +7445,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_rrsig_cache_validity) { return 0; }); + const time_t now = time(nullptr); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); BOOST_CHECK_EQUAL(res, RCode::NoError); diff --git a/pdns/saxfr.cc b/pdns/saxfr.cc index 38ba5590f..9b18d422e 100644 --- a/pdns/saxfr.cc +++ b/pdns/saxfr.cc @@ -204,9 +204,7 @@ try n+=numread; } - string packet = string(creply, len); - - MOADNSParser mdp(false, packet); + MOADNSParser mdp(false, string(creply, len)); if (mdp.d_header.rcode != 0) { throw PDNSException(string("Remote server refused: ") + std::to_string(mdp.d_header.rcode)); } diff --git a/pdns/statnode.cc b/pdns/statnode.cc index 7a6959dd3..d33836438 100644 --- a/pdns/statnode.cc +++ b/pdns/statnode.cc @@ -88,8 +88,9 @@ void StatNode::submit(deque& labels, const std::string& domain, int rcod name=labels.back(); // cerr<<"Set short name to '"<d_ttl - d_now.tv_sec; - ret.push_back(dr); + DNSRecord authDR(*rec); + authDR.d_ttl=j->d_ttl - d_now.tv_sec; + ret.push_back(authDR); } if(qtype != QType::CNAME) { // perhaps they really wanted a CNAME! @@ -1559,8 +1559,8 @@ void SyncRes::computeZoneCuts(const DNSName& begin, const DNSName& end, unsigned just look for (N)TA */ if (cutState == Insecure || cutState == Bogus) { - dsmap_t ds; - vState newState = getDSRecords(qname, ds, true, depth); + dsmap_t cutDS; + vState newState = getDSRecords(qname, cutDS, true, depth); if (newState == Indeterminate) { continue; } diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 394fa9fb1..cc0011ed8 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -815,15 +815,15 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou if(rectify) { // set auth - for(DNSZoneRecord &zrr : zrrs) { - zrr.auth=true; - if (zrr.dr.d_type != QType::NS || zrr.dr.d_name!=target) { - DNSName shorter(zrr.dr.d_name); + for(DNSZoneRecord &loopZRR : zrrs) { + loopZRR.auth=true; + if (loopZRR.dr.d_type != QType::NS || loopZRR.dr.d_name!=target) { + DNSName shorter(loopZRR.dr.d_name); do { if (shorter==target) // apex is always auth break; - if(nsset.count(shorter) && !(zrr.dr.d_name==shorter && zrr.dr.d_type == QType::DS)) { - zrr.auth=false; + if(nsset.count(shorter) && !(loopZRR.dr.d_name==shorter && loopZRR.dr.d_type == QType::DS)) { + loopZRR.auth=false; break; } } while(shorter.chopOff()); @@ -834,9 +834,9 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou // ents are only required for NSEC3 zones uint32_t maxent = ::arg().asNum("max-ent-entries"); set nsec3set, nonterm; - for (auto &zrr: zrrs) { + for (auto &loopZRR: zrrs) { bool skip=false; - DNSName shorter = zrr.dr.d_name; + DNSName shorter = loopZRR.dr.d_name; if (shorter != target && shorter.chopOff() && shorter != target) { do { if(nsset.count(shorter)) { @@ -845,8 +845,8 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou } } while(shorter.chopOff() && shorter != target); } - shorter = zrr.dr.d_name; - if(!skip && (zrr.dr.d_type != QType::NS || !ns3pr.d_flags)) { + shorter = loopZRR.dr.d_name; + if(!skip && (loopZRR.dr.d_type != QType::NS || !ns3pr.d_flags)) { do { if(!nsec3set.count(shorter)) { nsec3set.insert(shorter); @@ -855,8 +855,8 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou } } - for(DNSZoneRecord &zrr : zrrs) { - DNSName shorter(zrr.dr.d_name); + for(DNSZoneRecord &loopZRR : zrrs) { + DNSName shorter(loopZRR.dr.d_name); while(shorter != target && shorter.chopOff()) { if(!qnames.count(shorter) && !nonterm.count(shorter) && nsec3set.count(shorter)) { if(!(maxent)) { @@ -870,11 +870,11 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou } for(const auto& nt : nonterm) { - DNSZoneRecord zrr; - zrr.dr.d_name=nt; - zrr.dr.d_type=QType::ENT; - zrr.auth=true; - zrrs.push_back(zrr); + DNSZoneRecord tempRR; + tempRR.dr.d_name=nt; + tempRR.dr.d_type=QType::ENT; + tempRR.auth=true; + zrrs.push_back(tempRR); } } } @@ -888,39 +888,39 @@ int TCPNameserver::doAXFR(const DNSName &target, shared_ptr q, int ou DTime dt; dt.set(); int records=0; - for(DNSZoneRecord &zrr : zrrs) { - if (zrr.dr.d_type == QType::RRSIG) { - if(presignedZone && NSEC3Zone && getRR(zrr.dr)->d_type == QType::NSEC3) { - ns3rrs.insert(zrr.dr.d_name.makeRelative(sd.qname)); + for(DNSZoneRecord &loopZRR : zrrs) { + if (loopZRR.dr.d_type == QType::RRSIG) { + if(presignedZone && NSEC3Zone && getRR(loopZRR.dr)->d_type == QType::NSEC3) { + ns3rrs.insert(loopZRR.dr.d_name.makeRelative(sd.qname)); } continue; } // only skip the DNSKEY, CDNSKEY and CDS if direct-dnskey is enabled, to avoid changing behaviour // when it is not enabled. - if(::arg().mustDo("direct-dnskey") && (zrr.dr.d_type == QType::DNSKEY || zrr.dr.d_type == QType::CDNSKEY || zrr.dr.d_type == QType::CDS)) + if(::arg().mustDo("direct-dnskey") && (loopZRR.dr.d_type == QType::DNSKEY || loopZRR.dr.d_type == QType::CDNSKEY || loopZRR.dr.d_type == QType::CDS)) continue; records++; - if(securedZone && (zrr.auth || zrr.dr.d_type == QType::NS)) { - if (NSEC3Zone || zrr.dr.d_type) { - keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, zrr.dr.d_name))) : zrr.dr.d_name; + if(securedZone && (loopZRR.auth || loopZRR.dr.d_type == QType::NS)) { + if (NSEC3Zone || loopZRR.dr.d_type) { + keyname = NSEC3Zone ? DNSName(toBase32Hex(hashQNameWithSalt(ns3pr, loopZRR.dr.d_name))) : loopZRR.dr.d_name; NSECXEntry& ne = nsecxrepo[keyname]; ne.d_ttl = sd.default_ttl; - ne.d_auth = (ne.d_auth || zrr.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags)))); - if (zrr.dr.d_type) { - ne.d_set.insert(zrr.dr.d_type); + ne.d_auth = (ne.d_auth || loopZRR.auth || (NSEC3Zone && (!ns3pr.d_flags || (presignedZone && ns3pr.d_flags)))); + if (loopZRR.dr.d_type) { + ne.d_set.insert(loopZRR.dr.d_type); } } } - if (!zrr.dr.d_type) + if (!loopZRR.dr.d_type) continue; // skip empty non-terminals - if(zrr.dr.d_type == QType::SOA) + if(loopZRR.dr.d_type == QType::SOA) continue; // skip SOA - would indicate end of AXFR - if(csp.submit(zrr)) { + if(csp.submit(loopZRR)) { for(;;) { outpacket->getRRS() = csp.getChunk(); if(!outpacket->getRRS().empty()) { diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index 771bfb84b..7200454c8 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(test_QuestionHash) { for(unsigned int n=0; n < 100000; ++n) { packet.clear(); - DNSPacketWriter dpw1(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA); + DNSPacketWriter dpw3(packet, DNSName(std::to_string(n)+"."+std::to_string(n*2)+"."), QType::AAAA); counts[hashQuestion((char*)&packet[0], packet.size(), 0) % counts.size()]++; } @@ -597,17 +597,17 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) { BOOST_CHECK(!a(DNSName("www.powerdns.net"), g_rootdnsname)); vector vec; - for(const std::string& a : {"bert.com.", "alpha.nl.", "articles.xxx.", + for(const std::string& b : {"bert.com.", "alpha.nl.", "articles.xxx.", "Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.", "test.powerdns.com.", "\\128.com"}) { - vec.push_back(DNSName(a)); + vec.push_back(DNSName(b)); } sort(vec.begin(), vec.end(), CanonDNSNameCompare()); // for(const auto& v : vec) // cerr<<'"'< right; - for(const auto& a: {"bert.com.", "Aleph1.powerdns.com.", + for(const auto& b: {"bert.com.", "Aleph1.powerdns.com.", "test.powerdns.com.", "ZOMG.powerdns.com.", "\\128.com.", @@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) { "aaa.XXX.", "articles.xxx.", "yyy.XXX."}) - right.push_back(DNSName(a)); + right.push_back(DNSName(b)); BOOST_CHECK(vec==right); diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 54351e330..913063c59 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -195,11 +195,11 @@ bool ZoneParserTNG::getTemplateLine() char radix='d'; sscanf(spec.c_str(), "%d,%d,%c", &offset, &width, &radix); // parse format specifier - char format[12]; - snprintf(format, sizeof(format) - 1, "%%0%d%c", width, radix); // make into printf-style format + char sformat[12]; + snprintf(sformat, sizeof(sformat) - 1, "%%0%d%c", width, radix); // make into printf-style format char tmp[80]; - snprintf(tmp, sizeof(tmp)-1, format, d_templatecounter + offset); // and do the actual printing + snprintf(tmp, sizeof(tmp)-1, sformat, d_templatecounter + offset); // and do the actual printing outpart+=tmp; } else