From: Kees Monshouwer Date: Sat, 20 Jul 2013 14:05:11 +0000 (+0200) Subject: no label compression for name in TSIG records X-Git-Tag: auth-3.3.1~34^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78fc378cfc84feb24e30e68b87e83695967d88cd;p=thirdparty%2Fpdns.git no label compression for name in TSIG records --- diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 0b2ed39cca..c4cf85c809 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -529,7 +529,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, 0xff, 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;