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_NotEnoughAddressData_IPv6) {
  char record[10000] = {};
  base::BigEndianWriter writer(record, sizeof(record));
  AppendWellFormedEsniKeys(&writer);
  std::vector<uint8_t> address_list;
  std::vector<IPAddress> addresses_for_validation_unused;
  AppendAnotherIPAddress(&address_list, &addresses_for_validation_unused, 6);
  writer.WriteU16(address_list.size() - 1 + 4);
  writer.WriteU16(EsniRecordRdata::kAddressSetExtensionType);
  writer.WriteU16(address_list.size() - 1);
  writer.WriteBytes(address_list.data(), address_list.size() - 1);
  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_NotEnoughAddressData_IPv6 ) { char record [ 10000 ] = { } ; base :: BigEndianWriter writer ( record , sizeof ( record ) ) ; AppendWellFormedEsniKeys ( & writer ) ; std :: vector < uint8_t > address_list ; std :: vector < IPAddress > addresses_for_validation_unused ; AppendAnotherIPAddress ( & address_list , & addresses_for_validation_unused , 6 ) ; writer . WriteU16 ( address_list . size ( ) - 1 + 4 ) ; writer . WriteU16 ( EsniRecordRdata :: kAddressSetExtensionType ) ; writer . WriteU16 ( address_list . size ( ) - 1 ) ; writer . WriteBytes ( address_list . data ( ) , address_list . size ( ) - 1 ) ; 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: 2 bytes for address type, 2 for address_set length // Subtract 1 because we're deliberately writing one byte too few for the // purposes of this test. // oops! missing the last byte of our IPv6 address /* offset */