_ZN27ConcurrentConnectionManagerC2Em:
   30|      4|  {
   31|      4|    setMaxConcurrentConnections(max);
   32|      4|  }
_ZN27ConcurrentConnectionManager27setMaxConcurrentConnectionsEm:
   35|      4|  {
   36|      4|    d_data.lock()->d_maxConcurrentConnections = max;
   37|      4|  }

_ZN17dnsheader_aligned15isMemoryAlignedEPKv:
  227|  2.61k|  {
  228|  2.61k|    return reinterpret_cast<uintptr_t>(mem) % sizeof(uint32_t) == 0; // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
  229|  2.61k|  }

_ZN7dnsdist16DNSPacketOverlayC2ERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   29|  3.01k|{
   30|  3.01k|  if (packet.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (30:7): [True: 0, False: 3.01k]
  ------------------
   31|      0|    throw std::runtime_error("Packet is too small for a DNS packet");
   32|      0|  }
   33|       |
   34|  3.01k|  memcpy(&d_header, packet.data(), sizeof(dnsheader));
   35|  3.01k|  uint64_t supposedRecordCount = ntohs(d_header.ancount) + ntohs(d_header.nscount) + ntohs(d_header.arcount);
   36|       |  // No need to reserve more memory for more records than the request can
   37|       |  // contain. We could try to be smarter and actually count the records
   38|       |  // by doing getDnsrecordheader and skip the payload in a loop, but all
   39|       |  // we really want here is to avoid reserving too much memory in case of
   40|       |  // maliciously high record counts.
   41|  3.01k|  auto reserveRecordCount = std::min(1 + ((packet.size() - sizeof(dnsheader)) / sizeof(dnsrecordheader)), static_cast<size_t>(supposedRecordCount));
   42|  3.01k|  d_records.reserve(reserveRecordCount);
   43|       |
   44|  3.01k|  try {
   45|  3.01k|    PacketReader reader(std::string_view(reinterpret_cast<const char*>(packet.data()), packet.size()));
   46|       |
   47|  7.86k|    for (uint16_t idx = 0; idx < ntohs(d_header.qdcount); ++idx) {
  ------------------
  |  Branch (47:28): [True: 4.85k, False: 3.01k]
  ------------------
   48|  4.85k|      reader.xfrName(d_qname);
   49|  4.85k|      reader.xfrType(d_qtype);
   50|  4.85k|      reader.xfrType(d_qclass);
   51|  4.85k|    }
   52|       |
   53|  67.0k|    for (uint64_t idx = 0; idx < supposedRecordCount; ++idx) {
  ------------------
  |  Branch (53:28): [True: 64.0k, False: 3.01k]
  ------------------
   54|  64.0k|      Record rec;
   55|  64.0k|      reader.xfrName(rec.d_name);
   56|  64.0k|      rec.d_place = idx < ntohs(d_header.ancount) ? DNSResourceRecord::ANSWER : (idx < (ntohs(d_header.ancount) + ntohs(d_header.nscount)) ? DNSResourceRecord::AUTHORITY : DNSResourceRecord::ADDITIONAL);
  ------------------
  |  Branch (56:21): [True: 11.0k, False: 53.0k]
  |  Branch (56:82): [True: 12.7k, False: 40.3k]
  ------------------
   57|  64.0k|      reader.xfrType(rec.d_type);
   58|  64.0k|      reader.xfrType(rec.d_class);
   59|  64.0k|      reader.xfr32BitInt(rec.d_ttl);
   60|  64.0k|      reader.xfr16BitInt(rec.d_contentLength);
   61|  64.0k|      rec.d_contentOffset = reader.getPosition();
   62|  64.0k|      reader.skip(rec.d_contentLength);
   63|  64.0k|      d_records.push_back(std::move(rec));
   64|  64.0k|    }
   65|  3.01k|  }
   66|  3.01k|  catch (const std::exception& e) {
   67|  2.36k|    throw std::runtime_error("Unable to parse DNS packet: " + std::string(e.what()));
   68|  2.36k|  }
   69|  3.01k|  catch (...) {
   70|      0|    throw std::runtime_error("Unable to parse DNS packet");
   71|      0|  }
   72|  3.01k|}
_ZN7dnsdist21changeNameInDNSPacketERNSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEERK7DNSNameSA_:
   75|  2.38k|{
   76|  2.38k|  if (initialPacket.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (76:7): [True: 0, False: 2.38k]
  ------------------
   77|      0|    return false;
   78|      0|  }
   79|       |
   80|  2.38k|  PacketReader pr(std::string_view(reinterpret_cast<const char*>(initialPacket.data()), initialPacket.size()));
   81|       |
   82|  2.38k|  dnsheader dh;
   83|  2.38k|  memcpy(&dh, initialPacket.data(), sizeof(dh));
   84|  2.38k|  size_t idx = 0;
   85|  2.38k|  DNSName rrname;
   86|  2.38k|  uint16_t qdcount = ntohs(dh.qdcount);
   87|  2.38k|  uint16_t ancount = ntohs(dh.ancount);
   88|  2.38k|  uint16_t nscount = ntohs(dh.nscount);
   89|  2.38k|  uint16_t arcount = ntohs(dh.arcount);
   90|  2.38k|  uint16_t rrtype;
   91|  2.38k|  uint16_t rrclass;
   92|  2.38k|  string blob;
   93|       |
   94|  2.38k|  size_t recordsCount = ancount + nscount + arcount;
   95|  2.38k|  struct dnsrecordheader ah;
   96|       |
   97|  2.38k|  rrname = pr.getName();
   98|  2.38k|  if (rrname == from) {
  ------------------
  |  Branch (98:7): [True: 2.38k, False: 0]
  ------------------
   99|  2.38k|    rrname = to;
  100|  2.38k|  }
  101|       |
  102|  2.38k|  rrtype = pr.get16BitInt();
  103|  2.38k|  rrclass = pr.get16BitInt();
  104|       |
  105|  2.38k|  PacketBuffer newContent;
  106|  2.38k|  newContent.reserve(initialPacket.size());
  107|  2.38k|  GenericDNSPacketWriter<PacketBuffer> pw(newContent, rrname, rrtype, rrclass, dh.opcode);
  108|       |  /* we want to copy the flags and ID but not the counts since we recreate the records below */
  109|  2.38k|  pw.getHeader()->id = dh.id;
  110|  2.38k|  pw.getHeader()->qr = dh.qr;
  111|  2.38k|  pw.getHeader()->aa = dh.aa;
  112|  2.38k|  pw.getHeader()->tc = dh.tc;
  113|  2.38k|  pw.getHeader()->rd = dh.rd;
  114|  2.38k|  pw.getHeader()->ra = dh.ra;
  115|  2.38k|  pw.getHeader()->ad = dh.ad;
  116|  2.38k|  pw.getHeader()->cd = dh.cd;
  117|  2.38k|  pw.getHeader()->rcode = dh.rcode;
  118|       |
  119|       |  /* consume remaining qd if any, but do not copy it */
  120|  6.27k|  for (idx = 1; idx < qdcount; idx++) {
  ------------------
  |  Branch (120:17): [True: 3.89k, False: 2.38k]
  ------------------
  121|  3.89k|    rrname = pr.getName();
  122|  3.89k|    (void)pr.get16BitInt();
  123|  3.89k|    (void)pr.get16BitInt();
  124|  3.89k|  }
  125|       |
  126|  2.38k|  static const std::unordered_set<QType> nameOnlyTypes{QType::NS, QType::PTR, QType::CNAME, QType::DNAME};
  127|  2.38k|  static const std::unordered_set<QType> noNameTypes{QType::A, QType::AAAA, QType::DHCID, QType::TXT, QType::OPT, QType::HINFO, QType::DNSKEY, QType::CDNSKEY, QType::DS, QType::CDS, QType::DLV, QType::SSHFP, QType::KEY, QType::CERT, QType::TLSA, QType::SMIMEA, QType::OPENPGPKEY, QType::NSEC, QType::NSEC3, QType::CSYNC, QType::NSEC3PARAM, QType::LOC, QType::NID, QType::L32, QType::L64, QType::EUI48, QType::EUI64, QType::URI, QType::CAA};
  128|       |
  129|       |  /* copy AN, NS and AR */
  130|  67.8k|  for (idx = 0; idx < recordsCount; idx++) {
  ------------------
  |  Branch (130:17): [True: 66.8k, False: 994]
  ------------------
  131|  66.8k|    rrname = pr.getName();
  132|  66.8k|    if (rrname == from) {
  ------------------
  |  Branch (132:9): [True: 35.1k, False: 31.6k]
  ------------------
  133|  35.1k|      rrname = to;
  134|  35.1k|    }
  135|  66.8k|    pr.getDnsrecordheader(ah);
  136|       |
  137|  66.8k|    auto place = idx < ancount ? DNSResourceRecord::ANSWER : (idx < (ancount + nscount) ? DNSResourceRecord::AUTHORITY : DNSResourceRecord::ADDITIONAL);
  ------------------
  |  Branch (137:18): [True: 15.8k, False: 50.9k]
  |  Branch (137:63): [True: 18.8k, False: 32.1k]
  ------------------
  138|  66.8k|    pw.startRecord(rrname, ah.d_type, ah.d_ttl, ah.d_class, place, true);
  139|  66.8k|    if (nameOnlyTypes.count(ah.d_type)) {
  ------------------
  |  Branch (139:9): [True: 20.9k, False: 45.8k]
  ------------------
  140|  20.9k|      rrname = pr.getName();
  141|       |      // compression is not allowed for DNAME target per rfc6672 section 2.5
  142|  20.9k|      pw.xfrName(rrname, ah.d_type != QType::DNAME);
  143|  20.9k|    }
  144|  45.8k|    else if (noNameTypes.count(ah.d_type)) {
  ------------------
  |  Branch (144:14): [True: 37.6k, False: 8.16k]
  ------------------
  145|  37.6k|      pr.xfrBlob(blob);
  146|  37.6k|      pw.xfrBlob(blob);
  147|  37.6k|    }
  148|  8.16k|    else if (ah.d_type == QType::RRSIG) {
  ------------------
  |  Branch (148:14): [True: 2.22k, False: 5.94k]
  ------------------
  149|       |      /* good luck */
  150|  2.22k|      pr.xfrBlob(blob);
  151|  2.22k|      pw.xfrBlob(blob);
  152|  2.22k|    }
  153|  5.94k|    else if (ah.d_type == QType::MX) {
  ------------------
  |  Branch (153:14): [True: 2.27k, False: 3.67k]
  ------------------
  154|  2.27k|      auto prio = pr.get16BitInt();
  155|  2.27k|      rrname = pr.getName();
  156|  2.27k|      pw.xfr16BitInt(prio);
  157|  2.27k|      pw.xfrName(rrname, true);
  158|  2.27k|    }
  159|  3.67k|    else if (ah.d_type == QType::SOA) {
  ------------------
  |  Branch (159:14): [True: 1.13k, False: 2.53k]
  ------------------
  160|  1.13k|      auto mname = pr.getName();
  161|  1.13k|      pw.xfrName(mname, true);
  162|  1.13k|      auto rname = pr.getName();
  163|  1.13k|      pw.xfrName(rname, true);
  164|       |      /* serial */
  165|  1.13k|      pw.xfr32BitInt(pr.get32BitInt());
  166|       |      /* refresh */
  167|  1.13k|      pw.xfr32BitInt(pr.get32BitInt());
  168|       |      /* retry */
  169|  1.13k|      pw.xfr32BitInt(pr.get32BitInt());
  170|       |      /* expire */
  171|  1.13k|      pw.xfr32BitInt(pr.get32BitInt());
  172|       |      /* minimal */
  173|  1.13k|      pw.xfr32BitInt(pr.get32BitInt());
  174|  1.13k|    }
  175|  2.53k|    else if (ah.d_type == QType::SRV) {
  ------------------
  |  Branch (175:14): [True: 1.14k, False: 1.38k]
  ------------------
  176|       |      /* preference */
  177|  1.14k|      pw.xfr16BitInt(pr.get16BitInt());
  178|       |      /* weight */
  179|  1.14k|      pw.xfr16BitInt(pr.get16BitInt());
  180|       |      /* port */
  181|  1.14k|      pw.xfr16BitInt(pr.get16BitInt());
  182|  1.14k|      auto target = pr.getName();
  183|       |      /* Compression is not allowed per rfc2782:
  184|       |         "Unless and until permitted by future standards action,
  185|       |         name compression is not to be used for this field."
  186|       |      */
  187|  1.14k|      pw.xfrName(target, false);
  188|  1.14k|    }
  189|  1.38k|    else {
  190|       |      /* sorry, unsafe type */
  191|  1.38k|      return false;
  192|  1.38k|    }
  193|  66.8k|  }
  194|       |
  195|    994|  pw.commit();
  196|    994|  initialPacket = std::move(newContent);
  197|       |
  198|    994|  return true;
  199|  2.38k|}
_ZN7dnsdist14PacketMangling23editDNSHeaderFromPacketERNSt3__16vectorIh14noinit_adaptorINS1_9allocatorIhEEEEERKNS1_8functionIFbR9dnsheaderEEE:
  204|  2.61k|  {
  205|  2.61k|    if (packet.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (205:9): [True: 0, False: 2.61k]
  ------------------
  206|      0|      throw std::runtime_error("Trying to edit the DNS header of a too small packet");
  207|      0|    }
  208|       |
  209|  2.61k|    return editDNSHeaderFromRawPacket(packet.data(), editFunction);
  210|  2.61k|  }
_ZN7dnsdist14PacketMangling26editDNSHeaderFromRawPacketEPvRKNSt3__18functionIFbR9dnsheaderEEE:
  213|  2.61k|  {
  214|  2.61k|    if (dnsheader_aligned::isMemoryAligned(packet)) {
  ------------------
  |  Branch (214:9): [True: 2.61k, False: 0]
  ------------------
  215|       |      // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
  216|  2.61k|      auto* header = reinterpret_cast<dnsheader*>(packet);
  217|  2.61k|      return editFunction(*header);
  218|  2.61k|    }
  219|       |
  220|      0|    dnsheader header{};
  221|      0|    memcpy(&header, packet, sizeof(header));
  222|      0|    if (!editFunction(header)) {
  ------------------
  |  Branch (222:9): [True: 0, False: 0]
  ------------------
  223|      0|      return false;
  224|      0|    }
  225|      0|    memcpy(packet, &header, sizeof(header));
  226|      0|    return true;
  227|      0|  }
