src/net/dns/record_rdata_unittest.cc
// Test that an ESNI record with an address_set entry of bad address
// type is correctly rejected.
Test that an ESNI record with an address_set entry of bad address
type is correctly rejected.
Test that an ESNI record with an address_set entry of bad address type is correctly rejected .
TEST(RecordRdataTest, EsniMalformedRecord_InvalidAddressType) {
  char record[10000] = {};
  base::BigEndianWriter writer(record, sizeof(record));
  AppendWellFormedEsniKeys(&writer);
  writer.WriteU16(9);  
  writer.WriteU16(EsniRecordRdata::kAddressSetExtensionType);
  std::vector<uint8_t> address_list;
  IPAddress ipv4;
  ASSERT_TRUE(net::ParseURLHostnameToAddress("192.168.1.1", &ipv4));
  address_list.push_back(5);  
  std::copy(ipv4.bytes().begin(), ipv4.bytes().end(),
            std::back_inserter(address_list));
  writer.WriteU16(address_list.size());
  writer.WriteBytes(address_list.data(), address_list.size());
  auto record_size = writer.ptr() - record;
  DnsRecordParser parser(record, record_size, 0 );
  std::unique_ptr<EsniRecordRdata> record_obj =
      EsniRecordRdata::Create(std::string(record, record_size), parser);
  ASSERT_THAT(record_obj, IsNull());
}
TEST ( RecordRdataTest , EsniMalformedRecord_InvalidAddressType ) { char record [ 10000 ] = { } ; base :: BigEndianWriter writer ( record , sizeof ( record ) ) ; AppendWellFormedEsniKeys ( & writer ) ; writer . WriteU16 ( 9 ) ; writer . WriteU16 ( EsniRecordRdata :: kAddressSetExtensionType ) ; std :: vector < uint8_t > address_list ; IPAddress ipv4 ; ASSERT_TRUE ( net :: ParseURLHostnameToAddress ( " " , & ipv4 ) ) ; address_list . push_back ( 5 ) ; std :: copy ( ipv4 . bytes ( ) . begin ( ) , ipv4 . bytes ( ) . end ( ) , std :: back_inserter ( address_list ) ) ; writer . WriteU16 ( address_list . size ( ) ) ; writer . WriteBytes ( address_list . data ( ) , address_list . size ( ) ) ; auto record_size = writer . ptr ( ) - record ; DnsRecordParser parser ( record , record_size , 0 ) ; std :: unique_ptr < EsniRecordRdata > record_obj = EsniRecordRdata :: Create ( std :: string ( record , record_size ) , parser ) ; ASSERT_THAT ( record_obj , IsNull ( ) ) ; }
Test that an ESNI record with an address_set entry of bad address
type is correctly rejected.
Test that an ESNI record with an address_set entry of bad address type is correctly rejected .
// dns_extensions length: two U16's and a 5-byte address // Oops! "5" isn't a valid AddressType. /* offset */