Browse Source

[2094] (unrelated fix): DNAME RDATA shouldn't be compressed per RFC3597.

JINMEI Tatuya 12 years ago
parent
commit
7e1561912c

+ 3 - 1
src/lib/dns/rdata/generic/dname_39.cc

@@ -54,7 +54,9 @@ DNAME::toWire(OutputBuffer& buffer) const {
 
 
 void
 void
 DNAME::toWire(AbstractMessageRenderer& renderer) const {
 DNAME::toWire(AbstractMessageRenderer& renderer) const {
-    renderer.writeName(dname_);
+    // Type DNAME is not "well-known", and name compression must be disabled
+    // per RFC3597.
+    renderer.writeName(dname_, false);
 }
 }
 
 
 string
 string

+ 5 - 3
src/lib/dns/tests/rdata_dname_unittest.cc

@@ -45,9 +45,11 @@ const uint8_t wiredata_dname2[] = {
     // first name: dn.example.com.
     // first name: dn.example.com.
     0x02, 0x64, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x02, 0x64, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
     0x63, 0x6f, 0x6d, 0x00,
     0x63, 0x6f, 0x6d, 0x00,
-    // second name: dn2.example.com.  all labels except the first should be
-    // compressed.
-    0x03, 0x64, 0x6e, 0x32, 0xc0, 0x03 };
+    // second name: dn2.example.com.  The "example.com" shouldn't be compressed
+    // because DNAME is not a well know type per RFC3597.
+    0x03, 0x64, 0x6e, 0x32,
+    0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
+    0x63, 0x6f, 0x6d, 0x00 };
 
 
 TEST_F(Rdata_DNAME_Test, createFromText) {
 TEST_F(Rdata_DNAME_Test, createFromText) {
     EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com")));
     EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com")));