_ZN7dnsdist14PacketMangling21restrictDNSPacketTTLsERNSt3__16vectorIh14noinit_adaptorINS1_9allocatorIhEEEEEjjRKNS1_13unordered_setI5QTypeNS1_4hashISA_EENS1_8equal_toISA_EENS4_ISA_EEEE:
  230|  5.22k|  {
  231|  5.22k|    auto visitor = [minimumValue, maximumValue, types](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) {
  232|  5.22k|      (void)section;
  233|  5.22k|      if (!types.empty() && qclass == QClass::IN && types.count(qtype) == 0) {
  234|  5.22k|        return ttl;
  235|  5.22k|      }
  236|       |
  237|  5.22k|      if (minimumValue > 0) {
  238|  5.22k|        if (ttl < minimumValue) {
  239|  5.22k|          ttl = minimumValue;
  240|  5.22k|        }
  241|  5.22k|      }
  242|  5.22k|      if (ttl > maximumValue) {
  243|  5.22k|        ttl = maximumValue;
  244|  5.22k|      }
  245|  5.22k|      return ttl;
  246|  5.22k|    };
  247|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
  248|  5.22k|    editDNSPacketTTL(reinterpret_cast<char*>(packet.data()), packet.size(), visitor);
  249|  5.22k|  }
_ZN7dnsdist13RecordParsers18parseAddressRecordERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_16DNSPacketOverlay6RecordE:
  289|  11.9k|  {
  290|  11.9k|    if (record.d_type == QType::A && record.d_contentLength == 4) {
  ------------------
  |  Branch (290:9): [True: 1.92k, False: 10.0k]
  |  Branch (290:38): [True: 287, False: 1.63k]
  ------------------
  291|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  292|    287|      return makeComboAddressFromRaw(4, packet.substr(record.d_contentOffset, record.d_contentLength).data(), record.d_contentLength);
  293|    287|    }
  294|       |
  295|  11.6k|    if (record.d_type == QType::AAAA && record.d_contentLength == 16) {
  ------------------
  |  Branch (295:9): [True: 493, False: 11.1k]
  |  Branch (295:41): [True: 215, False: 278]
  ------------------
  296|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  297|    215|      return makeComboAddressFromRaw(6, packet.substr(record.d_contentOffset, record.d_contentLength).data(), record.d_contentLength);
  298|    215|    }
  299|       |
  300|  11.4k|    return {};
  301|  11.6k|  }
_ZN7dnsdist13RecordParsers16parseCNAMERecordERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_16DNSPacketOverlay6RecordE:
  304|  11.9k|  {
  305|  11.9k|    if (record.d_type != QType::CNAME) {
  ------------------
  |  Branch (305:9): [True: 4.86k, False: 7.11k]
  ------------------
  306|  4.86k|      return {};
  307|  4.86k|    }
  308|       |
  309|       |    // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  310|  7.11k|    return DNSName(packet.data(), record.d_contentOffset + record.d_contentLength, record.d_contentOffset, true);
  311|  11.9k|  }
dnsdist-dnsparser.cc:_ZZN7dnsdist14PacketMangling21restrictDNSPacketTTLsERNSt3__16vectorIh14noinit_adaptorINS1_9allocatorIhEEEEEjjRKNS1_13unordered_setI5QTypeNS1_4hashISA_EENS1_8equal_toISA_EENS4_ISA_EEEEENK3$_0clEhttj:
  231|   116k|    auto visitor = [minimumValue, maximumValue, types](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) {
  232|   116k|      (void)section;
  233|   116k|      if (!types.empty() && qclass == QClass::IN && types.count(qtype) == 0) {
  ------------------
  |  Branch (233:11): [True: 58.4k, False: 58.4k]
  |  Branch (233:11): [True: 840, False: 115k]
  |  Branch (233:29): [True: 1.41k, False: 56.9k]
  |  Branch (233:53): [True: 840, False: 576]
  ------------------
  234|    840|        return ttl;
  235|    840|      }
  236|       |
  237|   115k|      if (minimumValue > 0) {
  ------------------
  |  Branch (237:11): [True: 51.0k, False: 64.8k]
  ------------------
  238|  51.0k|        if (ttl < minimumValue) {
  ------------------
  |  Branch (238:13): [True: 13.3k, False: 37.7k]
  ------------------
  239|  13.3k|          ttl = minimumValue;
  240|  13.3k|        }
  241|  51.0k|      }
  242|   115k|      if (ttl > maximumValue) {
  ------------------
  |  Branch (242:11): [True: 83.0k, False: 32.8k]
  ------------------
  243|  83.0k|        ttl = maximumValue;
  244|  83.0k|      }
  245|   115k|      return ttl;
  246|   116k|    };

_ZN8DynBlockC2Ev:
   78|      4|  {
   79|      4|    until.tv_sec = 0;
   80|      4|    until.tv_nsec = 0;
   81|      4|  }

_ZN7dnsdist7metrics5StatsC2Ev:
   80|      2|  entries{std::vector<EntryTriple>{
   81|      2|    {"responses", "", &responses},
   82|      2|    {"servfail-responses", "", &servfailResponses},
   83|      2|    {"queries", "", &queries},
   84|      2|    {"frontend-nxdomain", "", &frontendNXDomain},
   85|      2|    {"frontend-servfail", "", &frontendServFail},
   86|      2|    {"frontend-noerror", "", &frontendNoError},
   87|      2|    {"acl-drops", "", &aclDrops},
   88|      2|    {"rule-drop", "", &ruleDrop},
   89|      2|    {"rule-nxdomain", "", &ruleNXDomain},
   90|      2|    {"rule-refused", "", &ruleRefused},
   91|      2|    {"rule-servfail", "", &ruleServFail},
   92|      2|    {"rule-truncated", "", &ruleTruncated},
   93|      2|    {"self-answered", "", &selfAnswered},
   94|      2|    {"downstream-timeouts", "", &downstreamTimeouts},
   95|      2|    {"downstream-send-errors", "", &downstreamSendErrors},
   96|      2|    {"trunc-failures", "", &truncFail},
   97|      2|    {"no-policy", "", &noPolicy},
   98|      2|    {"latency0-1", "", &latency0_1},
   99|      2|    {"latency1-10", "", &latency1_10},
  100|      2|    {"latency10-50", "", &latency10_50},
  101|      2|    {"latency50-100", "", &latency50_100},
  102|      2|    {"latency100-1000", "", &latency100_1000},
  103|      2|    {"latency-slow", "", &latencySlow},
  104|      2|    {"latency-avg100", "", &latencyAvg100},
  105|      2|    {"latency-avg1000", "", &latencyAvg1000},
  106|      2|    {"latency-avg10000", "", &latencyAvg10000},
  107|      2|    {"latency-avg1000000", "", &latencyAvg1000000},
  108|      2|    {"latency-tcp-avg100", "", &latencyTCPAvg100},
  109|      2|    {"latency-tcp-avg1000", "", &latencyTCPAvg1000},
  110|      2|    {"latency-tcp-avg10000", "", &latencyTCPAvg10000},
  111|      2|    {"latency-tcp-avg1000000", "", &latencyTCPAvg1000000},
  112|      2|    {"latency-dot-avg100", "", &latencyDoTAvg100},
  113|      2|    {"latency-dot-avg1000", "", &latencyDoTAvg1000},
  114|      2|    {"latency-dot-avg10000", "", &latencyDoTAvg10000},
  115|      2|    {"latency-dot-avg1000000", "", &latencyDoTAvg1000000},
  116|      2|    {"latency-doh-avg100", "", &latencyDoHAvg100},
  117|      2|    {"latency-doh-avg1000", "", &latencyDoHAvg1000},
  118|      2|    {"latency-doh-avg10000", "", &latencyDoHAvg10000},
  119|      2|    {"latency-doh-avg1000000", "", &latencyDoHAvg1000000},
  120|      2|    {"latency-doq-avg100", "", &latencyDoQAvg100},
  121|      2|    {"latency-doq-avg1000", "", &latencyDoQAvg1000},
  122|      2|    {"latency-doq-avg10000", "", &latencyDoQAvg10000},
  123|      2|    {"latency-doq-avg1000000", "", &latencyDoQAvg1000000},
  124|      2|    {"latency-doh3-avg100", "", &latencyDoH3Avg100},
  125|      2|    {"latency-doh3-avg1000", "", &latencyDoH3Avg1000},
  126|      2|    {"latency-doh3-avg10000", "", &latencyDoH3Avg10000},
  127|      2|    {"latency-doh3-avg1000000", "", &latencyDoH3Avg1000000},
  128|      2|    {"uptime", "", uptimeOfProcess},
  129|      2|    {"real-memory-usage", "", getRealMemoryUsage},
  130|      2|    {"special-memory-usage", "", getSpecialMemoryUsage},
  131|      2|    {"udp-in-errors", "", [](const std::string&) { return udpErrorStats("udp-in-errors"); }},
  132|      2|    {"udp-noport-errors", "", [](const std::string&) { return udpErrorStats("udp-noport-errors"); }},
  133|      2|    {"udp-recvbuf-errors", "", [](const std::string&) { return udpErrorStats("udp-recvbuf-errors"); }},
  134|      2|    {"udp-sndbuf-errors", "", [](const std::string&) { return udpErrorStats("udp-sndbuf-errors"); }},
  135|      2|    {"udp-in-csum-errors", "", [](const std::string&) { return udpErrorStats("udp-in-csum-errors"); }},
  136|      2|    {"udp6-in-errors", "", [](const std::string&) { return udp6ErrorStats("udp6-in-errors"); }},
  137|      2|    {"udp6-recvbuf-errors", "", [](const std::string&) { return udp6ErrorStats("udp6-recvbuf-errors"); }},
  138|      2|    {"udp6-sndbuf-errors", "", [](const std::string&) { return udp6ErrorStats("udp6-sndbuf-errors"); }},
  139|      2|    {"udp6-noport-errors", "", [](const std::string&) { return udp6ErrorStats("udp6-noport-errors"); }},
  140|      2|    {"udp6-in-csum-errors", "", [](const std::string&) { return udp6ErrorStats("udp6-in-csum-errors"); }},
  141|      2|    {"tcp-listen-overflows", "", [](const std::string&) { return tcpErrorStats("ListenOverflows"); }},
  142|      2|    {"noncompliant-queries", "", &nonCompliantQueries},
  143|      2|    {"noncompliant-responses", "", &nonCompliantResponses},
  144|      2|    {"proxy-protocol-invalid", "", &proxyProtocolInvalid},
  145|      2|    {"rdqueries", "", &rdQueries},
  146|      2|    {"empty-queries", "", &emptyQueries},
  147|      2|    {"cache-hits", "", &cacheHits},
  148|      2|    {"cache-misses", "", &cacheMisses},
  149|      2|    {"cpu-iowait", "", getCPUIOWait},
  150|      2|    {"cpu-steal", "", getCPUSteal},
  151|      2|    {"cpu-sys-msec", "", getCPUTimeSystem},
  152|      2|    {"cpu-user-msec", "", getCPUTimeUser},
  153|      2|    {"fd-usage", "", getOpenFileDescriptors},
  154|      2|    {"dyn-blocked", "", &dynBlocked},
  155|      2|#ifndef DISABLE_DYNBLOCKS
  156|      2|    {"dyn-block-nmg-size", "", [](const std::string&) { return dnsdist::DynamicBlocks::getClientAddressDynamicRules().size(); }},
  157|      2|#endif /* DISABLE_DYNBLOCKS */
  158|      2|    {"security-status", "", &securityStatus},
  159|      2|    {"doh-query-pipe-full", "", &dohQueryPipeFull},
  160|      2|    {"doh-response-pipe-full", "", &dohResponsePipeFull},
  161|      2|    {"doq-response-pipe-full", "", &doqResponsePipeFull},
  162|      2|    {"doh3-response-pipe-full", "", &doh3ResponsePipeFull},
  163|      2|    {"outgoing-doh-query-pipe-full", "", &outgoingDoHQueryPipeFull},
  164|      2|    {"tcp-query-pipe-full", "", &tcpQueryPipeFull},
  165|      2|    {"tcp-cross-protocol-query-pipe-full", "", &tcpCrossProtocolQueryPipeFull},
  166|      2|    {"tcp-cross-protocol-response-pipe-full", "", &tcpCrossProtocolResponsePipeFull},
  167|       |    // Latency histogram
  168|      2|    {"latency-sum", "", &latencySum},
  169|      2|    {"latency-count", "", &latencyCount},
  170|      2|  }}
  171|      2|{
  172|      2|}

_ZN16MetricDefinitionC2E20PrometheusMetricTypeRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_:
   51|    162|    description(_description), customName(customName_), prometheusType(_prometheusType)
   52|    162|  {
   53|    162|  }

_ZN7dnsdist10QueryCount13ConfigurationC2Ev:
   39|      2|  Configuration() = default;

_ZN7dnsdist3udp22UDPTCPCrossQuerySenderC2Ev:
   77|      2|  UDPTCPCrossQuerySender() = default;

