Index: net/dns/record_rdata_unittest.cc |
diff --git a/net/dns/record_rdata_unittest.cc b/net/dns/record_rdata_unittest.cc |
index c41e39aa5e6f3d186a69036a79d2a096e2345596..f26808cfa9e63bb578dbb84d564c8ae7446051e7 100644 |
--- a/net/dns/record_rdata_unittest.cc |
+++ b/net/dns/record_rdata_unittest.cc |
@@ -196,5 +196,41 @@ TEST(RecordRdataTest, ParseNsecRecord) { |
ASSERT_TRUE(record_obj->IsEqual(record_obj.get())); |
} |
+TEST(RecordRdataTest, CreateNsecRecordWithEmptyBitmapReturnsNull) { |
+ std::unique_ptr<NsecRecordRdata> record_obj; |
Ryan Sleevi
2016/07/06 17:48:25
STYLE: Keep this scoped closer to where it's used
|
+ |
+ // These are just the rdata portions of the DNS records, rather than complete |
+ // records, but it works well enough for this test. |
+ // This record has a bitmap that is 0 bytes long. |
+ const uint8_t record[] = {0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', |
+ 'l', 'e', 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x00}; |
+ |
+ DnsRecordParser parser(record, sizeof(record), 0); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
+ |
+ record_obj = NsecRecordRdata::Create(record_strpiece, parser); |
+ ASSERT_EQ(nullptr, record_obj); |
Ryan Sleevi
2016/07/06 17:48:25
ASSERT_FALSE(record_obj)
|
+} |
+ |
+TEST(RecordRdataTest, CreateNsecRecordWithOversizedBitmapReturnsNull) { |
+ std::unique_ptr<NsecRecordRdata> record_obj; |
+ |
+ // These are just the rdata portions of the DNS records, rather than complete |
+ // records, but it works well enough for this test. |
+ // This record has a bitmap that is 33 bytes long. The maximum size allowed by |
+ // RFC 3845, Section 2.1.2, is 32 bytes. |
+ const uint8_t record[] = { |
+ 0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+ DnsRecordParser parser(record, sizeof(record), 0); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
+ |
+ record_obj = NsecRecordRdata::Create(record_strpiece, parser); |
+ ASSERT_EQ(nullptr, record_obj); |
Ryan Sleevi
2016/07/06 17:48:25
ASSERT_FALSE(record_obj)
|
+} |
} // namespace net |