Browse Source

[1258] added one more basic test for fromWire(): a bogus input with a trimmed RR.

JINMEI Tatuya 13 years ago
parent
commit
13e8bc43e4
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/lib/dns/tests/message_unittest.cc

+ 8 - 0
src/lib/dns/tests/message_unittest.cc

@@ -606,6 +606,14 @@ TEST_F(MessageTest, fromWire) {
     EXPECT_TRUE(it->isLast());
 }
 
+TEST_F(MessageTest, fromWireShortBuffer) {
+    // We trim a valid message (ending with an SOA RR) for one byte.
+    // fromWire() should throw an exception while parsing the trimmed RR.
+    UnitTestUtil::readWireData("message_fromWire22.wire", received_data);
+    InputBuffer buffer(&received_data[0], received_data.size() - 1);
+    EXPECT_THROW(message_parse.fromWire(buffer), InvalidBufferPosition);
+}
+
 TEST_F(MessageTest, fromWireCombineRRs) {
     // This message contains 3 RRs in the answer section in the order of
     // A, AAAA, A types.  fromWire() should combine the two A RRs into a