_ZN7DNSNameC2ENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEE:
   77|  2.41k|{
   78|  2.41k|  if (content.empty() || (content.size() == 1 && content.at(0) == '.')) {
  ------------------
  |  Branch (78:7): [True: 0, False: 2.41k]
  |  Branch (78:27): [True: 6, False: 2.40k]
  |  Branch (78:50): [True: 4, False: 2]
  ------------------
   79|      4|    d_storage.assign(1U, '\0');
   80|      4|    return;
   81|      4|  }
   82|       |
   83|  2.40k|  if (std::memchr(content.data(), '\\', content.size()) != nullptr) {
  ------------------
  |  Branch (83:7): [True: 0, False: 2.40k]
  ------------------
   84|      0|    d_storage = segmentDNSNameRaw(content.data(), content.size());
   85|      0|    if (d_storage.size() > s_maxDNSNameLength) {
  ------------------
  |  Branch (85:9): [True: 0, False: 0]
  ------------------
   86|      0|      throwSafeRangeError("name too long: ", content);
   87|      0|    }
   88|      0|    return;
   89|      0|  }
   90|       |
   91|  2.40k|  unsigned char lenpos = 0;
   92|  2.40k|  unsigned char labellen = 0;
   93|       |
   94|  2.40k|  d_storage.reserve(content.size() + 1U);
   95|  7.20k|  for (size_t position = 0; position < content.size(); ) {
  ------------------
  |  Branch (95:29): [True: 4.80k, False: 2.40k]
  ------------------
   96|  4.80k|    lenpos = d_storage.size();
   97|  4.80k|    if (content.at(position) == '.') {
  ------------------
  |  Branch (97:9): [True: 0, False: 4.80k]
  ------------------
   98|      0|      throwSafeRangeError("Found . in wrong position in DNSName: ", content);
   99|      0|    }
  100|  4.80k|    d_storage.append(1U, '\0');
  101|  4.80k|    labellen = 0;
  102|  4.80k|    size_t begPosition = position;
  103|  78.9k|    for(; position < content.size() && content.at(position) != '.'; ++position) {
  ------------------
  |  Branch (103:11): [True: 78.9k, False: 26]
  |  Branch (103:40): [True: 74.1k, False: 4.77k]
  ------------------
  104|  74.1k|      labellen++;
  105|  74.1k|    }
  106|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  107|  4.80k|    d_storage.append(content.begin() + begPosition, content.begin() + position);
  108|  4.80k|    if (position < content.size()) {
  ------------------
  |  Branch (108:9): [True: 4.77k, False: 26]
  ------------------
  109|  4.77k|      ++position;
  110|  4.77k|    }
  111|  4.80k|    if (labellen > s_maxDNSLabelLength) {
  ------------------
  |  Branch (111:9): [True: 0, False: 4.80k]
  ------------------
  112|      0|      throwSafeRangeError("label too long to append: ", content);
  113|      0|    }
  114|       |
  115|  4.80k|    if (position > s_maxDNSNameLength - 1U) {
  ------------------
  |  Branch (115:9): [True: 0, False: 4.80k]
  ------------------
  116|       |      // reserve two bytes, one for length and one for the root label
  117|      0|      throwSafeRangeError("name too long to append: ", content);
  118|      0|    }
  119|       |
  120|  4.80k|    d_storage.at(lenpos) = static_cast<char>(labellen);
  121|  4.80k|  }
  122|  2.40k|  if (d_storage.size() > s_maxDNSNameLength - 1U) {
  ------------------
  |  Branch (122:7): [True: 0, False: 2.40k]
  ------------------
  123|      0|    throwSafeRangeError("name too long: ", content);
  124|      0|  }
  125|  2.40k|  d_storage.append(1U, '\0');
  126|  2.40k|}
_ZN7DNSNameC2EPKcmmbPtS2_PjtPm:
  129|   178k|{
  130|   178k|  if (offset >= len)
  ------------------
  |  Branch (130:7): [True: 646, False: 177k]
  ------------------
  131|    646|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  132|       |
  133|   177k|  if(!uncompress) {
  ------------------
  |  Branch (133:6): [True: 2.55k, False: 175k]
  ------------------
  134|  2.55k|    if(const void * fnd=memchr(pos+offset, 0, len-offset)) {
  ------------------
  |  Branch (134:21): [True: 2.46k, False: 84]
  ------------------
  135|  2.46k|      d_storage.reserve(2+(const char*)fnd-(pos+offset));
  136|  2.46k|    }
  137|  2.55k|  }
  138|       |
  139|   177k|  packetParser(pos, len, offset, uncompress, qtype, qclass, consumed, 0, minOffset, 0, pointerBudget);
  140|   177k|}
_ZN7DNSName23parsePacketUncompressedERKN4pdns5views16UnsignedCharViewEmb:
  154|   229k|{
  155|   229k|  const size_t initialPos = pos;
  156|   229k|  auto existingSize = d_storage.size();
  157|   229k|  const size_t neededSizeForFinalLabel = /* final empty label length */ (existingSize == 0 ? 1U : 0U);
  ------------------
  |  Branch (157:74): [True: 221k, False: 7.92k]
  ------------------
  158|   229k|  size_t totalLength = 0;
  159|   229k|  unsigned char labellen = 0;
  160|       |
  161|  2.05M|  do {
  162|  2.05M|    labellen = view.at(pos);
  163|  2.05M|    ++pos;
  164|       |
  165|  2.05M|    if (labellen == 0) {
  ------------------
  |  Branch (165:9): [True: 176k, False: 1.88M]
  ------------------
  166|   176k|      --pos;
  167|   176k|      break;
  168|   176k|    }
  169|       |
  170|  1.88M|    if (labellen >= 0xc0) {
  ------------------
  |  Branch (170:9): [True: 52.8k, False: 1.82M]
  ------------------
  171|  52.8k|      if (!uncompress) {
  ------------------
  |  Branch (171:11): [True: 75, False: 52.8k]
  ------------------
  172|     75|        throw std::range_error("Found compressed label, instructed not to follow");
  173|     75|      }
  174|  52.8k|      --pos;
  175|  52.8k|      break;
  176|  52.8k|    }
  177|       |
  178|  1.82M|    if ((labellen & 0xc0) != 0) {
  ------------------
  |  Branch (178:9): [True: 226, False: 1.82M]
  ------------------
  179|    226|      throw std::range_error("Found an invalid label length in qname (only one of the first two bits is set)");
  180|    226|    }
  181|  1.82M|    checkLabelLength(labellen);
  182|       |
  183|       |    // reserve one byte for the label length, plus one byte for the final empty label if we were empty before
  184|  1.82M|    if ((existingSize + totalLength + labellen + 1U + neededSizeForFinalLabel) > s_maxDNSNameLength) {
  ------------------
  |  Branch (184:9): [True: 39, False: 1.82M]
  ------------------
  185|     39|      throw std::range_error("name too long to append");
  186|     39|    }
  187|  1.82M|    if (pos + labellen >= view.size()) {
  ------------------
  |  Branch (187:9): [True: 207, False: 1.82M]
  ------------------
  188|    207|      throw std::range_error("Found an invalid label length in qname");
  189|    207|    }
  190|  1.82M|    pos += labellen;
  191|  1.82M|    totalLength += 1U + labellen;
  192|  1.82M|  }
  193|  1.82M|  while (pos < view.size());
  ------------------
  |  Branch (193:10): [True: 1.82M, False: 0]
  ------------------
  194|       |
  195|   229k|  if (totalLength != 0) {
  ------------------
  |  Branch (195:7): [True: 85.9k, False: 143k]
  ------------------
  196|  85.9k|    if (existingSize > 0) {
  ------------------
  |  Branch (196:9): [True: 5.51k, False: 80.4k]
  ------------------
  197|       |      // remove the last label count, we are about to override it */
  198|  5.51k|      --existingSize;
  199|  5.51k|    }
  200|  85.9k|    if ((existingSize + totalLength + 1U) > s_maxDNSNameLength) {
  ------------------
  |  Branch (200:9): [True: 0, False: 85.9k]
  ------------------
  201|      0|      throw std::range_error("name too long to append");
  202|      0|    }
  203|  85.9k|    d_storage.reserve(existingSize + totalLength + 1);
  204|  85.9k|    d_storage.resize(existingSize + totalLength);
  205|  85.9k|    memcpy(&d_storage.at(existingSize), &view.at(initialPos), totalLength);
  206|  85.9k|    d_storage.append(1, static_cast<char>(0));
  207|  85.9k|  }
  208|   229k|  return pos;
  209|   229k|}
_ZN7DNSName12packetParserEPKcmmbPtS2_PjittPm:
  213|   229k|{
  214|   229k|  if (offset >= len) {
  ------------------
  |  Branch (214:7): [True: 0, False: 229k]
  ------------------
  215|      0|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  216|      0|  }
  217|       |
  218|   229k|  if (offset < static_cast<size_t>(minOffset)) {
  ------------------
  |  Branch (218:7): [True: 0, False: 229k]
  ------------------
  219|      0|    throw std::range_error("Trying to read before the beginning of the buffer ("+std::to_string(offset)+ " < "+std::to_string(minOffset)+")");
  220|      0|  }
  221|   229k|  unsigned char labellen{0};
  222|       |
  223|   229k|  pdns::views::UnsignedCharView view(qpos, len);
  224|   229k|  auto pos = parsePacketUncompressed(view, offset, uncompress);
  225|       |
  226|       |
  227|   229k|  labellen = view.at(pos);
  228|   229k|  if (pos == offset && labellen != 0) {
  ------------------
  |  Branch (228:7): [True: 143k, False: 86.5k]
  |  Branch (228:24): [True: 45.1k, False: 98.1k]
  ------------------
  229|       |    // It's a pointer
  230|  45.1k|    if (pointerBudget != nullptr) {
  ------------------
  |  Branch (230:9): [True: 44.4k, False: 736]
  ------------------
  231|  44.4k|      if (*pointerBudget == 0) {
  ------------------
  |  Branch (231:11): [True: 0, False: 44.4k]
  ------------------
  232|      0|        throw std::range_error("Too many compression pointers processed in packet");
  233|      0|      }
  234|  44.4k|      (*pointerBudget)--;
  235|  44.4k|    }
  236|       |    // Are we chasing a pointer chain already for this name?
  237|  45.1k|    if (pointerChainLength++ > s_maxPointersToPointers) {
  ------------------
  |  Branch (237:9): [True: 3, False: 45.1k]
  ------------------
  238|      3|      throw std::range_error("Too many pointer to pointers during decompression (" + std::to_string(pointerChainLength) + ")");
  239|      3|    }
  240|  45.1k|  }
  241|   184k|  else {
  242|   184k|    pointerChainLength = 0; // not an immediate pointer to pointer case any more
  243|   184k|  }
  244|   229k|  pos++;
  245|   229k|  if (labellen != 0 && pos < view.size()) {
  ------------------
  |  Branch (245:7): [True: 52.8k, False: 177k]
  |  Branch (245:24): [True: 52.4k, False: 334]
  ------------------
  246|  52.4k|    if (labellen < 0xc0) {
  ------------------
  |  Branch (246:9): [True: 0, False: 52.4k]
  ------------------
  247|      0|      throw std::range_error("Invalid label byte during decompression ("+std::to_string(labellen)+")");
  248|      0|    }
  249|       |
  250|  52.4k|    if (!uncompress) {
  ------------------
  |  Branch (250:9): [True: 0, False: 52.4k]
  ------------------
  251|      0|      throw std::range_error("Found compressed label, instructed not to follow");
  252|      0|    }
  253|       |
  254|  52.4k|    labellen &= (~0xc0);
  255|  52.4k|    size_t newpos = (labellen << 8) + view.at(pos);
  256|       |
  257|  52.4k|    if (newpos >= offset) {
  ------------------
  |  Branch (257:9): [True: 270, False: 52.1k]
  ------------------
  258|    270|      throw std::range_error("Found a forward reference during label decompression");
  259|    270|    }
  260|       |
  261|  52.1k|    if (newpos < minOffset) {
  ------------------
  |  Branch (261:9): [True: 22, False: 52.1k]
  ------------------
  262|     22|      throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
  263|     22|    }
  264|       |
  265|  52.1k|    if (++depth > s_maxPointersPerName) {
  ------------------
  |  Branch (265:9): [True: 3, False: 52.1k]
  ------------------
  266|      3|      throw std::range_error("Abort label decompression after too many redirects (" + std::to_string(depth) + ")");
  267|      3|    }
  268|       |
  269|  52.1k|    packetParser(qpos, len, newpos, true, nullptr, nullptr, nullptr, depth, minOffset, pointerChainLength, pointerBudget);
  270|       |
  271|  52.1k|    pos++;
  272|  52.1k|  }
  273|       |
  274|   229k|  if (d_storage.empty()) {
  ------------------
  |  Branch (274:7): [True: 96.4k, False: 133k]
  ------------------
  275|  96.4k|    d_storage.append(1, static_cast<char>(0)); // we just parsed the root
  276|  96.4k|  }
  277|       |
  278|   229k|  if (consumed != nullptr) {
  ------------------
  |  Branch (278:7): [True: 169k, False: 59.8k]
  ------------------
  279|   169k|    *consumed = pos - offset;
  280|   169k|  }
  281|       |
  282|   229k|  if (qtype != nullptr) {
  ------------------
  |  Branch (282:7): [True: 0, False: 229k]
  ------------------
  283|      0|    if (pos + 2 > view.size()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|      throw std::range_error("Trying to read qtype past the end of the buffer ("+std::to_string(pos + 2)+ " > "+std::to_string(len)+")");
  285|      0|    }
  286|      0|    *qtype = view.at(pos)*256 + view.at(pos+1);
  287|      0|  }
  288|       |
  289|   229k|  pos += 2;
  290|   229k|  if (qclass != nullptr) {
  ------------------
  |  Branch (290:7): [True: 0, False: 229k]
  ------------------
  291|      0|    if (pos + 2 > view.size()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|      throw std::range_error("Trying to read qclass past the end of the buffer ("+std::to_string(pos + 2)+ " > "+std::to_string(len)+")");
  293|      0|    }
  294|      0|    *qclass = view.at(pos)*256 + view.at(pos+1);
  295|      0|  }
  296|   229k|}
_ZNK7DNSName10wirelengthEv:
  367|  2.28k|size_t DNSName::wirelength() const {
  368|  2.28k|  return d_storage.length();
  369|  2.28k|}
dnsname.cc:_ZL16checkLabelLengthh:
  143|  1.82M|{
  144|  1.82M|  if (length == 0) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.82M]
  ------------------
  145|      0|    throw std::range_error("no such thing as an empty label to append");
  146|      0|  }
  147|  1.82M|  if (length > DNSName::s_maxDNSLabelLength) {
  ------------------
  |  Branch (147:7): [True: 0, False: 1.82M]
  ------------------
  148|      0|    throw std::range_error("label too long to append");
  149|      0|  }
  150|  1.82M|}

_Z11dns_tolowerh:
   58|  3.41M|{
   59|  3.41M|  return dns_tolower_table[chr];
   60|  3.41M|}
