From 6177a1769e6b1e0e18ff7d5f8494ad3cc5a11f4a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Sun, 4 Jun 2017 18:48:21 +0200 Subject: [PATCH] Make DNSRecordContent::mastermake() return a shared pointer We almost always wrapped it into one afterward, and had no good reason not to anyway. --- modules/bindbackend/binddnssec.cc | 3 +- modules/tinydnsbackend/tinydnsbackend.cc | 3 +- pdns/dnsparser.cc | 39 ++++++++++----------- pdns/dnsparser.hh | 6 ++-- pdns/lua-auth4.cc | 2 +- pdns/lua-pdns.cc | 2 +- pdns/lua-recursor4.cc | 6 ++-- pdns/packethandler.cc | 4 +-- pdns/pdnsutil.cc | 11 +++--- pdns/rec-lua-conf.cc | 4 +-- pdns/recursordist/test-negcache_cc.cc | 2 +- pdns/recursordist/test-syncres_cc.cc | 2 +- pdns/reczones.cc | 8 ++--- pdns/speedtest.cc | 43 +++++++++--------------- pdns/syncres.cc | 2 +- pdns/test-dnsrecords_cc.cc | 6 ++-- pdns/ws-auth.cc | 2 +- 17 files changed, 63 insertions(+), 82 deletions(-) diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index fb125af272..6f1981dd4a 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -168,9 +168,8 @@ bool Bind2Backend::getNSEC3PARAM(const DNSName& name, NSEC3PARAMRecordContent* n static int maxNSEC3Iterations=::arg().asNum("max-nsec3-iterations"); if(ns3p) { - NSEC3PARAMRecordContent* tmp=dynamic_cast(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value)); + std::shared_ptr tmp=std::dynamic_pointer_cast(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value)); *ns3p = *tmp; - delete tmp; if (ns3p->d_iterations > maxNSEC3Iterations) { ns3p->d_iterations = maxNSEC3Iterations; diff --git a/modules/tinydnsbackend/tinydnsbackend.cc b/modules/tinydnsbackend/tinydnsbackend.cc index 8b3bed9f89..83b473d936 100644 --- a/modules/tinydnsbackend/tinydnsbackend.cc +++ b/modules/tinydnsbackend/tinydnsbackend.cc @@ -300,10 +300,9 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr) dr.d_type = rr.qtype.getCode(); dr.d_clen = val.size()-pr.d_pos; - DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr); + std::shared_ptr drc = DNSRecordContent::mastermake(dr, pr); rr.content = drc->getZoneRepresentation(); DLOG(cerr<<"CONTENT: "< DNSRecordContent::unserialize(const DNSName& qname, return ret; } -DNSRecordContent* DNSRecordContent::mastermake(const DNSRecord &dr, +std::shared_ptr DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr) { uint16_t searchclass = (dr.d_type == QType::OPT) ? 1 : dr.d_class; // class is invalid for OPT typemap_t::const_iterator i=getTypemap().find(make_pair(searchclass, dr.d_type)); if(i==getTypemap().end() || !i->second) { - return new UnknownRecordContent(dr, pr); + return std::make_shared(dr, pr); } - return i->second(dr, pr); + return std::shared_ptr(i->second(dr, pr)); } -DNSRecordContent* DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass, +std::shared_ptr DNSRecordContent::mastermake(uint16_t qtype, uint16_t qclass, const string& content) { zmakermap_t::const_iterator i=getZmakermap().find(make_pair(qclass, qtype)); if(i==getZmakermap().end()) { - return new UnknownRecordContent(content); + return std::make_shared(content); } - return i->second(content); + return std::shared_ptr(i->second(content)); } std::unique_ptr DNSRecordContent::makeunique(uint16_t qtype, uint16_t qclass, @@ -157,21 +157,21 @@ std::unique_ptr DNSRecordContent::makeunique(uint16_t qtype, u } -DNSRecordContent* DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t oc) { +std::shared_ptr DNSRecordContent::mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t oc) { // For opcode UPDATE and where the DNSRecord is an answer record, we don't care about content, because this is // not used within the prerequisite section of RFC2136, so - we can simply use unknownrecordcontent. // For section 3.2.3, we do need content so we need to get it properly. But only for the correct QClasses. if (oc == Opcode::Update && dr.d_place == DNSResourceRecord::ANSWER && dr.d_class != 1) - return new UnknownRecordContent(dr, pr); + return std::make_shared(dr, pr); uint16_t searchclass = (dr.d_type == QType::OPT) ? 1 : dr.d_class; // class is invalid for OPT typemap_t::const_iterator i=getTypemap().find(make_pair(searchclass, dr.d_type)); if(i==getTypemap().end() || !i->second) { - return new UnknownRecordContent(dr, pr); + return std::make_shared(dr, pr); } - return i->second(dr, pr); + return std::shared_ptr(i->second(dr, pr)); } @@ -207,7 +207,7 @@ DNSRecord::DNSRecord(const DNSResourceRecord& rr) d_class = rr.qclass; d_place = DNSResourceRecord::ANSWER; d_clen = 0; - d_content = std::shared_ptr(DNSRecordContent::mastermake(d_type, rr.qclass, rr.content)); + d_content = DNSRecordContent::mastermake(d_type, rr.qclass, rr.content); } // If you call this and you are not parsing a packet coming from a socket, you are doing it wrong. @@ -290,7 +290,7 @@ void MOADNSParser::init(bool query, const char *packet, unsigned int len) } else { // cerr<<"parsing RR, query is "<(DNSRecordContent::mastermake(dr, pr, d_header.opcode)); + dr.d_content=DNSRecordContent::mastermake(dr, pr, d_header.opcode); } d_answers.push_back(make_pair(dr, pr.d_pos)); @@ -431,15 +431,12 @@ DNSName PacketReader::getName() d_pos+=consumed; return dn; } - catch(std::range_error& re) - { - throw std::out_of_range(string("dnsname issue: ")+re.what()); - } - - catch(...) - { - throw std::out_of_range("dnsname issue"); - } + catch(const std::range_error& re) { + throw std::out_of_range(string("dnsname issue: ")+re.what()); + } + catch(...) { + throw std::out_of_range("dnsname issue"); + } throw PDNSException("PacketReader::getName(): name is empty"); } diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index 1f0ca6a5b9..78a73f03be 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -166,9 +166,9 @@ struct DNSRecord; class DNSRecordContent { public: - static DNSRecordContent* mastermake(const DNSRecord &dr, PacketReader& pr); - static DNSRecordContent* mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode); - static DNSRecordContent* mastermake(uint16_t qtype, uint16_t qclass, const string& zone); + static std::shared_ptr mastermake(const DNSRecord &dr, PacketReader& pr); + static std::shared_ptr mastermake(const DNSRecord &dr, PacketReader& pr, uint16_t opcode); + static std::shared_ptr mastermake(uint16_t qtype, uint16_t qclass, const string& zone); static std::unique_ptr makeunique(uint16_t qtype, uint16_t qclass, const string& content); virtual std::string getZoneRepresentation(bool noDot=false) const = 0; diff --git a/pdns/lua-auth4.cc b/pdns/lua-auth4.cc index a14c12b3fb..687da4bdd1 100644 --- a/pdns/lua-auth4.cc +++ b/pdns/lua-auth4.cc @@ -142,7 +142,7 @@ AuthLua4::AuthLua4(const std::string& fname) { }); - d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = shared_ptr(DNSRecordContent::mastermake(dr.d_type, 1, newContent)); }); + d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = DNSRecordContent::mastermake(dr.d_type, 1, newContent); }); d_lw->writeFunction("pdnslog", [](const std::string& msg, boost::optional loglevel) { theL() << (Logger::Urgency)loglevel.get_value_or(Logger::Warning) << msg<(DNSRecordContent::mastermake(rr.d_type, rr.d_class, content)); + rr.d_content=DNSRecordContent::mastermake(rr.d_type, rr.d_class, content); if(!getFromTable(lua, "ttl", rr.d_ttl)) rr.d_ttl=3600; diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index e6ae516f42..192eb2d187 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -196,7 +196,7 @@ void RecursorLua4::DNSQuestion::addRecord(uint16_t type, const std::string& cont dr.d_ttl=ttl.get_value_or(3600); dr.d_type = type; dr.d_place = place; - dr.d_content = shared_ptr(DNSRecordContent::mastermake(type, 1, content)); + dr.d_content = DNSRecordContent::mastermake(type, 1, content); records.push_back(dr); } @@ -372,7 +372,7 @@ RecursorLua4::RecursorLua4(const std::string& fname) }, [](DNSFilterEngine::Policy& pol, const std::string& content) { // Only CNAMES for now, when we ever add a d_custom_type, there will be pain - pol.d_custom = shared_ptr(DNSRecordContent::mastermake(QType::CNAME, 1, content)); + pol.d_custom = DNSRecordContent::mastermake(QType::CNAME, 1, content); } ); d_lw->registerFunction("getDH", &DNSQuestion::getDH); @@ -401,7 +401,7 @@ RecursorLua4::RecursorLua4(const std::string& fname) }); - d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = shared_ptr(DNSRecordContent::mastermake(dr.d_type, 1, newContent)); }); + d_lw->registerFunction("changeContent", [](DNSRecord& dr, const std::string& newContent) { dr.d_content = DNSRecordContent::mastermake(dr.d_type, 1, newContent); }); d_lw->registerFunction("addAnswer", &DNSQuestion::addAnswer); d_lw->registerFunction("addRecord", &DNSQuestion::addRecord); d_lw->registerFunction("getRecords", &DNSQuestion::getRecords); diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 3a9dc7a251..cf083520f2 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -265,7 +265,7 @@ int PacketHandler::doChaosRequest(DNSPacket *p, DNSPacket *r, DNSName &target) } else content=mode; - rr.dr.d_content = shared_ptr(DNSRecordContent::mastermake(QType::TXT, 1, "\""+content+"\"")); + rr.dr.d_content = DNSRecordContent::mastermake(QType::TXT, 1, "\""+content+"\""); } else if (target==idserver) { // modes: disabled, hostname or custom @@ -275,7 +275,7 @@ int PacketHandler::doChaosRequest(DNSPacket *p, DNSPacket *r, DNSName &target) r->setRcode(RCode::Refused); return 0; } - rr.dr.d_content=shared_ptr(DNSRecordContent::mastermake(QType::TXT, 1, id)); + rr.dr.d_content=DNSRecordContent::mastermake(QType::TXT, 1, id); } else { r->setRcode(RCode::Refused); diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 3621440060..4c57f76360 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -1,3 +1,4 @@ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -1465,23 +1466,23 @@ void verifyCrypto(const string& zone) if(rr.qtype.getCode() == QType::DNSKEY) { cerr<<"got DNSKEY!"<(DNSRecordContent::mastermake(QType::DNSKEY, 1, rr.content)); + drc = *std::dynamic_pointer_cast(DNSRecordContent::mastermake(QType::DNSKEY, 1, rr.content)); } else if(rr.qtype.getCode() == QType::RRSIG) { cerr<<"got RRSIG"<(DNSRecordContent::mastermake(QType::RRSIG, 1, rr.content)); + rrc = *std::dynamic_pointer_cast(DNSRecordContent::mastermake(QType::RRSIG, 1, rr.content)); } else if(rr.qtype.getCode() == QType::DS) { cerr<<"got DS"<(DNSRecordContent::mastermake(QType::DS, 1, rr.content)); + dsrc = *std::dynamic_pointer_cast(DNSRecordContent::mastermake(QType::DS, 1, rr.content)); } else { qname = rr.qname; - toSign.push_back(shared_ptr(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content))); + toSign.push_back(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); } } - string msg = getMessageForRRSET(qname, rrc, toSign); + string msg = getMessageForRRSET(qname, rrc, toSign); cerr<<"Verify: "<verify(msg, rrc.d_signature)<d_name = std::make_shared(polName); if(defpol->d_kind == DNSFilterEngine::PolicyKind::Custom) { defpol->d_custom= - shared_ptr( DNSRecordContent::mastermake(QType::CNAME, 1, boost::get(constGet(have,"defcontent")) - ) - ); + ); if(have.count("defttl")) defpol->d_ttl = static_cast(boost::get(constGet(have, "defttl"))); diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index c0ee00e506..7340884700 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -14,7 +14,7 @@ static recordsAndSignatures genRecsAndSigs(const DNSName& name, const uint16_t q rec.d_type = qtype; rec.d_ttl = 600; rec.d_place = DNSResourceRecord::AUTHORITY; - rec.d_content = shared_ptr(DNSRecordContent::mastermake(qtype, QClass::IN, content)); + rec.d_content = DNSRecordContent::mastermake(qtype, QClass::IN, content); ret.records.push_back(rec); diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index e2338783b2..1f1bab4026 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -195,7 +195,7 @@ static void addRecordToList(std::vector& records, const DNSName& name rec.d_content = std::make_shared(); } else { - rec.d_content = shared_ptr(DNSRecordContent::mastermake(type, QClass::IN, content)); + rec.d_content = DNSRecordContent::mastermake(type, QClass::IN, content); } records.push_back(rec); diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 772decded2..01e818d127 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -108,7 +108,7 @@ static void makeNameToIPZone(std::shared_ptr newMap, const dr.d_ttl=86400; dr.d_type=QType::SOA; dr.d_class = 1; - dr.d_content = std::shared_ptr(DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800")); + dr.d_content = DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800"); ad.d_records.insert(dr); @@ -118,7 +118,7 @@ static void makeNameToIPZone(std::shared_ptr newMap, const ad.d_records.insert(dr); dr.d_type=QType::A; - dr.d_content= std::shared_ptr(DNSRecordContent::mastermake(QType::A, 1, ip)); + dr.d_content = DNSRecordContent::mastermake(QType::A, 1, ip); ad.d_records.insert(dr); if(newMap->count(dr.d_name)) { @@ -151,7 +151,7 @@ static void makeIPToNamesZone(std::shared_ptr newMap, cons dr.d_place=DNSResourceRecord::ANSWER; dr.d_ttl=86400; dr.d_type=QType::SOA; - dr.d_content=std::shared_ptr(DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800")); + dr.d_content=DNSRecordContent::mastermake(QType::SOA, 1, "localhost. root 1 604800 86400 2419200 604800"); ad.d_records.insert(dr); @@ -163,7 +163,7 @@ static void makeIPToNamesZone(std::shared_ptr newMap, cons if(ipparts.size()==4) // otherwise this is a partial zone for(unsigned int n=1; n < parts.size(); ++n) { - dr.d_content=std::shared_ptr(DNSRecordContent::mastermake(QType::PTR, 1, DNSName(parts[n]).toString())); // XXX FIXME DNSNAME PAIN CAN THIS BE RIGHT? + dr.d_content=DNSRecordContent::mastermake(QType::PTR, 1, DNSName(parts[n]).toString()); // XXX FIXME DNSNAME PAIN CAN THIS BE RIGHT? ad.d_records.insert(dr); } diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index d3a1fc15bd..5c8e0677da 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -229,29 +229,25 @@ vector makeBigReferral() for(char c='a'; c<= 'm';++c) { pw.startRecord(DNSName("com"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); gtld[0]=c; - DNSRecordContent* drc = DNSRecordContent::mastermake(QType::NS, 1, gtld); + std::unique_ptr drc = DNSRecordContent::makeunique(QType::NS, 1, gtld); drc->toPacket(pw); - delete drc; } for(char c='a'; c<= 'k';++c) { gtld[0]=c; pw.startRecord(DNSName(gtld), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - DNSRecordContent* drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); + std::unique_ptr drc = DNSRecordContent::makeunique(QType::A, 1, "1.2.3.4"); drc->toPacket(pw); - delete drc; } pw.startRecord(DNSName("a.gtld-servers.net"), QType::AAAA, 3600, 1, DNSResourceRecord::ADDITIONAL); - auto aaaarc = DNSRecordContent::mastermake(QType::AAAA, 1, "2001:503:a83e::2:30"); + auto aaaarc = DNSRecordContent::makeunique(QType::AAAA, 1, "2001:503:a83e::2:30"); aaaarc->toPacket(pw); - delete aaaarc; pw.startRecord(DNSName("b.gtld-servers.net"), QType::AAAA, 3600, 1, DNSResourceRecord::ADDITIONAL); - aaaarc = DNSRecordContent::mastermake(QType::AAAA, 1, "2001:503:231d::2:30"); + aaaarc = DNSRecordContent::makeunique(QType::AAAA, 1, "2001:503:231d::2:30"); aaaarc->toPacket(pw); - delete aaaarc; pw.commit(); @@ -297,9 +293,8 @@ vector makeBigDNSPacketReferral() // shuffle(records); for(const auto& rec : records) { pw.startRecord(rec.qname, rec.qtype.getCode(), rec.ttl, 1, DNSResourceRecord::ADDITIONAL); - auto drc = DNSRecordContent::mastermake(rec.qtype.getCode(), 1, rec.content); + auto drc = DNSRecordContent::makeunique(rec.qtype.getCode(), 1, rec.content); drc->toPacket(pw); - delete drc; } pw.commit(); @@ -317,9 +312,8 @@ struct MakeARecordTestMM void operator()() const { - DNSRecordContent*drc = DNSRecordContent::mastermake(QType::A, 1, - "1.2.3.4"); - delete drc; + auto drc = DNSRecordContent::makeunique(QType::A, 1, + "1.2.3.4"); } }; @@ -391,10 +385,9 @@ struct GenericRecordTest DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), d_type); for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), d_type); - DNSRecordContent*drc = DNSRecordContent::mastermake(d_type, 1, - d_content); + auto drc = DNSRecordContent::makeunique(d_type, 1, + d_content); drc->toPacket(pw); - delete drc; } pw.commit(); } @@ -419,9 +412,8 @@ struct AAAARecordTest DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::AAAA); for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), QType::AAAA); - DNSRecordContent*drc = DNSRecordContent::mastermake(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441"); + auto drc = DNSRecordContent::makeunique(QType::AAAA, 1, "fe80::21d:92ff:fe6d:8441"); drc->toPacket(pw); - delete drc; } pw.commit(); } @@ -444,9 +436,8 @@ struct SOARecordTest for(int records = 0; records < d_records; records++) { pw.startRecord(DNSName("outpost.ds9a.nl"), QType::SOA); - DNSRecordContent*drc = DNSRecordContent::mastermake(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400"); + auto drc = DNSRecordContent::makeunique(QType::SOA, 1, "a0.org.afilias-nst.info. noc.afilias-nst.info. 2008758137 1800 900 604800 86400"); drc->toPacket(pw); - delete drc; } pw.commit(); } @@ -466,25 +457,21 @@ vector makeTypicalReferral() DNSPacketWriter pw(packet, DNSName("outpost.ds9a.nl"), QType::A); pw.startRecord(DNSName("ds9a.nl"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); - DNSRecordContent* drc = DNSRecordContent::mastermake(QType::NS, 1, "ns1.ds9a.nl"); + auto drc = DNSRecordContent::makeunique(QType::NS, 1, "ns1.ds9a.nl"); drc->toPacket(pw); - delete drc; pw.startRecord(DNSName("ds9a.nl"), QType::NS, 3600, 1, DNSResourceRecord::AUTHORITY); - drc = DNSRecordContent::mastermake(QType::NS, 1, "ns2.ds9a.nl"); + drc = DNSRecordContent::makeunique(QType::NS, 1, "ns2.ds9a.nl"); drc->toPacket(pw); - delete drc; pw.startRecord(DNSName("ns1.ds9a.nl"), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - drc = DNSRecordContent::mastermake(QType::A, 1, "1.2.3.4"); + drc = DNSRecordContent::makeunique(QType::A, 1, "1.2.3.4"); drc->toPacket(pw); - delete drc; pw.startRecord(DNSName("ns2.ds9a.nl"), QType::A, 3600, 1, DNSResourceRecord::ADDITIONAL); - drc = DNSRecordContent::mastermake(QType::A, 1, "4.3.2.1"); + drc = DNSRecordContent::makeunique(QType::A, 1, "4.3.2.1"); drc->toPacket(pw); - delete drc; pw.commit(); return packet; diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 4652fb1754..206f4bfcda 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -190,7 +190,7 @@ bool SyncRes::doSpecialNamesResolve(const DNSName &qname, const QType &qtype, co dr.d_ttl = 86400; for (const auto& ans : answers) { dr.d_type = ans.first; - dr.d_content = shared_ptr(DNSRecordContent::mastermake(ans.first, qclass, ans.second)); + dr.d_content = DNSRecordContent::mastermake(ans.first, qclass, ans.second); ret.push_back(dr); } } diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 576c42d5d7..bb68f90cf7 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(test_record_types) { try { std::string recData; if (q.getCode() != QType::TSIG) { - boost::scoped_ptr rec(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); + auto rec = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()); BOOST_CHECK_MESSAGE(rec != NULL, "mastermake( " << q.getCode() << ", 1, " << val.get<1>() << ") returned NULL"); if (rec == NULL) continue; // now verify the record (note that this will be same as *zone* value (except for certain QTypes) @@ -268,10 +268,10 @@ BOOST_AUTO_TEST_CASE(test_record_types_bad_values) { if (val.get<2>()) { bool success=true; - BOOST_WARN_EXCEPTION( { boost::scoped_ptr drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); success=false; }, std::exception, test_dnsrecords_cc_predicate ); + BOOST_WARN_EXCEPTION( { auto drc = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); success=false; }, std::exception, test_dnsrecords_cc_predicate ); if (success==false) REC_FAIL_XSUCCESS2(q.getName() << " test #" << n << " has unexpectedly passed"); // a bad record was detected when it was supposed not to be detected } else { - BOOST_CHECK_EXCEPTION( { boost::scoped_ptr drc(DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>())); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); }, std::exception, test_dnsrecords_cc_predicate ); + BOOST_CHECK_EXCEPTION( { auto drc = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); }, std::exception, test_dnsrecords_cc_predicate ); } }; } diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 2129964dc5..5d3482fc1d 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -287,7 +287,7 @@ void AuthWebServer::indexfunction(HttpRequest* req, HttpResponse* resp) /** Helper to build a record content as needed. */ static inline string makeRecordContent(const QType& qtype, const string& content, bool noDot) { // noDot: for backend storage, pass true. for API users, pass false. - std::unique_ptr drc(DNSRecordContent::mastermake(qtype.getCode(), 1, content)); + std::unique_ptr drc(DNSRecordContent::makeunique(qtype.getCode(), QClass::IN, content)); return drc->getZoneRepresentation(noDot); } -- 2.47.2