Skip to content

Commit 27ff60a

Browse files
author
Peter van Dijk
committed
make sure our NSEC(3)s for names with spaces in them are correct. Reported by Jimmy Bergman. Includes test. Needs additional recursor verification.
1 parent 51332c0 commit 27ff60a

File tree

8 files changed

+33
-1
lines changed

8 files changed

+33
-1
lines changed

pdns/dnsparser.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,13 @@ void PacketReader::xfrHexBlob(string& blob, bool keepReading)
502502
xfrBlob(blob);
503503
}
504504

505-
string simpleCompress(const string& label, const string& root)
505+
string simpleCompress(const string& elabel, const string& root)
506506
{
507+
string label=elabel;
508+
// FIXME: this relies on the semi-canonical escaped output from getLabelFromContent
509+
boost::replace_all(label, "\\.", ".");
510+
boost::replace_all(label, "\\032", " ");
511+
boost::replace_all(label, "\\\\", "\\");
507512
typedef vector<pair<unsigned int, unsigned int> > parts_t;
508513
parts_t parts;
509514
vstringtok(parts, label, ".");

pdns/dnswriter.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ void DNSPacketWriter::xfrLabel(const string& Label, bool compress)
237237

238238
if(unescaped) {
239239
string part(label.c_str() + i -> first, i->second - i->first);
240+
// FIXME: this relies on the semi-canonical escaped output from getLabelFromContent
240241
boost::replace_all(part, "\\.", ".");
241242
boost::replace_all(part, "\\032", " ");
242243
boost::replace_all(part, "\\\\", "\\");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
cleandig 'space name'.example.com A dnssec
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make sure we answer queries with spaces in the name correctly, including the
2+
right NSEC(3) records.

regression-tests/space-name/expected_result

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1 9fag9508oqu3m22qac0u5eqgg45v8cf0.example.com. IN NSEC3 86400 1 1 1 abcd 9FAG9508OQU3M22QAC0U5EQGG45V8CF2
2+
1 9fag9508oqu3m22qac0u5eqgg45v8cf0.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
3+
1 example.com. IN RRSIG 86400 SOA 8 2 100000 [expiry] [inception] [keytag] example.com. ...
4+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
5+
1 gl4qf9db2fkivonidgs9954bhkhpvviq.example.com. IN NSEC3 86400 1 1 1 abcd GL4QF9DB2FKIVONIDGS9954BHKHPVVIS
6+
1 gl4qf9db2fkivonidgs9954bhkhpvviq.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
7+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN NSEC3 86400 1 1 1 abcd VTNQ6OCN2VKUIV3NJU14OQTAEN2MT5SL NS SOA MX RRSIG DNSKEY NSEC3PARAM
8+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
9+
2 . IN OPT 32768
10+
Rcode: 3, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
11+
Reply to question for qname='space\032name.example.com.', qtype=A
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1 9f8hti7cc7oqnqjv84klnp89glqrss3r.example.com. IN NSEC3 86400 1 1 1 abcd 9FDAOFPLLN0FQFU9DP274GOU59QFHSLD A RRSIG
2+
1 9f8hti7cc7oqnqjv84klnp89glqrss3r.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
3+
1 example.com. IN RRSIG 86400 SOA 8 2 100000 [expiry] [inception] [keytag] example.com. ...
4+
1 example.com. IN SOA 86400 ns1.example.com. ahu.example.com. 2000081501 28800 7200 604800 86400
5+
1 gl3vilecelbsri6t44urj9lp6m5853mq.example.com. IN NSEC3 86400 1 1 1 abcd GL5I9VH027O95O1M3UTE1A8KR1TJ253D A RRSIG
6+
1 gl3vilecelbsri6t44urj9lp6m5853mq.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
7+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN NSEC3 86400 1 1 1 abcd VTP9NUQBEH436S7J0K8TI2A32MMKCUUL NS SOA MX RRSIG DNSKEY NSEC3PARAM
8+
1 vtnq6ocn2vkuiv3nju14oqtaen2mt5sk.example.com. IN RRSIG 86400 NSEC3 8 3 86400 [expiry] [inception] [keytag] example.com. ...
9+
2 . IN OPT 32768
10+
Rcode: 3, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
11+
Reply to question for qname='space\032name.example.com.', qtype=A

regression-tests/space-name/skip.nodnssec

Whitespace-only changes.

0 commit comments

Comments
 (0)