_Z39pdns_ilexicographical_compare_three_wayNSt3__117basic_string_viewIcNS_11char_traitsIcEEEES3_:
   64|   113k|{
   65|   113k|  const unsigned char *aPtr = (const unsigned char*)a.data(), *bPtr = (const unsigned char*)b.data();
   66|   113k|  const unsigned char *aEptr = aPtr + a.length(), *bEptr = bPtr + b.length();
   67|   580k|  while(aPtr != aEptr && bPtr != bEptr) {
  ------------------
  |  Branch (67:9): [True: 487k, False: 93.1k]
  |  Branch (67:26): [True: 487k, False: 0]
  ------------------
   68|   487k|    if (*aPtr != *bPtr) {
  ------------------
  |  Branch (68:9): [True: 20.2k, False: 466k]
  ------------------
   69|  20.2k|      if (int rc = dns_tolower(*aPtr) - dns_tolower(*bPtr); rc != 0) {
  ------------------
  |  Branch (69:61): [True: 20.0k, False: 208]
  ------------------
   70|  20.0k|        return rc;
   71|  20.0k|      }
   72|  20.2k|    }
   73|   467k|    aPtr++;
   74|   467k|    bPtr++;
   75|   467k|  }
   76|       |  // At this point, one of the strings has been completely processed.
   77|       |  // Either both have the same length, and they are equal, or one of them
   78|       |  // is larger, and compares as higher.
   79|  93.1k|  if (aPtr == aEptr) {
  ------------------
  |  Branch (79:7): [True: 93.1k, False: 0]
  ------------------
   80|  93.1k|    if (bPtr != bEptr) {
  ------------------
  |  Branch (80:9): [True: 0, False: 93.1k]
  ------------------
   81|      0|      return -1; // a < b
   82|      0|    }
   83|  93.1k|  }
   84|      0|  else {
   85|      0|    return 1; // a > b
   86|      0|  }
   87|  93.1k|  return 0; // a == b
   88|  93.1k|}
_ZN7DNSNameaSERKS_:
  151|  37.5k|  {
  152|  37.5k|    if (this != &rhs) {
  ------------------
  |  Branch (152:9): [True: 37.5k, False: 0]
  ------------------
  153|  37.5k|      d_storage = rhs.d_storage;
  154|  37.5k|    }
  155|  37.5k|    return *this;
  156|  37.5k|  }
_ZN7DNSNameaSEOS_:
  158|   164k|  {
  159|   164k|    if (this != &rhs) {
  ------------------
  |  Branch (159:9): [True: 164k, False: 0]
  ------------------
  160|   164k|      d_storage = std::move(rhs.d_storage);
  161|   164k|    }
  162|   164k|    return *this;
  163|   164k|  }
_ZNK7DNSName5emptyEv:
  210|   322k|  bool empty() const { return d_storage.empty(); }
_ZNK7DNSName6isRootEv:
  211|   125k|  bool isRoot() const { return d_storage.size()==1 && d_storage[0]==0; }
  ------------------
  |  Branch (211:32): [True: 9.98k, False: 115k]
  |  Branch (211:55): [True: 9.98k, False: 0]
  ------------------
_ZNK7DNSName10getStorageEv:
  261|  99.7k|  const string_t& getStorage() const {
  262|  99.7k|    return d_storage;
  263|  99.7k|  }
_ZNK7DNSNameeqERKS_:
  826|   131k|{
  827|   131k|  if (rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size()) {
  ------------------
  |  Branch (827:7): [True: 0, False: 131k]
  |  Branch (827:33): [True: 57.9k, False: 73.5k]
  ------------------
  828|  57.9k|    return false;
  829|  57.9k|  }
  830|       |
  831|  73.5k|  const auto* us = d_storage.cbegin();
  832|  73.5k|  const auto* p = rhs.d_storage.cbegin();
  833|  1.75M|  for (; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) {
  ------------------
  |  Branch (833:10): [True: 1.68M, False: 72.4k]
  |  Branch (833:36): [True: 1.68M, False: 0]
  ------------------
  834|  1.68M|    if (dns_tolower(*p) != dns_tolower(*us)) {
  ------------------
  |  Branch (834:9): [True: 1.14k, False: 1.68M]
  ------------------
  835|  1.14k|      return false;
  836|  1.14k|    }
  837|  1.68M|  }
  838|  72.4k|  return true;
  839|  73.5k|}
_ZN7DNSNameC2ERKS_:
  164|  2.28k|  DNSName(const DNSName& a) = default;
_ZN7DNSNameC2EOS_:
  165|  69.1k|  DNSName(DNSName&& a) = default;
_ZN7DNSNameC2Ev:
  148|  69.4k|  DNSName() = default; //!< Constructs an *empty* DNSName, NOT the root!
_ZN15SuffixMatchTreeI8DynBlockEC2ENSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEb:
  465|      2|    d_name(std::move(name)), endNode(endNode_)
  466|      2|  {}

_ZN12PacketReader18getDnsrecordheaderER15dnsrecordheader:
  480|  66.2k|{
  481|  66.2k|  unsigned char *p = reinterpret_cast<unsigned char*>(&ah);
  482|       |
  483|   726k|  for(unsigned int n = 0; n < sizeof(dnsrecordheader); ++n) {
  ------------------
  |  Branch (483:27): [True: 660k, False: 66.2k]
  ------------------
  484|   660k|    p[n] = d_content.at(d_pos++);
  485|   660k|  }
  486|       |
  487|  66.2k|  ah.d_type = ntohs(ah.d_type);
  488|  66.2k|  ah.d_class = ntohs(ah.d_class);
  489|  66.2k|  ah.d_clen = ntohs(ah.d_clen);
  490|  66.2k|  ah.d_ttl = ntohl(ah.d_ttl);
  491|       |
  492|  66.2k|  d_startrecordpos = d_pos; // needed for getBlob later on
  493|  66.2k|  d_recordlen = ah.d_clen;
  494|  66.2k|  if (d_pos > d_content.size() || (d_content.size() - d_pos) < (d_recordlen)) {
  ------------------
  |  Branch (494:7): [True: 363, False: 65.9k]
  |  Branch (494:35): [True: 119, False: 65.7k]
  ------------------
  495|    119|    throw std::out_of_range("DNS record length (" + std::to_string(d_recordlen) + " starting at " + std::to_string(d_pos) + ") goes beyond the packet's content (" + std::to_string(d_content.size()) + ")");
  496|    119|  }
  497|  66.2k|}
_ZN12PacketReader11get32BitIntEv:
  565|  68.6k|{
  566|  68.6k|  uint32_t ret=0;
  567|  68.6k|  if (!isWithinRecordBoundaries(d_pos, d_pos + sizeof(ret))) {
  ------------------
  |  Branch (567:7): [True: 140, False: 68.4k]
  ------------------
  568|    140|    throw std::out_of_range("Attempt to read 32 bit value outside of record");
  569|    140|  }
  570|  68.4k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  571|  68.4k|  ret<<=8;
  572|  68.4k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  573|  68.4k|  ret<<=8;
  574|  68.4k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  575|  68.4k|  ret<<=8;
  576|  68.4k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  577|       |
  578|  68.4k|  return ret;
  579|  68.6k|}
_ZN12PacketReader11get16BitIntEv:
  583|   217k|{
  584|   217k|  uint16_t ret=0;
  585|   217k|  if (!isWithinRecordBoundaries(d_pos, d_pos + sizeof(ret))) {
  ------------------
  |  Branch (585:7): [True: 53, False: 217k]
  ------------------
  586|     53|    throw std::out_of_range("Attempt to read 16 bit value outside of record");
  587|     53|  }
  588|   217k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  589|   217k|  ret<<=8;
  590|   217k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  591|       |
  592|   217k|  return ret;
  593|   217k|}
_ZN12PacketReader7getNameEv:
  604|   168k|{
  605|   168k|  unsigned int consumed{0};
  606|   168k|  const auto initialPosition = d_pos;
  607|   168k|  try {
  608|   168k|    uint16_t minOffset = d_standalone ? 0 : sizeof(dnsheader);
  ------------------
  |  Branch (608:26): [True: 0, False: 168k]
  ------------------
  609|   168k|    bool uncompress = !d_standalone;
  610|       |
  611|   168k|    DNSName name((const char*) d_content.data(), d_content.size(), d_pos, uncompress, nullptr /* qtype */, nullptr /* qclass */, &consumed, minOffset, &d_pointerBudget);
  612|       |
  613|   168k|    d_pos += consumed;
  614|       |    // if we know the length of the record, and we were parsing a DNS name inside the record contents
  615|       |    // (not the owner name, in which case d_startrecordpos and d_recordlen still refer to the content of the previous record),
  616|       |    // check that we did not go over the record boundary
  617|   168k|    if (!isWithinRecordBoundaries(initialPosition, d_pos, true)) {
  ------------------
  |  Branch (617:9): [True: 18, False: 168k]
  ------------------
  618|     18|      throw std::out_of_range("Attempt to read DNS name outside of record");
  619|     18|    }
  620|   168k|    return name;
  621|   168k|  }
  622|   168k|  catch(const std::range_error& re) {
  623|  1.23k|    throw std::out_of_range(string("dnsname issue: ")+re.what());
  624|  1.23k|  }
  625|   168k|  catch(...) {
  626|     18|    throw std::out_of_range("dnsname issue");
  627|     18|  }
  628|   168k|}
_ZN12PacketReader7xfrBlobERNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE:
  727|  39.8k|{
  728|  39.8k|  try {
  729|  39.8k|    if (d_recordlen != 0 && !(d_pos == (d_startrecordpos + d_recordlen))) {
  ------------------
  |  Branch (729:9): [True: 32.6k, False: 7.21k]
  |  Branch (729:29): [True: 32.6k, False: 0]
  ------------------
  730|  32.6k|      if (d_pos > (d_startrecordpos + d_recordlen)) {
  ------------------
  |  Branch (730:11): [True: 0, False: 32.6k]
  ------------------
  731|      0|        throw std::out_of_range("xfrBlob out of record range");
  732|      0|      }
  733|  32.6k|      blob.assign(&d_content.at(d_pos), &d_content.at(d_startrecordpos + d_recordlen - 1 ) + 1);
  734|  32.6k|    }
  735|  7.21k|    else {
  736|  7.21k|      blob.clear();
  737|  7.21k|    }
  738|       |
  739|  39.8k|    d_pos = d_startrecordpos + d_recordlen;
  740|  39.8k|  }
  741|  39.8k|  catch(...)
  742|  39.8k|  {
  743|      0|    throw std::out_of_range("xfrBlob out of range");
  744|      0|  }
  745|  39.8k|}
_Z16editDNSPacketTTLPcmRKNSt3__18functionIFjhttjEEE:
  949|  5.22k|{
  950|  5.22k|  if(length < sizeof(dnsheader))
  ------------------
  |  Branch (950:6): [True: 0, False: 5.22k]
  ------------------
  951|      0|    return;
  952|  5.22k|  try
  953|  5.22k|  {
  954|  5.22k|    dnsheader dh;
  955|  5.22k|    memcpy((void*)&dh, (const dnsheader*)packet, sizeof(dh));
  956|  5.22k|    uint64_t numrecords = ntohs(dh.ancount) + ntohs(dh.nscount) + ntohs(dh.arcount);
  957|  5.22k|    DNSPacketMangler dpm(packet, length);
  958|       |
  959|  5.22k|    uint64_t n;
  960|  40.9k|    for(n=0; n < ntohs(dh.qdcount) ; ++n) {
  ------------------
  |  Branch (960:14): [True: 35.6k, False: 5.22k]
  ------------------
  961|  35.6k|      dpm.skipDomainName();
  962|       |      /* type and class */
  963|  35.6k|      dpm.skipBytes(4);
  964|  35.6k|    }
  965|       |
  966|   123k|    for(n=0; n < numrecords; ++n) {
  ------------------
  |  Branch (966:14): [True: 117k, False: 5.19k]
  ------------------
  967|   117k|      dpm.skipDomainName();
  968|       |
  969|   117k|      uint8_t section = n < ntohs(dh.ancount) ? 1 : (n < (ntohs(dh.ancount) + ntohs(dh.nscount)) ? 2 : 3);
  ------------------
  |  Branch (969:25): [True: 19.4k, False: 98.5k]
  |  Branch (969:54): [True: 16.9k, False: 81.5k]
  ------------------
  970|   117k|      uint16_t dnstype = dpm.get16BitInt();
  971|   117k|      uint16_t dnsclass = dpm.get16BitInt();
  972|       |
  973|   117k|      if(dnstype == QType::OPT) // not getting near that one with a stick
  ------------------
  |  Branch (973:10): [True: 28, False: 117k]
  ------------------
  974|     28|        break;
  975|       |
  976|   117k|      uint32_t dnsttl = dpm.get32BitInt();
  977|   117k|      uint32_t newttl = visitor(section, dnsclass, dnstype, dnsttl);
  978|   117k|      if (newttl) {
  ------------------
  |  Branch (978:11): [True: 109k, False: 8.16k]
  ------------------
  979|   109k|        dpm.rewindBytes(sizeof(newttl));
  980|   109k|        dpm.setAndSkip32BitInt(newttl);
  981|   109k|      }
  982|   117k|      dpm.skipRData();
  983|   117k|    }
  984|  5.22k|  }
  985|  5.22k|  catch(...)
  986|  5.22k|  {
  987|  4.69k|    return;
  988|  4.69k|  }
  989|  5.22k|}

_ZN12PacketReaderC2ERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEtbb:
   72|  5.39k|    : d_pos(initialPos), d_startrecordpos(initialPos), d_internal(internalRepresentation), d_standalone(standalone), d_content(content)
   73|  5.39k|  {
   74|  5.39k|    if (content.size() > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (74:9): [True: 0, False: 5.39k]
  ------------------
   75|      0|      throw std::out_of_range("packet too large");
   76|      0|    }
   77|       |
   78|  5.39k|    d_recordlen = static_cast<uint16_t>(content.size());
   79|  5.39k|    d_pointerBudget = static_cast<size_t>(d_recordlen) * s_MaxPointersPerByte;
   80|  5.39k|  }
_ZN12PacketReader11xfr32BitIntERj:
   96|  63.5k|  {
   97|  63.5k|    val=get32BitInt();
   98|  63.5k|  }
_ZN12PacketReader11xfr16BitIntERt:
  131|   199k|  {
  132|   199k|    val=get16BitInt();
  133|   199k|  }
_ZN12PacketReader7xfrTypeERt:
  136|   136k|  {
  137|   136k|    xfr16BitInt(val);
  138|   136k|  }
_ZN12PacketReader7xfrNameER7DNSNameb:
  147|  68.9k|  {
  148|  68.9k|    name = getName();
  149|  68.9k|  }
_ZNK12PacketReader11getPositionEv:
  205|  63.1k|  {
  206|  63.1k|    return d_pos;
  207|  63.1k|  }
