From f4d26b4f0b45417c1f90c8f12f6aeb90a32166b9 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Sat, 20 Jul 2013 16:05:11 +0200 Subject: [PATCH] no label compression for name in TSIG records --- pdns/dnssecinfra.cc | 6 +++--- pdns/dnswriter.cc | 10 +++++----- pdns/dnswriter.hh | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 82f76200f2..a417a3c158 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -475,7 +475,7 @@ string makeTSIGMessageFromTSIGPacket(const string& opacket, unsigned int tsigOff DNSPacketWriter dw(signVect, "", 0); if(!timersonly) { dw.xfrLabel(keyname, false); - dw.xfr16BitInt(0xff); // class + dw.xfr16BitInt(QClass::ANY); // class dw.xfr32BitInt(0); // TTL dw.xfrLabel(toLower(trc.d_algoName), false); } @@ -514,7 +514,7 @@ void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyn DNSPacketWriter dw(signVect, "", 0); if(!timersonly) { dw.xfrLabel(tsigkeyname, false); - dw.xfr16BitInt(0xff); // class + dw.xfr16BitInt(QClass::ANY); // class dw.xfr32BitInt(0); // TTL dw.xfrLabel(trc->d_algoName, false); } @@ -533,7 +533,7 @@ void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyn trc->d_mac = calculateMD5HMAC(tsigsecret, toSign); // d_trc->d_mac[0]++; // sabotage - pw.startRecord(tsigkeyname, QType::TSIG, 0, 0xff, DNSPacketWriter::ADDITIONAL); + pw.startRecord(tsigkeyname, QType::TSIG, 0, QClass::ANY, DNSPacketWriter::ADDITIONAL, false); trc->toPacket(pw); pw.commit(); } diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index b39fa1ca4a..cd30f37f2b 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -53,7 +53,7 @@ dnsheader* DNSPacketWriter::getHeader() return (dnsheader*)&*d_content.begin(); } -void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place) +void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place, bool compress) { if(!d_record.empty()) commit(); @@ -64,19 +64,19 @@ void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t t d_recordttl=ttl; d_recordplace=place; - d_stuff = 0; + d_stuff = 0; d_rollbackmarker=d_content.size(); - if(pdns_iequals(d_qname, d_recordqname)) { // don't do the whole label compression thing if we *know* we can get away with "see question" + if(compress && pdns_iequals(d_qname, d_recordqname)) { // don't do the whole label compression thing if we *know* we can get away with "see question" static unsigned char marker[2]={0xc0, 0x0c}; d_content.insert(d_content.end(), (const char *) &marker[0], (const char *) &marker[2]); } else { - xfrLabel(d_recordqname, true); + xfrLabel(d_recordqname, compress); d_content.insert(d_content.end(), d_record.begin(), d_record.end()); d_record.clear(); } - + d_stuff = sizeof(dnsrecordheader); // this is needed to get compressed label offsets right, the dnsrecordheader will be interspersed d_sor=d_content.size() + d_stuff; // start of real record } diff --git a/pdns/dnswriter.hh b/pdns/dnswriter.hh index 69bd88e538..6bed390c3a 100644 --- a/pdns/dnswriter.hh +++ b/pdns/dnswriter.hh @@ -50,7 +50,7 @@ public: /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - ANSWER, AUTHORITY, ADDITIONAL */ - void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER); + void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER, bool compress=true); /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */ typedef vector > optvect_t; -- 2.47.2