_ZN12PacketReader4skipEt:
  210|  63.1k|  {
  211|  63.1k|    size_t stop = d_pos;
  212|  63.1k|    stop += n;
  213|  63.1k|    if (!isWithinRecordBoundaries(d_pos, d_pos + n)) {
  ------------------
  |  Branch (213:9): [True: 1.04k, False: 62.1k]
  ------------------
  214|  1.04k|      throw std::out_of_range("Attempt to skip bytes (" + std::to_string(n) + " starting at " + std::to_string(d_pos) + ") farther than the record's end (" + std::to_string(d_startrecordpos + d_recordlen) + ")");
  215|  1.04k|    }
  216|  62.1k|    if (stop > d_content.size()) {
  ------------------
  |  Branch (216:9): [True: 35, False: 62.0k]
  ------------------
  217|     35|      throw std::out_of_range("Attempt to skip bytes (" + std::to_string(n) + " starting at " + std::to_string(d_pos) + ") farther than the packet's end (" + std::to_string(d_content.size()) + ")");
  218|     35|    }
  219|       |
  220|  62.0k|    d_pos += n;
  221|  62.0k|  }
_ZNK12PacketReader24isWithinRecordBoundariesEmmb:
  227|   516k|  {
  228|   516k|    if (initialPosition > endPosition) {
  ------------------
  |  Branch (228:9): [True: 0, False: 516k]
  ------------------
  229|      0|      return false;
  230|      0|    }
  231|   516k|    if (canBeOutsideRecordContent && d_recordlen == 0) {
  ------------------
  |  Branch (231:9): [True: 167k, False: 349k]
  |  Branch (231:38): [True: 14.7k, False: 152k]
  ------------------
  232|       |      // we don't know the record's length, nothing to check
  233|  14.7k|      return true;
  234|  14.7k|    }
  235|   502k|    const size_t endOfRecordContent = d_startrecordpos + d_recordlen;
  236|   502k|    if (canBeOutsideRecordContent && initialPosition >= endOfRecordContent) {
  ------------------
  |  Branch (236:9): [True: 152k, False: 349k]
  |  Branch (236:38): [True: 32.7k, False: 119k]
  ------------------
  237|       |      // our initial position is after the last known record content,
  238|       |      // we are probably parsing the owner name of the next record,
  239|       |      // nothing to check
  240|  32.7k|      return true;
  241|  32.7k|    }
  242|       |    // are we still inside the record's content?
  243|   469k|    return initialPosition >= d_startrecordpos && initialPosition <= endOfRecordContent && endPosition <= endOfRecordContent;
  ------------------
  |  Branch (243:12): [True: 469k, False: 0]
  |  Branch (243:51): [True: 469k, False: 66]
  |  Branch (243:92): [True: 468k, False: 1.19k]
  ------------------
  244|   502k|  }
_ZN16DNSPacketManglerC2EPcm:
  627|  5.22k|    : d_packet(packet), d_length(length), d_notyouroffset(12), d_offset(d_notyouroffset)
  628|  5.22k|  {}
_ZN16DNSPacketMangler14skipDomainNameEv:
  635|   153k|  {
  636|   153k|    uint8_t len{};
  637|   153k|    bool isRoot = true;
  638|   241k|    while ((len = get8BitInt()) != 0) {
  ------------------
  |  Branch (638:12): [True: 117k, False: 123k]
  ------------------
  639|   117k|      isRoot = false;
  640|   117k|      if (len >= 0xc0) { // extended label
  ------------------
  |  Branch (640:11): [True: 29.6k, False: 88.2k]
  ------------------
  641|  29.6k|        get8BitInt();
  642|  29.6k|        return false;
  643|  29.6k|      }
  644|  88.2k|      skipBytes(len);
  645|  88.2k|    }
  646|   123k|    return isRoot;
  647|   153k|  }
_ZN16DNSPacketMangler9skipBytesEt:
  650|   123k|  {
  651|   123k|    moveOffset(bytes);
  652|   123k|  }
_ZN16DNSPacketMangler11rewindBytesEt:
  654|   109k|  {
  655|   109k|    rewindOffset(by);
  656|   109k|  }
_ZN16DNSPacketMangler11get32BitIntEv:
  658|   117k|  {
  659|   117k|    const char* p = d_packet + d_offset;
  660|   117k|    moveOffset(4);
  661|   117k|    uint32_t ret;
  662|   117k|    memcpy(&ret, p, sizeof(ret));
  663|       |    return ntohl(ret);
  664|   117k|  }
_ZN16DNSPacketMangler11get16BitIntEv:
  666|   351k|  {
  667|   351k|    const char* p = d_packet + d_offset;
  668|   351k|    moveOffset(2);
  669|   351k|    uint16_t ret;
  670|   351k|    memcpy(&ret, p, sizeof(ret));
  671|       |    return ntohs(ret);
  672|   351k|  }
_ZN16DNSPacketMangler10get8BitIntEv:
  675|   271k|  {
  676|   271k|    const char* p = d_packet + d_offset;
  677|   271k|    moveOffset(1);
  678|   271k|    return *p;
  679|   271k|  }
_ZN16DNSPacketMangler9skipRDataEv:
  682|   116k|  {
  683|   116k|    auto toskip = get16BitInt();
  684|   116k|    moveOffset(toskip);
  685|   116k|  }
_ZN16DNSPacketMangler18setAndSkip32BitIntEj:
  714|   109k|  {
  715|   109k|    moveOffset(4);
  716|       |
  717|       |    value = htonl(value);
  718|   109k|    memcpy(d_packet + d_offset-4, (const char*)&value, sizeof(value));
  719|   109k|  }
_ZN16DNSPacketMangler10moveOffsetEt:
  752|  1.08M|  {
  753|  1.08M|    d_notyouroffset += by;
  754|  1.08M|    if(d_notyouroffset > d_length)
  ------------------
  |  Branch (754:8): [True: 4.69k, False: 1.08M]
  ------------------
  755|  4.69k|      throw std::out_of_range("dns packet out of range: "+std::to_string(d_notyouroffset) +" > "
  756|  4.69k|      + std::to_string(d_length) );
  757|  1.08M|  }
_ZN16DNSPacketMangler12rewindOffsetEt:
  760|   109k|  {
  761|   109k|    if(d_notyouroffset < by)
  ------------------
  |  Branch (761:8): [True: 0, False: 109k]
  ------------------
  762|      0|      throw std::out_of_range("Rewinding dns packet out of range: "+std::to_string(d_notyouroffset) +" < "
  763|      0|                              + std::to_string(by));
  764|   109k|    d_notyouroffset -= by;
  765|   109k|    if(d_notyouroffset < 12)
  ------------------
  |  Branch (765:8): [True: 0, False: 109k]
  ------------------
  766|      0|      throw std::out_of_range("Rewinding dns packet out of range: "+std::to_string(d_notyouroffset) +" < "
  767|      0|                              + std::to_string(12));
  768|   109k|  }

_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEEC2ERS6_RK7DNSNametth:
   43|  2.28k|  d_qname(qname), d_content(content)
   44|  2.28k|{
   45|  2.28k|  d_content.clear();
   46|  2.28k|  dnsheader dnsheader;
   47|       |
   48|  2.28k|  memset(&dnsheader, 0, sizeof(dnsheader));
   49|  2.28k|  dnsheader.id=0;
   50|  2.28k|  dnsheader.qdcount=htons(1);
   51|  2.28k|  dnsheader.opcode=opcode;
   52|       |
   53|  2.28k|  const uint8_t* ptr=(const uint8_t*)&dnsheader;
   54|  2.28k|  d_content.reserve(sizeof(dnsheader) + qname.wirelength() + sizeof(qtype) + sizeof(qclass));
   55|  2.28k|  d_content.resize(sizeof(dnsheader));
   56|  2.28k|  uint8_t* dptr=(&*d_content.begin());
   57|       |
   58|  2.28k|  memcpy(dptr, ptr, sizeof(dnsheader));
   59|  2.28k|  d_namepositions.reserve(16);
   60|  2.28k|  xfrName(qname, false);
   61|  2.28k|  xfr16BitInt(qtype);
   62|  2.28k|  xfr16BitInt(qclass);
   63|       |
   64|  2.28k|  if (d_content.size() > std::numeric_limits<decltype(d_truncatemarker)>::max()) {
  ------------------
  |  Branch (64:7): [True: 0, False: 2.28k]
  ------------------
   65|      0|    throw std::range_error("Trying to build a packet larger than " + std::to_string(std::numeric_limits<decltype(d_truncatemarker)>::max()) + " bytes");
   66|      0|  }
   67|  2.28k|  d_truncatemarker = d_content.size();
   68|  2.28k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11startRecordERK7DNSNametjtN17DNSResourceRecord5PlaceEb:
   77|  65.7k|{
   78|  65.7k|  d_compress = compress;
   79|  65.7k|  commit();
   80|  65.7k|  if (d_content.size() > std::numeric_limits<decltype(d_rollbackmarker)>::max()) {
  ------------------
  |  Branch (80:7): [True: 0, False: 65.7k]
  ------------------
   81|      0|    throw std::range_error("Trying to build a packet larger than " + std::to_string(std::numeric_limits<decltype(d_rollbackmarker)>::max()) + " bytes");
   82|      0|  }
   83|  65.7k|  d_rollbackmarker = d_content.size();
   84|       |
   85|  65.7k|  if (compress && !name.isRoot() && d_qname==name) {  // don't do the whole label compression thing if we *know* we can get away with "see question" - except when compressing the root
  ------------------
  |  Branch (85:7): [True: 65.7k, False: 21]
  |  Branch (85:19): [True: 62.9k, False: 2.85k]
  |  Branch (85:37): [True: 34.8k, False: 28.0k]
  ------------------
   86|  34.8k|    static const std::array<unsigned char, 2> marker{0xc0, 0x0c};
   87|  34.8k|    d_content.insert(d_content.end(), reinterpret_cast<const char *>(marker.begin()), reinterpret_cast<const char *>(marker.end()));
   88|  34.8k|  }
   89|  30.8k|  else {
   90|  30.8k|    xfrName(name, compress);
   91|  30.8k|  }
   92|  65.7k|  xfr16BitInt(qtype);
   93|  65.7k|  xfr16BitInt(qclass);
   94|  65.7k|  xfr32BitInt(ttl);
   95|  65.7k|  xfr16BitInt(0); // this will be the record size
   96|  65.7k|  d_recordplace = place;
   97|       |
   98|  65.7k|  d_sor = d_content.size(); // this will remind us where to stuff the record size
   99|  65.7k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE6commitEv:
  574|  66.1k|{
  575|  66.1k|  if (d_sor == 0) {
  ------------------
  |  Branch (575:7): [True: 1.70k, False: 64.4k]
  ------------------
  576|  1.70k|    return;
  577|  1.70k|  }
  578|       |
  579|  64.4k|  if (d_sor < 2 || d_sor > d_content.size()) {
  ------------------
  |  Branch (579:7): [True: 0, False: 64.4k]
  |  Branch (579:20): [True: 0, False: 64.4k]
  ------------------
  580|      0|    throw std::range_error("Invalid start of record when trying to build a packet: " + std::to_string(d_sor) + " / " + std::to_string(d_content.size()));
  581|      0|  }
  582|       |
  583|  64.4k|  if (d_content.size() > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (583:7): [True: 23, False: 64.4k]
  ------------------
  584|     23|    throw std::range_error("Trying to build a packet larger than " + std::to_string(std::numeric_limits<uint16_t>::max()) + " bytes");
  585|     23|  }
  586|       |
  587|  64.4k|  uint16_t rlen = d_content.size() - d_sor;
  588|  64.4k|  d_content.at(d_sor-2) = rlen >> 8;
  589|  64.4k|  d_content.at(d_sor-1) = rlen & 0xff;
  590|  64.4k|  d_sor = 0;
  591|  64.4k|  auto* dh = reinterpret_cast<dnsheader*>( &*d_content.begin());
  592|  64.4k|  switch(d_recordplace) {
  ------------------
  |  Branch (592:10): [True: 64.4k, False: 0]
  ------------------
  593|      0|  case DNSResourceRecord::QUESTION:
  ------------------
  |  Branch (593:3): [True: 0, False: 64.4k]
  ------------------
  594|      0|    dh->qdcount = htons(ntohs(dh->qdcount) + 1);
  595|      0|    break;
  596|  15.0k|  case DNSResourceRecord::ANSWER:
  ------------------
  |  Branch (596:3): [True: 15.0k, False: 49.3k]
  ------------------
  597|  15.0k|    dh->ancount = htons(ntohs(dh->ancount) + 1);
  598|  15.0k|    break;
  599|  18.4k|  case DNSResourceRecord::AUTHORITY:
  ------------------
  |  Branch (599:3): [True: 18.4k, False: 45.9k]
  ------------------
  600|  18.4k|    dh->nscount = htons(ntohs(dh->nscount) + 1);
  601|  18.4k|    break;
  602|  30.8k|  case DNSResourceRecord::ADDITIONAL:
  ------------------
  |  Branch (602:3): [True: 30.8k, False: 33.5k]
  ------------------
  603|  30.8k|    dh->arcount = htons(ntohs(dh->arcount) + 1);
  604|  30.8k|    break;
  605|  64.4k|  }
  606|       |
  607|  64.4k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11xfr32BitIntEm:
  155|  70.7k|{
  156|  70.7k|  if (val > std::numeric_limits<uint32_t>::max()) {
  ------------------
  |  Branch (156:7): [True: 0, False: 70.7k]
  ------------------
  157|      0|    throw runtime_error("Value too large to fit in 32 bits");
  158|      0|  }
  159|  70.7k|  uint32_t rval=htonl(static_cast<uint32_t>(val));
  160|  70.7k|  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval);
  161|  70.7k|  d_content.insert(d_content.end(), ptr, ptr+4);
  162|  70.7k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11xfr16BitIntEm:
  165|   207k|{
  166|   207k|  if (val > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (166:7): [True: 0, False: 207k]
  ------------------
  167|      0|    throw runtime_error("Value too large to fit in 16 bits");
  168|      0|  }
  169|   207k|  uint16_t rval=htons(static_cast<uint16_t>(val));
  170|   207k|  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval);
  171|   207k|  d_content.insert(d_content.end(), ptr, ptr+2);
  172|   207k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE7xfrNameERK7DNSNameb:
  395|  59.6k|{
  396|  59.6k|  if(l_verbose)
  ------------------
  |  Branch (396:6): [Folded, False: 59.6k]
  ------------------
  397|      0|    cout<<"Wants to write "<<name<<", compress="<<compress<<", canonic="<<d_canonic<<", LC="<<d_lowerCase<<endl;
  398|  59.6k|  if(d_canonic || d_lowerCase)   // d_lowerCase implies canonic
  ------------------
  |  Branch (398:6): [True: 0, False: 59.6k]
  |  Branch (398:19): [True: 0, False: 59.6k]
  ------------------
  399|      0|    compress=false;
  400|       |
  401|  59.6k|  if(name.empty() || name.isRoot()) { // for speed
  ------------------
  |  Branch (401:6): [True: 0, False: 59.6k]
  |  Branch (401:22): [True: 7.12k, False: 52.5k]
  ------------------
  402|  7.12k|    d_content.push_back(0);
  403|  7.12k|    return;
  404|  7.12k|  }
  405|       |
  406|  52.5k|  uint16_t li=0;
  407|  52.5k|  uint16_t matchlen=0;
  408|  52.5k|  if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < maxCompressionOffset) {
  ------------------
  |  Branch (408:6): [True: 50.2k, False: 2.28k]
  |  Branch (408:20): [True: 47.2k, False: 3.05k]
  |  Branch (408:32): [True: 14.4k, False: 32.7k]
  |  Branch (408:68): [True: 14.4k, False: 0]
  ------------------
  409|  14.4k|    const auto& dns=name.getStorage();
  410|  14.4k|    if(l_verbose)
  ------------------
  |  Branch (410:8): [Folded, False: 14.4k]
  ------------------
  411|      0|      cout<<"Found a substring of "<<matchlen<<" bytes from the back, offset: "<<li<<", dnslen: "<<dns.size()<<endl;
  412|       |    // found a substring, if www.powerdns.com matched powerdns.com, we get back matchlen = 13
  413|       |
  414|  14.4k|    unsigned int pos=d_content.size();
  415|  14.4k|    if(pos < maxCompressionOffset && matchlen != dns.size()) {
  ------------------
  |  Branch (415:8): [True: 10.2k, False: 4.21k]
  |  Branch (415:38): [True: 1.03k, False: 9.24k]
  ------------------
  416|  1.03k|      if(l_verbose)
  ------------------
  |  Branch (416:10): [Folded, False: 1.03k]
  ------------------
  417|      0|        cout<<"Inserting pos "<<pos<<" for "<<name<<" for compressed case"<<endl;
  418|  1.03k|      d_namepositions.push_back(pos);
  419|  1.03k|    }
  420|       |
  421|  14.4k|    if(l_verbose)
  ------------------
  |  Branch (421:8): [Folded, False: 14.4k]
  ------------------
  422|      0|      cout<<"Going to write unique part: '"<<makeHexDump(string(dns.c_str(), dns.c_str() + dns.size() - matchlen)) <<"'"<<endl;
  423|  14.4k|    d_content.insert(d_content.end(), (const unsigned char*)dns.c_str(), (const unsigned char*)dns.c_str() + dns.size() - matchlen);
  424|  14.4k|    uint16_t offset=li;
  425|  14.4k|    offset|=0xc000;
  426|       |
  427|  14.4k|    d_content.push_back((char)(offset >> 8));
  428|  14.4k|    d_content.push_back((char)(offset & 0xff));
  429|  14.4k|  }
  430|  38.0k|  else {
  431|  38.0k|    unsigned int pos=d_content.size();
  432|  38.0k|    if(l_verbose)
  ------------------
  |  Branch (432:8): [Folded, False: 38.0k]
  ------------------
  433|      0|      cout<<"Found nothing, we are at pos "<<pos<<", inserting whole name"<<endl;
  434|  38.0k|    if(pos < maxCompressionOffset) {
  ------------------
  |  Branch (434:8): [True: 23.8k, False: 14.2k]
  ------------------
  435|  23.8k|      if(l_verbose)
  ------------------
  |  Branch (435:10): [Folded, False: 23.8k]
  ------------------
  436|      0|        cout<<"Inserting pos "<<pos<<" for "<<name<<" for uncompressed case"<<endl;
  437|  23.8k|      d_namepositions.push_back(pos);
  438|  23.8k|    }
  439|       |
  440|  38.0k|    std::unique_ptr<DNSName> lc;
  441|  38.0k|    if(d_lowerCase)
  ------------------
  |  Branch (441:8): [True: 0, False: 38.0k]
  ------------------
  442|      0|      lc = make_unique<DNSName>(name.makeLowerCase());
  443|       |
  444|  38.0k|    const DNSName::string_t& raw = (lc ? *lc : name).getStorage();
  ------------------
  |  Branch (444:37): [True: 0, False: 38.0k]
  ------------------
  445|  38.0k|    if(l_verbose)
  ------------------
  |  Branch (445:8): [Folded, False: 38.0k]
  ------------------
  446|      0|      cout<<"Writing out the whole thing "<<makeHexDump(string(raw.c_str(),  raw.c_str() + raw.length()))<<endl;
  447|  38.0k|    d_content.insert(d_content.end(), raw.c_str(), raw.c_str() + raw.size());
  448|  38.0k|  }
  449|  52.5k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE7xfrBlobERKNS0_12basic_stringIcNS0_11char_traitsIcEENS3_IcEEEEi:
  452|  39.8k|{
  453|  39.8k|  const uint8_t* ptr=reinterpret_cast<const uint8_t*>(blob.c_str());
  454|  39.8k|  d_content.insert(d_content.end(), ptr, ptr+blob.size());
  455|  39.8k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE9getHeaderEv:
   71|  20.5k|{
   72|  20.5k|  return reinterpret_cast<dnsheader*>(&*d_content.begin());
   73|  20.5k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE10lookupNameERK7DNSNamePt:
  229|  47.2k|{
  230|       |  // iterate over the written labels, see if we find a match
  231|  47.2k|  const auto& raw = name.getStorage();
  232|       |
  233|       |  /* name might be a.root-servers.net, we need to be able to benefit from finding:
  234|       |     b.root-servers.net, or even:
  235|       |     b\xc0\x0c
  236|       |  */
  237|  47.2k|  unsigned int bestpos=0;
  238|  47.2k|  *matchLen = 0;
  239|       |
  240|       |  // positions of each label in the name we are trying to compress
  241|  47.2k|  boost::container::static_vector<uint16_t, 34> positionsInName;
  242|       |  // positions of labels in the packet we are building
  243|  47.2k|  boost::container::static_vector<uint16_t, 34> positionsInPacket;
  244|       |
  245|  47.2k|  try {
  246|  1.18M|    for(auto riter= raw.cbegin(); riter < raw.cend(); ) {
  ------------------
  |  Branch (246:35): [True: 1.15M, False: 30.2k]
  ------------------
  247|  1.15M|      if (*riter == 0) {
  ------------------
  |  Branch (247:11): [True: 16.9k, False: 1.13M]
  ------------------
  248|  16.9k|        break;
  249|  16.9k|      }
  250|  1.13M|      positionsInName.push_back(riter - raw.cbegin());
  251|  1.13M|      riter += *riter + 1;
  252|  1.13M|    }
  253|  47.2k|  }
  254|  47.2k|  catch (const std::bad_alloc& ba) {
  255|  30.2k|    if (l_verbose) {
  ------------------
  |  Branch (255:9): [Folded, False: 30.2k]
  ------------------
  256|      0|      cout << "Domain " << name << " too large to compress" << endl;
  257|      0|    }
  258|  30.2k|    return 0;
  259|  30.2k|  }
  260|       |
  261|  16.9k|  if (l_verbose) {
  ------------------
  |  Branch (261:7): [Folded, False: 16.9k]
  ------------------
  262|      0|    cout<<"Input vector for lookup "<<name<<": ";
  263|      0|    for (const auto n : positionsInName) {
  ------------------
  |  Branch (263:23): [True: 0, False: 0]
  ------------------
  264|      0|      cout << n << " ";
  265|      0|    }
  266|      0|    cout<<endl;
  267|      0|    cout<<makeHexDump(string(raw.c_str(), raw.c_str()+raw.size()))<<endl;
  268|      0|  }
  269|       |
  270|  16.9k|  if (l_verbose) {
  ------------------
  |  Branch (270:7): [Folded, False: 16.9k]
  ------------------
  271|      0|    cout << "Have " << d_namepositions.size() << " to ponder" << endl;
  272|      0|  }
  273|       |
  274|  16.9k|  int counter=1;
  275|   222k|  for (const auto positionInPacket : d_namepositions) {
  ------------------
  |  Branch (275:36): [True: 222k, False: 4.46k]
  ------------------
  276|       |    // here it's a bit tricky because the names might be compressed,
  277|       |    // so we will gather all labels composing the name, following
  278|       |    // pointers if needed
  279|       |    // for example if there is an uncompressed \1a\1b\1c\0 we will store
  280|       |    // the position of \1a, \1b, \1c
  281|       |    // if there is instead \1a followed by a pointer to \1b\1c\0 earlier
  282|       |    // in the packet we will store the position of \1a, \1b, \1c as well
  283|       |    // they will just be disjoint
  284|   222k|    if (l_verbose) {
  ------------------
  |  Branch (284:9): [Folded, False: 222k]
  ------------------
  285|      0|      cout<<"Pos: "<<positionInPacket<<", "<<d_content.size()<<endl;
  286|      0|      DNSName pname(reinterpret_cast<const char*>(d_content.data()), d_content.size(), positionInPacket, true); // only for debugging
  287|      0|      cout<<"Looking at '"<<pname<<"' in packet at position "<<positionInPacket<<"/"<<d_content.size()<<", option "<<counter<<"/"<<d_namepositions.size()<<endl;
  288|      0|      ++counter;
  289|      0|    }
  290|   222k|    size_t pointerQuota = 50U;
  291|       |    // memcmp here makes things _slower_
  292|   222k|    positionsInPacket.clear();
  293|   222k|    try {
  294|  5.39M|      for (auto iter = d_content.cbegin() + positionInPacket; iter < d_content.cend() && pointerQuota > 0;) {
  ------------------
  |  Branch (294:63): [True: 5.26M, False: 133k]
  |  Branch (294:63): [True: 5.26M, False: 133k]
  |  Branch (294:90): [True: 5.26M, False: 0]
  ------------------
  295|  5.26M|        uint8_t labelLength = *iter;
  296|  5.26M|        const uint16_t currentPos = (iter - d_content.cbegin());
  297|  5.26M|        if (l_verbose) {
  ------------------
  |  Branch (297:13): [Folded, False: 5.26M]
  ------------------
  298|      0|          cout << "Found label length: " << std::to_string(labelLength) << " at " << currentPos << endl;
  299|      0|        }
  300|  5.26M|        if (labelLength & 0xc0) {
  ------------------
  |  Branch (300:13): [True: 30.6k, False: 5.23M]
  ------------------
  301|  30.6k|          uint16_t npos = 0x100*(labelLength & (~0xc0)) + *++iter;
  302|       |          // check against going forward
  303|  30.6k|          if (npos >= currentPos || npos < sizeof(dnsheader)) {
  ------------------
  |  Branch (303:15): [True: 0, False: 30.6k]
  |  Branch (303:37): [True: 0, False: 30.6k]
  ------------------
  304|       |            /* something is not right */
  305|      0|            break;
  306|      0|          }
  307|       |
  308|       |          // jump to the target of the pointer
  309|  30.6k|          iter = d_content.begin() + npos;
  310|  30.6k|          if (l_verbose) {
  ------------------
  |  Branch (310:15): [Folded, False: 30.6k]
  ------------------
  311|      0|            cout << "Is compressed label to newpos " << npos << ", going there" << endl;
  312|      0|          }
  313|       |
  314|  30.6k|          if (pointerQuota >= 1) {
  ------------------
  |  Branch (314:15): [True: 30.6k, False: 0]
  ------------------
  315|  30.6k|            pointerQuota--;
  316|  30.6k|            continue;
  317|  30.6k|          }
  318|       |
  319|       |          // out of pointer quota, let's stop there
  320|      0|          break;
  321|  30.6k|        }
  322|       |
  323|  5.23M|        if (labelLength == 0) {
  ------------------
  |  Branch (323:13): [True: 88.2k, False: 5.14M]
  ------------------
  324|  88.2k|          break;
  325|  88.2k|        }
  326|       |
  327|  5.14M|        if (currentPos >= maxCompressionOffset) {
  ------------------
  |  Branch (327:13): [True: 980, False: 5.14M]
  ------------------
  328|    980|          break; // compression pointers cannot point here
  329|    980|        }
  330|       |
  331|  5.14M|        positionsInPacket.push_back(currentPos);
  332|       |        // jump to the next label
  333|  5.14M|        iter += labelLength + 1;
  334|  5.14M|      }
  335|   222k|    }
  336|   222k|    catch (const std::bad_alloc& ba) {
  337|   133k|      if (l_verbose) {
  ------------------
  |  Branch (337:11): [Folded, False: 133k]
  ------------------
  338|      0|        cout << "Domain " << name << " too large to compress" << endl;
  339|      0|      }
  340|   133k|      continue;
  341|   133k|    }
  342|       |
  343|  89.2k|    if (l_verbose) {
  ------------------
  |  Branch (343:9): [Folded, False: 89.2k]
  ------------------
  344|      0|      cout<<"Packet vector: "<<endl;
  345|      0|      for (const auto n : positionsInPacket) {
  ------------------
  |  Branch (345:25): [True: 0, False: 0]
  ------------------
  346|      0|        cout << n << " ";
  347|      0|      }
  348|      0|      cout<<endl;
  349|      0|    }
  350|       |
  351|  89.2k|    auto positionInNameIter = positionsInName.crbegin();
  352|  89.2k|    auto positionInPacketIter = positionsInPacket.crbegin();
  353|  89.2k|    unsigned int cmatchlen=1;
  354|   169k|    for(; positionInNameIter != positionsInName.crend() && positionInPacketIter != positionsInPacket.crend(); ++positionInNameIter, ++positionInPacketIter) {
  ------------------
  |  Branch (354:11): [True: 169k, False: 0]
  |  Branch (354:11): [True: 168k, False: 1.93k]
  |  Branch (354:60): [True: 168k, False: 1.93k]
  ------------------
  355|       |      // positionInNameIter is an offset in raw, pvect an offset in packet
  356|   168k|      uint8_t nlen = raw[*positionInNameIter];
  357|   168k|      uint8_t plen = d_content[*positionInPacketIter];
  358|       |
  359|   168k|      if (l_verbose) {
  ------------------
  |  Branch (359:11): [Folded, False: 168k]
  ------------------
  360|      0|        cout << "nlnen=" << (int)nlen << ", plen=" << (int)plen << endl;
  361|      0|      }
  362|       |
  363|   168k|      if (nlen != plen) {
  ------------------
  |  Branch (363:11): [True: 54.8k, False: 113k]
  ------------------
  364|  54.8k|        break;
  365|  54.8k|      }
  366|       |
  367|   113k|      auto rawpart = std::string_view(raw.c_str() + *positionInNameIter + 1, nlen); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  368|   113k|      auto pktpart = std::string_view((const char*)&d_content[*positionInPacketIter] + 1, nlen); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  369|   113k|      if (pdns_ilexicographical_compare_three_way(rawpart, pktpart) != 0) {
  ------------------
  |  Branch (369:11): [True: 20.0k, False: 93.1k]
  ------------------
  370|  20.0k|        if (l_verbose) {
  ------------------
  |  Branch (370:13): [Folded, False: 20.0k]
  ------------------
  371|      0|          cout << "Mismatch: " << rawpart << " != " << pktpart << endl;
  372|      0|        }
  373|  20.0k|        break;
  374|  20.0k|      }
  375|       |
  376|  93.1k|      cmatchlen += nlen + 1;
  377|  93.1k|      if (cmatchlen == raw.length()) { // have matched all of it, can't improve
  ------------------
  |  Branch (377:11): [True: 12.4k, False: 80.7k]
  ------------------
  378|  12.4k|        if (l_verbose) {
  ------------------
  |  Branch (378:13): [Folded, False: 12.4k]
  ------------------
  379|      0|          cout << "Stopping search, matched whole name" << endl;
  380|      0|        }
  381|       |
  382|  12.4k|        *matchLen = cmatchlen;
  383|  12.4k|        return *positionInPacketIter;
  384|  12.4k|      }
  385|  93.1k|    }
  386|  76.7k|    if (positionInPacketIter != positionsInPacket.crbegin() && *matchLen < cmatchlen) {
  ------------------
  |  Branch (386:9): [True: 15.4k, False: 61.2k]
  |  Branch (386:9): [True: 5.07k, False: 71.6k]
  |  Branch (386:64): [True: 5.07k, False: 10.4k]
  ------------------
  387|  5.07k|      *matchLen = cmatchlen;
  388|  5.07k|      bestpos = *--positionInPacketIter;
  389|  5.07k|    }
  390|  76.7k|  }
  391|  4.46k|  return bestpos;
  392|  16.9k|}

_ZN22EpollRegisterOurselvesC2Ev:
   72|      2|  {
   73|      2|    FDMultiplexer::getMultiplexerMap().emplace(0, &makeEpoll); // priority 0!
   74|      2|  }

_ZN10LuaContextC2Eb:
  110|      2|    {
  111|       |        // luaL_newstate can return null if allocation failed
  112|       |#if defined(__SANITIZE_THREAD__) && defined(LUAJIT_VERSION) && defined(__aarch64__)
  113|       |        // on arm64 with luajit and TSAN, allocation may fail spuriously, so keep retrying a bit
  114|       |        int tries = 100;
  115|       |#else
  116|      2|        int tries = 1;
  117|      2|#endif
  118|      2|        for (; tries > 0; tries--) {
  ------------------
  |  Branch (118:16): [True: 2, False: 0]
  ------------------
  119|      2|          mState = luaL_newstate();
  120|      2|          if (mState != nullptr) { break; }
  ------------------
  |  Branch (120:15): [True: 2, False: 0]
  ------------------
  121|      2|        }
  122|      2|#undef RETRIES
  123|      2|        if (mState == nullptr)
  ------------------
  |  Branch (123:13): [True: 0, False: 2]
  ------------------
  124|      0|            throw std::bad_alloc();
  125|       |
  126|       |        // setting the panic function
  127|      2|        lua_atpanic(mState, [](lua_State* state) -> int {
  128|      2|            const std::string str = lua_tostring(state, -1);
  129|      2|            lua_pop(state, 1);
  130|      2|            assert(false && "lua_atpanic triggered");
  131|      2|            exit(0);
  132|      2|        });
  133|       |
  134|       |        // opening default library if required to do so
  135|      2|        if (openDefaultLibs)
  ------------------
  |  Branch (135:13): [True: 2, False: 0]
  ------------------
  136|      2|            luaL_openlibs(mState);
  137|       |
  138|      2|        writeGlobalEq();
  139|      2|        lua_pushliteral(mState, LUACONTEXT_DEBUG_TRACEBACK); // ref
  ------------------
  |  |  276|      2|	lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
  ------------------
  140|      2|        lua_getglobal(mState, "debug"); // ref, debug
  ------------------
  |  |  279|      2|#define lua_getglobal(L,s)	lua_getfield(L, LUA_GLOBALSINDEX, (s))
  |  |  ------------------
  |  |  |  |   38|      2|#define LUA_GLOBALSINDEX	(-10002)
  |  |  ------------------
  ------------------
  141|      2|        lua_getfield(mState, -1, "traceback"); // ref, debug, traceback
  142|      2|        lua_remove(mState, -2); // ref, traceback
  143|      2|        lua_settable(mState, LUA_REGISTRYINDEX); // []
  ------------------
  |  |   36|      2|#define LUA_REGISTRYINDEX	(-10000)
  ------------------
  144|      2|    }
_ZN10LuaContext13writeGlobalEqEv:
  146|      2|    void writeGlobalEq() {
  147|      2|      const auto eqFunction = [](lua_State* lua) -> int {
  148|      2|        try {
  149|      2|          lua_pushstring(lua, "__eq");
  150|      2|          lua_gettable(lua, -2);
  151|       |          /* if not found, return false */
  152|      2|          if (lua_isnil(lua, -1)) {
  153|      2|            lua_pop(lua, 2);
  154|      2|            lua_pushboolean(lua, false);
  155|      2|            return 1;
  156|      2|          }
  157|      2|          lua_insert(lua, lua_gettop(lua)-2);
  158|      2|          return callRaw(lua, PushedObject{lua, 3}, 1).release();
  159|      2|        } catch(...) {
  160|      2|          Pusher<std::exception_ptr>::push(lua, std::current_exception()).release();
  161|      2|          luaError(lua);
  162|      2|        }
  163|      2|      };
  164|      2|      lua_pushcfunction(mState, eqFunction);
  ------------------
  |  |  262|      2|#define lua_pushcfunction(L,f)	lua_pushcclosure(L, (f), 0)
  ------------------
  165|      2|      lua_setglobal(mState, LUACONTEXT_GLOBAL_EQ);
  ------------------
  |  |  278|      2|#define lua_setglobal(L,s)	lua_setfield(L, LUA_GLOBALSINDEX, (s))
  |  |  ------------------
  |  |  |  |   38|      2|#define LUA_GLOBALSINDEX	(-10002)
  |  |  ------------------
  ------------------
  166|      2|    };
_ZN10LuaContextC2EOS_:
  172|      2|        mState(s.mState)
  173|      2|    {
  174|      2|        s.mState = luaL_newstate();
  175|      2|    }
_ZN10LuaContextD2Ev:
  200|      2|    {
  201|      2|        assert(mState);
  ------------------
  |  Branch (201:9): [True: 2, False: 0]
  ------------------
  202|      2|        lua_close(mState);
  203|      2|    }

LLVMFuzzerTestOneInput:
   24|  2.63k|{
   25|  2.63k|  if (size < sizeof(dnsheader) || size > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (25:7): [True: 6, False: 2.62k]
  |  Branch (25:35): [True: 11, False: 2.61k]
  ------------------
   26|     17|    return 0;
   27|     17|  }
   28|       |
   29|       |  // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   30|  2.61k|  const PacketBuffer packet(data, data + size);
   31|       |  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
   32|  2.61k|  const std::string_view view(reinterpret_cast<const char*>(packet.data()), packet.size());
   33|       |
   34|  2.61k|  try {
   35|  2.61k|    parseRecords(view);
   36|  2.61k|  }
   37|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   38|  2.61k|  catch (const std::exception&) {
   39|  2.38k|  }
   40|       |
   41|  2.61k|  try {
   42|  2.61k|    unsigned int consumed = 0;
   43|       |    // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
   44|  2.61k|    const DNSName original(view.data(), view.size(), sizeof(dnsheader), false, nullptr, nullptr, &consumed);
   45|       |    // a 1-63 octet label shrinks with single alphabet grows the rewritten packet, shifting records and compression pointers with legitimate IDs.
   46|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   47|  2.61k|    const DNSName replacement(std::string(1U + (data[0] % 63U), static_cast<char>('a' + (data[1] % 26U))) + ".example.");
   48|  2.61k|    PacketBuffer rewritten(packet);
   49|  2.61k|    if (dnsdist::changeNameInDNSPacket(rewritten, original, replacement)) {
  ------------------
  |  Branch (49:9): [True: 397, False: 2.21k]
  ------------------
   50|       |      // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
   51|    397|      parseRecords(std::string_view(reinterpret_cast<const char*>(rewritten.data()), rewritten.size()));
   52|    397|    }
   53|  2.61k|  }
   54|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   55|  2.61k|  catch (const std::exception&) {
   56|  1.88k|  }
   57|       |
   58|  2.61k|  try {
   59|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   60|  2.61k|    const uint32_t first = (static_cast<uint32_t>(data[0]) << 8U) | data[1];
   61|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   62|  2.61k|    const uint32_t second = (static_cast<uint32_t>(data[2]) << 8U) | data[3];
   63|  2.61k|    PacketBuffer restricted(packet);
   64|  2.61k|    dnsdist::PacketMangling::restrictDNSPacketTTLs(restricted, std::min(first, second), std::max(first, second));
   65|  2.61k|    dnsdist::PacketMangling::restrictDNSPacketTTLs(restricted, 0, second, {QType::A, QType::AAAA});
   66|  2.61k|  }
   67|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   68|  2.61k|  catch (const std::exception&) {
   69|      0|  }
   70|       |
   71|  2.61k|  PacketBuffer edited(packet);
   72|  2.61k|  dnsdist::PacketMangling::editDNSHeaderFromPacket(edited, [](dnsheader& header) {
   73|  2.61k|    header.rd = !header.rd;
   74|  2.61k|    header.cd = !header.cd;
   75|  2.61k|    return true;
   76|  2.61k|  });
   77|       |
   78|  2.61k|  return 0;
   79|  2.61k|}
fuzz_dnsdist_dnsparser.cc:_ZN12_GLOBAL__N_112parseRecordsERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEE:
   12|  3.01k|{
   13|  3.01k|  const dnsdist::DNSPacketOverlay overlay(packet);
   14|  11.9k|  for (const auto& record : overlay.d_records) {
  ------------------
  |  Branch (14:27): [True: 11.9k, False: 3.01k]
  ------------------
   15|  11.9k|    dnsdist::RecordParsers::parseAddressRecord(packet, record);
   16|  11.9k|    dnsdist::RecordParsers::parseCNAMERecord(packet, record);
   17|  11.9k|  }
   18|  3.01k|}
fuzz_dnsdist_dnsparser.cc:_ZZ22LLVMFuzzerTestOneInputENK3$_0clER9dnsheader:
   72|  2.61k|  dnsdist::PacketMangling::editDNSHeaderFromPacket(edited, [](dnsheader& header) {
   73|  2.61k|    header.rd = !header.rd;
   74|  2.61k|    header.cd = !header.cd;
   75|  2.61k|    return true;
   76|  2.61k|  });

_ZN12ComboAddressC2Ev:
  212|    512|  {
  213|       |    sin4.sin_family = AF_INET;
  214|    512|    sin4.sin_addr.s_addr = 0;
  215|    512|    sin4.sin_port = 0;
  216|    512|    sin6.sin6_scope_id = 0;
  217|    512|    sin6.sin6_flowinfo = 0;
  218|    512|  }
_ZN12ComboAddressC2ERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEt:
  247|      2|  {
  248|      2|    memset(&sin6, 0, sizeof(sin6));
  249|      2|    sin4.sin_family = AF_INET;
  250|      2|    sin4.sin_port = 0;
  251|      2|    if (makeIPv4sockaddr(str, &sin4) != 0) {
  ------------------
  |  Branch (251:9): [True: 0, False: 2]
  ------------------
  252|      0|      sin6.sin6_family = AF_INET6;
  253|      0|      if (makeIPv6sockaddr(str, &sin6) < 0) {
  ------------------
  |  Branch (253:11): [True: 0, False: 0]
  ------------------
  254|      0|        throw PDNSException("Unable to convert presentation address '" + str + "'");
  255|      0|      }
  256|      0|    }
  257|      2|    if (sin4.sin_port == 0) { // 'str' overrides port!
  ------------------
  |  Branch (257:9): [True: 0, False: 2]
  ------------------
  258|       |      sin4.sin_port = htons(port);
  259|      0|    }
  260|      2|  }
_Z23makeComboAddressFromRawhPKcm:
  661|    502|{
  662|    502|  ComboAddress address;
  663|       |
  664|    502|  if (version == 4) {
  ------------------
  |  Branch (664:7): [True: 287, False: 215]
  ------------------
  665|    287|    address.sin4.sin_family = AF_INET;
  666|    287|    if (len != sizeof(address.sin4.sin_addr)) {
  ------------------
  |  Branch (666:9): [True: 0, False: 287]
  ------------------
  667|      0|      throw NetmaskException("invalid raw address length");
  668|      0|    }
  669|    287|    memcpy(&address.sin4.sin_addr, raw, sizeof(address.sin4.sin_addr));
  670|    287|  }
  671|    215|  else if (version == 6) {
  ------------------
  |  Branch (671:12): [True: 215, False: 0]
  ------------------
  672|    215|    address.sin6.sin6_family = AF_INET6;
  673|    215|    if (len != sizeof(address.sin6.sin6_addr)) {
  ------------------
  |  Branch (673:9): [True: 0, False: 215]
  ------------------
  674|      0|      throw NetmaskException("invalid raw address length");
  675|      0|    }
  676|    215|    memcpy(&address.sin6.sin6_addr, raw, sizeof(address.sin6.sin6_addr));
  677|    215|  }
  678|      0|  else {
  679|      0|    throw NetmaskException("invalid address family");
  680|      0|  }
  681|       |
  682|    502|  return address;
  683|    502|}
_ZN7NetmaskC2Ev:
  696|      8|  {
  697|      8|    d_network.sin4.sin_family = 0; // disable this doing anything useful
  698|      8|    d_network.sin4.sin_port = 0; // this guarantees d_network compares identical
  699|      8|  }
_ZN19AddressAndPortRangeC2Ev:
 1885|      2|    d_addrMask(0), d_portMask(0)
 1886|      2|  {
 1887|      2|    d_addr.sin4.sin_family = 0; // disable this doing anything useful
 1888|      2|    d_addr.sin4.sin_port = 0; // this guarantees d_network compares identical
 1889|      2|  }
_ZN12NetmaskGroupC2Ev:
 1722|      8|  NetmaskGroup() noexcept = default;
_ZN11NetmaskTreeIb7NetmaskEC2Ev:
 1327|      8|    d_root(new TreeNode()), d_left(nullptr)
 1328|      8|  {
 1329|      8|  }
_ZN11NetmaskTreeIb7NetmaskE8TreeNodeC2Ev:
 1032|      8|      parent(nullptr), node(), assigned(false), d_bits(0)
 1033|      8|    {
 1034|      8|    }
_ZN11NetmaskTreeI8DynBlock19AddressAndPortRangeE8TreeNodeC2Ev:
 1032|      2|      parent(nullptr), node(), assigned(false), d_bits(0)
 1033|      2|    {
 1034|      2|    }
_ZN11NetmaskTreeI8DynBlock19AddressAndPortRangeEC2Ev:
 1327|      2|    d_root(new TreeNode()), d_left(nullptr)
 1328|      2|  {
 1329|      2|  }

_ZN11LockGuardedINSt3__15dequeINS0_10unique_ptrI18CrossProtocolQueryNS0_14default_deleteIS3_EEEENS0_9allocatorIS6_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__110shared_ptrIN7dnsdist13configuration20RuntimeConfigurationEEEEC2EOS5_:
  310|      2|    d_value(std::move(value))
  311|      2|  {
  312|      2|  }
_ZN11LockGuardedIN19DynBlockMaintenance4TopsEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__16vectorINS0_10shared_ptrI18DynBlockRulesGroupEENS0_9allocatorIS4_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__110shared_ptrI11NetmaskTreeI8DynBlock19AddressAndPortRangeEEEEC2EOS6_:
  310|      2|    d_value(std::move(value))
  311|      2|  {
  312|      2|  }
_ZN11LockGuardedINSt3__110shared_ptrI15SuffixMatchTreeI8DynBlockEEEEC2EOS5_:
  310|      2|    d_value(std::move(value))
  311|      2|  {
  312|      2|  }
_ZN20RecursiveLockGuardedI10LuaContextEC2EOS0_:
  415|      2|    d_value(std::move(value))
  416|      2|  {
  417|      2|  }
_ZN11LockGuardedINSt3__16vectorINS0_10shared_ptrIN7dnsdist16ServiceDiscovery18UpgradeableBackendEEENS0_9allocatorIS6_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__16vectorINS0_4pairI7timevalNS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEEENS7_ISA_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedIN27ConcurrentConnectionManager4DataEEC2Ev:
  314|      4|  explicit LockGuarded() = default;
_ZN11LockGuardedIN27ConcurrentConnectionManager4DataEE4lockEv:
  322|      4|  {
  323|      4|    return LockGuardedHolder<T>(d_value, d_mutex);
  324|      4|  }
_ZN17LockGuardedHolderIN27ConcurrentConnectionManager4DataEEC2ERS1_RNSt3__15mutexE:
  236|      4|    d_lock(mutex), d_value(value)
  237|      4|  {
  238|      4|  }
_ZNK17LockGuardedHolderIN27ConcurrentConnectionManager4DataEEptEv:
  246|      4|  {
  247|      4|    return &d_value;
  248|      4|  }
_ZN11LockGuardedINSt3__16vectorINS0_8functionIFvvEEENS0_9allocatorIS4_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__16vectorINS0_4pairINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEENS0_8functionIFvvEEEEENS6_ISC_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedINSt3__16vectorINS0_8functionIFvRKNS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEbEEENS6_ISC_EEEEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN17SharedLockGuardedIN5boost15circular_bufferIN7dnsdist17MacAddressesCache5EntryENSt3__19allocatorIS4_EEEEEC2Ev:
  583|      2|  explicit SharedLockGuarded() = default;
_ZN17SharedLockGuardedINSt3__13mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEENS1_IS7_N7dnsdist7metrics14MutableCounterENS0_4lessIS7_EENS5_INS0_4pairIKS7_SA_EEEEEENSB_IvEENS5_INSD_ISE_SH_EEEEEEEC2Ev:
  583|      2|  explicit SharedLockGuarded() = default;
_ZN17SharedLockGuardedINSt3__13mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEENS1_IS7_N7dnsdist7metrics12MutableGaugeENS0_4lessIS7_EENS5_INS0_4pairIKS7_SA_EEEEEENSB_IvEENS5_INSD_ISE_SH_EEEEEEEC2Ev:
  583|      2|  explicit SharedLockGuarded() = default;
_ZN17SharedLockGuardedINSt3__16vectorIN7dnsdist7metrics5Stats11EntryTripleENS0_9allocatorIS5_EEEEEC2EOS8_:
  579|      2|    d_value(std::move(value))
  580|      2|  {
  581|      2|  }
_ZN17SharedLockGuardedINSt3__113unordered_mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEjNS0_4hashIS7_EENS0_8equal_toIS7_EENS5_INS0_4pairIKS7_jEEEEEEEC2Ev:
  583|      2|  explicit SharedLockGuarded() = default;
_ZN11LockGuardedIN15TLSSessionCache9CacheDataEEC2Ev:
  314|      2|  explicit LockGuarded() = default;
_ZN11LockGuardedIN5boost11multi_index21multi_index_containerIN7dnsdist11ClientEntryENS1_10indexed_byINS1_13hashed_uniqueINS1_3tagINS3_10AddressTagEN4mpl_2naESA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_EENS1_6memberIS4_19AddressAndPortRangeXadL_ZNS4_6d_addrEEEEENSD_4hashESA_EENS1_18ordered_non_uniqueINS7_INS3_7TimeTagESA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_EENSC_IS4_lXadL_ZNS4_10d_lastSeenEEEEESA_EESA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_SA_EENSt3__19allocatorIS4_EEEEEC2Ev:
  314|     32|  explicit LockGuarded() = default;
_ZN17SharedLockGuardedINSt3__113unordered_mapINS0_12basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEENS0_7variantIJNS0_8functionIFvRKN6YaHTTP7RequestERNSA_8ResponseERKN4Logr6LoggerEEEENS9_IFvSD_SF_EEEEEENS0_4hashIS7_EENS0_8equal_toIS7_EENS5_INS0_4pairIKS7_SO_EEEEEEEC2Ev:
  583|      2|  explicit SharedLockGuarded() = default;
_ZN11LockGuardedIbEC2EOb:
  310|      2|    d_value(std::move(value))
  311|      2|  {
  312|      2|  }

_Z11getHostnamev:
  479|      2|{
  480|      2|  const size_t maxHostNameBufSize = getMaxHostNameSize() + 1;
  481|      2|  std::string hostname;
  482|      2|  hostname.resize(maxHostNameBufSize, 0);
  483|       |
  484|      2|  if (gethostname(hostname.data(), maxHostNameBufSize) == -1) {
  ------------------
  |  Branch (484:7): [True: 0, False: 2]
  ------------------
  485|      0|    return std::nullopt;
  486|      0|  }
  487|       |
  488|      2|  hostname.resize(strlen(hostname.c_str()));
  489|      2|  return std::make_optional(hostname);
  490|      2|}
_Z16makeIPv4sockaddrRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEP11sockaddr_in:
  778|      2|{
  779|      2|  std::string str(arg);
  780|      2|  if (str.empty()) {
  ------------------
  |  Branch (780:7): [True: 0, False: 2]
  ------------------
  781|      0|    return -1;
  782|      0|  }
  783|      2|  struct in_addr inp{};
  784|       |
  785|      2|  string::size_type pos = str.find(':');
  786|      2|  if (pos == string::npos) { // no port specified, not touching the port
  ------------------
  |  Branch (786:7): [True: 0, False: 2]
  ------------------
  787|      0|    if (inet_aton(str.c_str(), &inp) != 0) {
  ------------------
  |  Branch (787:9): [True: 0, False: 0]
  ------------------
  788|      0|      ret->sin_addr.s_addr = inp.s_addr;
  789|      0|      return 0;
  790|      0|    }
  791|      0|    return -1;
  792|      0|  }
  793|      2|  if (*(str.c_str() + pos + 1) == 0) { // trailing :
  ------------------
  |  Branch (793:7): [True: 0, False: 2]
  ------------------
  794|      0|    return -1;
  795|      0|  }
  796|       |
  797|      2|  auto* eptr = str.data() + str.size();
  798|      2|  int port = static_cast<int>(strtol(str.c_str() + pos + 1, &eptr, 10));
  799|      2|  if (port < 0 || port > 65535) {
  ------------------
  |  Branch (799:7): [True: 0, False: 2]
  |  Branch (799:19): [True: 0, False: 2]
  ------------------
  800|      0|    return -1;
  801|      0|  }
  802|      2|  if (*eptr != 0) {
  ------------------
  |  Branch (802:7): [True: 0, False: 2]
  ------------------
  803|      0|    return -1;
  804|      0|  }
  805|       |
  806|      2|  ret->sin_port = htons(port);
  807|      2|  if (inet_aton(str.substr(0, pos).c_str(), &inp) != 0) {
  ------------------
  |  Branch (807:7): [True: 2, False: 0]
  ------------------
  808|      2|    ret->sin_addr.s_addr = inp.s_addr;
  809|      2|    return 0;
  810|      2|  }
  811|      0|  return -1;
  812|      2|}
misc.cc:_ZL18getMaxHostNameSizev:
  462|      2|{
  463|      2|#if defined(HOST_NAME_MAX)
  464|      2|  return HOST_NAME_MAX;
  465|      0|#endif
  466|       |
  467|      0|#if defined(_SC_HOST_NAME_MAX)
  468|      0|  auto tmp = sysconf(_SC_HOST_NAME_MAX);
  469|      0|  if (tmp != -1) {
  ------------------
  |  Branch (469:7): [True: 0, False: 0]
  ------------------
  470|      0|    return tmp;
  471|      0|  }
  472|      0|#endif
  473|       |
  474|      0|  const size_t maxHostNameSize = 255;
  475|      0|  return maxHostNameSize;
  476|      0|}

_ZN13FDMultiplexer17getMultiplexerMapEv:
  259|      4|  {
  260|      4|    static FDMultiplexermap_t theMap;
  261|      4|    return theMap;
  262|      4|  }

_ZN14noinit_adaptorINSt3__19allocatorIhEEEC2Ev:
   22|  4.89k|  noinit_adaptor(): Allocator() { }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRKhJEEEvPT_OT0_DpOT1_:
   36|  6.74M|  void construct(U* p, V&& v, Args&&... args) {
   37|  6.74M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  6.74M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE7destroyIhEEvPT_:
   41|  41.4M|  void destroy(U* p) {
   42|  41.4M|    p->~U();
   43|  41.4M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRhJEEEvPT_OT0_DpOT1_:
   36|  15.5M|  void construct(U* p, V&& v, Args&&... args) {
   37|  15.5M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  15.5M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhEEvPT_:
   31|  27.3k|  void construct(U* p) {
   32|  27.3k|    ::new((void*)p) U;
   33|  27.3k|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhhJEEEvPT_OT0_DpOT1_:
   36|  11.6M|  void construct(U* p, V&& v, Args&&... args) {
   37|  11.6M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  11.6M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRKcJEEEvPT_OT0_DpOT1_:
   36|  7.45M|  void construct(U* p, V&& v, Args&&... args) {
   37|  7.45M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  7.45M|  }

_ZN17RegisterOurselvesC2Ev:
   58|      2|  {
   59|      2|    FDMultiplexer::getMultiplexerMap().emplace(2, &make);
   60|      2|  }

qtype.cc:_ZL12swapElementsRKNSt3__13mapIKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEtNS_4lessIS7_EENS4_INS_4pairIS7_tEEEEEE:
  103|      2|{
  104|      2|  std::map<uint16_t, const std::string> ret;
  105|       |
  106|    138|  for (const auto& name : names) {
  ------------------
  |  Branch (106:25): [True: 138, False: 2]
  ------------------
  107|    138|    ret.emplace(name.second, name.first);
  108|    138|  }
  109|      2|  return ret;
  110|      2|}

_ZN5QTypeC2Et:
   49|   117k|    code(qtype) {}
_ZNKSt3__14hashI5QTypeEclES1_:
  177|   132k|  {
  178|   132k|    return std::hash<uint16_t>{}(qtype.getCode());
  179|   132k|  }
_ZNK5QType7getCodeEv:
   60|   132k|  {
   61|   132k|    return code;
   62|   132k|  }
_ZNK5QTypecvtEv:
   54|   118k|  {
   55|   118k|    return code;
   56|   118k|  }
_ZNK6QClasscvtEv:
  201|  58.4k|  {
  202|  58.4k|    return qclass;
  203|  58.4k|  }

_ZN17GlobalStateHolderIN7dnsdist13configuration20RuntimeConfigurationEEC2Ev:
  105|      2|    d_state(std::make_shared<T>())
  106|      2|  {}
_ZN17GlobalStateHolderI11NetmaskTreeI8DynBlock19AddressAndPortRangeEEC2Ev:
  105|      2|    d_state(std::make_shared<T>())
  106|      2|  {}
_ZN17GlobalStateHolderI15SuffixMatchTreeI8DynBlockEEC2Ev:
  105|      2|    d_state(std::make_shared<T>())
  106|      2|  {}

_ZN4pdns12stat_t_traitImEC2Em:
   39|     92|    {
   40|     92|      new(&counter) atomic_t(value);
   41|     92|    }
_ZN4pdns12stat_t_traitIdEC2Ed:
   39|     48|    {
   40|     48|      new(&counter) atomic_t(value);
   41|     48|    }

_ZN4pdns5views16UnsignedCharViewC2EPKcm:
   33|   229k|    view(data_, size_)
   34|   229k|  {
   35|   229k|  }
_ZNK4pdns5views16UnsignedCharView2atEm:
   44|  2.42M|  {
   45|  2.42M|    return reinterpret_cast<const unsigned char&>(view.at(pos));
   46|  2.42M|  }
_ZNK4pdns5views16UnsignedCharView4sizeEv:
   60|  3.70M|  {
   61|  3.70M|    return view.size();
   62|  3.70M|  }

