_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.64k|  {
  228|  2.64k|    return reinterpret_cast<uintptr_t>(mem) % sizeof(uint32_t) == 0; // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
  229|  2.64k|  }

_ZN7dnsdist16DNSPacketOverlayC2ERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   29|  3.07k|{
   30|  3.07k|  if (packet.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (30:7): [True: 0, False: 3.07k]
  ------------------
   31|      0|    throw std::runtime_error("Packet is too small for a DNS packet");
   32|      0|  }
   33|       |
   34|  3.07k|  memcpy(&d_header, packet.data(), sizeof(dnsheader));
   35|  3.07k|  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.07k|  auto reserveRecordCount = std::min(1 + ((packet.size() - sizeof(dnsheader)) / sizeof(dnsrecordheader)), static_cast<size_t>(supposedRecordCount));
   42|  3.07k|  d_records.reserve(reserveRecordCount);
   43|       |
   44|  3.07k|  try {
   45|  3.07k|    PacketReader reader(std::string_view(reinterpret_cast<const char*>(packet.data()), packet.size()));
   46|       |
   47|  8.01k|    for (uint16_t idx = 0; idx < ntohs(d_header.qdcount); ++idx) {
  ------------------
  |  Branch (47:28): [True: 4.94k, False: 3.07k]
  ------------------
   48|  4.94k|      reader.xfrName(d_qname);
   49|  4.94k|      reader.xfrType(d_qtype);
   50|  4.94k|      reader.xfrType(d_qclass);
   51|  4.94k|    }
   52|       |
   53|  62.2k|    for (uint64_t idx = 0; idx < supposedRecordCount; ++idx) {
  ------------------
  |  Branch (53:28): [True: 59.1k, False: 3.07k]
  ------------------
   54|  59.1k|      Record rec;
   55|  59.1k|      reader.xfrName(rec.d_name);
   56|  59.1k|      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: 13.5k, False: 45.6k]
  |  Branch (56:82): [True: 11.6k, False: 34.0k]
  ------------------
   57|  59.1k|      reader.xfrType(rec.d_type);
   58|  59.1k|      reader.xfrType(rec.d_class);
   59|  59.1k|      reader.xfr32BitInt(rec.d_ttl);
   60|  59.1k|      reader.xfr16BitInt(rec.d_contentLength);
   61|  59.1k|      rec.d_contentOffset = reader.getPosition();
   62|  59.1k|      reader.skip(rec.d_contentLength);
   63|  59.1k|      d_records.push_back(std::move(rec));
   64|  59.1k|    }
   65|  3.07k|  }
   66|  3.07k|  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.07k|  catch (...) {
   70|      0|    throw std::runtime_error("Unable to parse DNS packet");
   71|      0|  }
   72|  3.07k|}
_ZN7dnsdist21changeNameInDNSPacketERNSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEERK7DNSNameSA_:
   75|  2.40k|{
   76|  2.40k|  if (initialPacket.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (76:7): [True: 0, False: 2.40k]
  ------------------
   77|      0|    return false;
   78|      0|  }
   79|       |
   80|  2.40k|  PacketReader pr(std::string_view(reinterpret_cast<const char*>(initialPacket.data()), initialPacket.size()));
   81|       |
   82|  2.40k|  dnsheader dh;
   83|  2.40k|  memcpy(&dh, initialPacket.data(), sizeof(dh));
   84|  2.40k|  size_t idx = 0;
   85|  2.40k|  DNSName rrname;
   86|  2.40k|  uint16_t qdcount = ntohs(dh.qdcount);
   87|  2.40k|  uint16_t ancount = ntohs(dh.ancount);
   88|  2.40k|  uint16_t nscount = ntohs(dh.nscount);
   89|  2.40k|  uint16_t arcount = ntohs(dh.arcount);
   90|  2.40k|  uint16_t rrtype;
   91|  2.40k|  uint16_t rrclass;
   92|  2.40k|  string blob;
   93|       |
   94|  2.40k|  size_t recordsCount = ancount + nscount + arcount;
   95|  2.40k|  struct dnsrecordheader ah;
   96|       |
   97|  2.40k|  rrname = pr.getName();
   98|  2.40k|  if (rrname == from) {
  ------------------
  |  Branch (98:7): [True: 2.40k, False: 0]
  ------------------
   99|  2.40k|    rrname = to;
  100|  2.40k|  }
  101|       |
  102|  2.40k|  rrtype = pr.get16BitInt();
  103|  2.40k|  rrclass = pr.get16BitInt();
  104|       |
  105|  2.40k|  PacketBuffer newContent;
  106|  2.40k|  newContent.reserve(initialPacket.size());
  107|  2.40k|  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.40k|  pw.getHeader()->id = dh.id;
  110|  2.40k|  pw.getHeader()->qr = dh.qr;
  111|  2.40k|  pw.getHeader()->aa = dh.aa;
  112|  2.40k|  pw.getHeader()->tc = dh.tc;
  113|  2.40k|  pw.getHeader()->rd = dh.rd;
  114|  2.40k|  pw.getHeader()->ra = dh.ra;
  115|  2.40k|  pw.getHeader()->ad = dh.ad;
  116|  2.40k|  pw.getHeader()->cd = dh.cd;
  117|  2.40k|  pw.getHeader()->rcode = dh.rcode;
  118|       |
  119|       |  /* consume remaining qd if any, but do not copy it */
  120|  6.36k|  for (idx = 1; idx < qdcount; idx++) {
  ------------------
  |  Branch (120:17): [True: 3.96k, False: 2.40k]
  ------------------
  121|  3.96k|    rrname = pr.getName();
  122|  3.96k|    (void)pr.get16BitInt();
  123|  3.96k|    (void)pr.get16BitInt();
  124|  3.96k|  }
  125|       |
  126|  2.40k|  static const std::unordered_set<QType> nameOnlyTypes{QType::NS, QType::PTR, QType::CNAME, QType::DNAME};
  127|  2.40k|  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|  64.0k|  for (idx = 0; idx < recordsCount; idx++) {
  ------------------
  |  Branch (130:17): [True: 63.0k, False: 1.03k]
  ------------------
  131|  63.0k|    rrname = pr.getName();
  132|  63.0k|    if (rrname == from) {
  ------------------
  |  Branch (132:9): [True: 32.2k, False: 30.7k]
  ------------------
  133|  32.2k|      rrname = to;
  134|  32.2k|    }
  135|  63.0k|    pr.getDnsrecordheader(ah);
  136|       |
  137|  63.0k|    auto place = idx < ancount ? DNSResourceRecord::ANSWER : (idx < (ancount + nscount) ? DNSResourceRecord::AUTHORITY : DNSResourceRecord::ADDITIONAL);
  ------------------
  |  Branch (137:18): [True: 18.4k, False: 44.5k]
  |  Branch (137:63): [True: 14.4k, False: 30.1k]
  ------------------
  138|  63.0k|    pw.startRecord(rrname, ah.d_type, ah.d_ttl, ah.d_class, place, true);
  139|  63.0k|    if (nameOnlyTypes.count(ah.d_type)) {
  ------------------
  |  Branch (139:9): [True: 20.8k, False: 42.2k]
  ------------------
  140|  20.8k|      rrname = pr.getName();
  141|       |      // compression is not allowed for DNAME target per rfc6672 section 2.5
  142|  20.8k|      pw.xfrName(rrname, ah.d_type != QType::DNAME);
  143|  20.8k|    }
  144|  42.2k|    else if (noNameTypes.count(ah.d_type)) {
  ------------------
  |  Branch (144:14): [True: 34.2k, False: 7.98k]
  ------------------
  145|  34.2k|      pr.xfrBlob(blob);
  146|  34.2k|      pw.xfrBlob(blob);
  147|  34.2k|    }
  148|  7.98k|    else if (ah.d_type == QType::RRSIG) {
  ------------------
  |  Branch (148:14): [True: 2.34k, False: 5.63k]
  ------------------
  149|       |      /* good luck */
  150|  2.34k|      pr.xfrBlob(blob);
  151|  2.34k|      pw.xfrBlob(blob);
  152|  2.34k|    }
  153|  5.63k|    else if (ah.d_type == QType::MX) {
  ------------------
  |  Branch (153:14): [True: 2.23k, False: 3.39k]
  ------------------
  154|  2.23k|      auto prio = pr.get16BitInt();
  155|  2.23k|      rrname = pr.getName();
  156|  2.23k|      pw.xfr16BitInt(prio);
  157|  2.23k|      pw.xfrName(rrname, true);
  158|  2.23k|    }
  159|  3.39k|    else if (ah.d_type == QType::SOA) {
  ------------------
  |  Branch (159:14): [True: 941, False: 2.45k]
  ------------------
  160|    941|      auto mname = pr.getName();
  161|    941|      pw.xfrName(mname, true);
  162|    941|      auto rname = pr.getName();
  163|    941|      pw.xfrName(rname, true);
  164|       |      /* serial */
  165|    941|      pw.xfr32BitInt(pr.get32BitInt());
  166|       |      /* refresh */
  167|    941|      pw.xfr32BitInt(pr.get32BitInt());
  168|       |      /* retry */
  169|    941|      pw.xfr32BitInt(pr.get32BitInt());
  170|       |      /* expire */
  171|    941|      pw.xfr32BitInt(pr.get32BitInt());
  172|       |      /* minimal */
  173|    941|      pw.xfr32BitInt(pr.get32BitInt());
  174|    941|    }
  175|  2.45k|    else if (ah.d_type == QType::SRV) {
  ------------------
  |  Branch (175:14): [True: 1.09k, False: 1.36k]
  ------------------
  176|       |      /* preference */
  177|  1.09k|      pw.xfr16BitInt(pr.get16BitInt());
  178|       |      /* weight */
  179|  1.09k|      pw.xfr16BitInt(pr.get16BitInt());
  180|       |      /* port */
  181|  1.09k|      pw.xfr16BitInt(pr.get16BitInt());
  182|  1.09k|      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.09k|      pw.xfrName(target, false);
  188|  1.09k|    }
  189|  1.36k|    else {
  190|       |      /* sorry, unsafe type */
  191|  1.36k|      return false;
  192|  1.36k|    }
  193|  63.0k|  }
  194|       |
  195|  1.03k|  pw.commit();
  196|  1.03k|  initialPacket = std::move(newContent);
  197|       |
  198|  1.03k|  return true;
  199|  2.40k|}
_ZN7dnsdist14PacketMangling23editDNSHeaderFromPacketERNSt3__16vectorIh14noinit_adaptorINS1_9allocatorIhEEEEERKNS1_8functionIFbR9dnsheaderEEE:
  204|  2.64k|  {
  205|  2.64k|    if (packet.size() < sizeof(dnsheader)) {
  ------------------
  |  Branch (205:9): [True: 0, False: 2.64k]
  ------------------
  206|      0|      throw std::runtime_error("Trying to edit the DNS header of a too small packet");
  207|      0|    }
  208|       |
  209|  2.64k|    return editDNSHeaderFromRawPacket(packet.data(), editFunction);
  210|  2.64k|  }
_ZN7dnsdist14PacketMangling26editDNSHeaderFromRawPacketEPvRKNSt3__18functionIFbR9dnsheaderEEE:
  213|  2.64k|  {
  214|  2.64k|    if (dnsheader_aligned::isMemoryAligned(packet)) {
  ------------------
  |  Branch (214:9): [True: 2.64k, False: 0]
  ------------------
  215|       |      // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
  216|  2.64k|      auto* header = reinterpret_cast<dnsheader*>(packet);
  217|  2.64k|      return editFunction(*header);
  218|  2.64k|    }
  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.28k|  {
  231|  5.28k|    auto visitor = [minimumValue, maximumValue, types](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) {
  232|  5.28k|      (void)section;
  233|  5.28k|      if (!types.empty() && qclass == QClass::IN && types.count(qtype) == 0) {
  234|  5.28k|        return ttl;
  235|  5.28k|      }
  236|       |
  237|  5.28k|      if (minimumValue > 0) {
  238|  5.28k|        if (ttl < minimumValue) {
  239|  5.28k|          ttl = minimumValue;
  240|  5.28k|        }
  241|  5.28k|      }
  242|  5.28k|      if (ttl > maximumValue) {
  243|  5.28k|        ttl = maximumValue;
  244|  5.28k|      }
  245|  5.28k|      return ttl;
  246|  5.28k|    };
  247|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
  248|  5.28k|    editDNSPacketTTL(reinterpret_cast<char*>(packet.data()), packet.size(), visitor);
  249|  5.28k|  }
_ZN7dnsdist13RecordParsers18parseAddressRecordERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_16DNSPacketOverlay6RecordE:
  289|  14.4k|  {
  290|  14.4k|    if (record.d_type == QType::A && record.d_contentLength == 4) {
  ------------------
  |  Branch (290:9): [True: 2.72k, False: 11.7k]
  |  Branch (290:38): [True: 248, False: 2.47k]
  ------------------
  291|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  292|    248|      return makeComboAddressFromRaw(4, packet.substr(record.d_contentOffset, record.d_contentLength).data(), record.d_contentLength);
  293|    248|    }
  294|       |
  295|  14.1k|    if (record.d_type == QType::AAAA && record.d_contentLength == 16) {
  ------------------
  |  Branch (295:9): [True: 877, False: 13.3k]
  |  Branch (295:41): [True: 602, False: 275]
  ------------------
  296|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  297|    602|      return makeComboAddressFromRaw(6, packet.substr(record.d_contentOffset, record.d_contentLength).data(), record.d_contentLength);
  298|    602|    }
  299|       |
  300|  13.5k|    return {};
  301|  14.1k|  }
_ZN7dnsdist13RecordParsers16parseCNAMERecordERKNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_16DNSPacketOverlay6RecordE:
  304|  14.4k|  {
  305|  14.4k|    if (record.d_type != QType::CNAME) {
  ------------------
  |  Branch (305:9): [True: 7.10k, False: 7.33k]
  ------------------
  306|  7.10k|      return {};
  307|  7.10k|    }
  308|       |
  309|       |    // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage): length is passed in and used to read data
  310|  7.33k|    return DNSName(packet.data(), record.d_contentOffset + record.d_contentLength, record.d_contentOffset, true);
  311|  14.4k|  }
dnsdist-dnsparser.cc:_ZZN7dnsdist14PacketMangling21restrictDNSPacketTTLsERNSt3__16vectorIh14noinit_adaptorINS1_9allocatorIhEEEEEjjRKNS1_13unordered_setI5QTypeNS1_4hashISA_EENS1_8equal_toISA_EENS4_ISA_EEEEENK3$_0clEhttj:
  231|   106k|    auto visitor = [minimumValue, maximumValue, types](uint8_t section, uint16_t qclass, uint16_t qtype, uint32_t ttl) {
  232|   106k|      (void)section;
  233|   106k|      if (!types.empty() && qclass == QClass::IN && types.count(qtype) == 0) {
  ------------------
  |  Branch (233:11): [True: 53.3k, False: 53.3k]
  |  Branch (233:11): [True: 900, False: 105k]
  |  Branch (233:29): [True: 1.34k, False: 51.9k]
  |  Branch (233:53): [True: 900, False: 448]
  ------------------
  234|    900|        return ttl;
  235|    900|      }
  236|       |
  237|   105k|      if (minimumValue > 0) {
  ------------------
  |  Branch (237:11): [True: 44.9k, False: 60.7k]
  ------------------
  238|  44.9k|        if (ttl < minimumValue) {
  ------------------
  |  Branch (238:13): [True: 14.3k, False: 30.5k]
  ------------------
  239|  14.3k|          ttl = minimumValue;
  240|  14.3k|        }
  241|  44.9k|      }
  242|   105k|      if (ttl > maximumValue) {
  ------------------
  |  Branch (242:11): [True: 69.3k, False: 36.3k]
  ------------------
  243|  69.3k|        ttl = maximumValue;
  244|  69.3k|      }
  245|   105k|      return ttl;
  246|   106k|    };

_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.43k|{
   78|  2.43k|  if (content.empty() || (content.size() == 1 && content.at(0) == '.')) {
  ------------------
  |  Branch (78:7): [True: 0, False: 2.43k]
  |  Branch (78:27): [True: 6, False: 2.42k]
  |  Branch (78:50): [True: 4, False: 2]
  ------------------
   79|      4|    d_storage.assign(1U, '\0');
   80|      4|    return;
   81|      4|  }
   82|       |
   83|  2.43k|  if (std::memchr(content.data(), '\\', content.size()) != nullptr) {
  ------------------
  |  Branch (83:7): [True: 0, False: 2.43k]
  ------------------
   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.43k|  unsigned char lenpos = 0;
   92|  2.43k|  unsigned char labellen = 0;
   93|       |
   94|  2.43k|  d_storage.reserve(content.size() + 1U);
   95|  7.27k|  for (size_t position = 0; position < content.size(); ) {
  ------------------
  |  Branch (95:29): [True: 4.84k, False: 2.43k]
  ------------------
   96|  4.84k|    lenpos = d_storage.size();
   97|  4.84k|    if (content.at(position) == '.') {
  ------------------
  |  Branch (97:9): [True: 0, False: 4.84k]
  ------------------
   98|      0|      throwSafeRangeError("Found . in wrong position in DNSName: ", content);
   99|      0|    }
  100|  4.84k|    d_storage.append(1U, '\0');
  101|  4.84k|    labellen = 0;
  102|  4.84k|    size_t begPosition = position;
  103|  84.1k|    for(; position < content.size() && content.at(position) != '.'; ++position) {
  ------------------
  |  Branch (103:11): [True: 84.1k, False: 26]
  |  Branch (103:40): [True: 79.2k, False: 4.81k]
  ------------------
  104|  79.2k|      labellen++;
  105|  79.2k|    }
  106|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  107|  4.84k|    d_storage.append(content.begin() + begPosition, content.begin() + position);
  108|  4.84k|    if (position < content.size()) {
  ------------------
  |  Branch (108:9): [True: 4.81k, False: 26]
  ------------------
  109|  4.81k|      ++position;
  110|  4.81k|    }
  111|  4.84k|    if (labellen > s_maxDNSLabelLength) {
  ------------------
  |  Branch (111:9): [True: 0, False: 4.84k]
  ------------------
  112|      0|      throwSafeRangeError("label too long to append: ", content);
  113|      0|    }
  114|       |
  115|  4.84k|    if (position > s_maxDNSNameLength - 1U) {
  ------------------
  |  Branch (115:9): [True: 0, False: 4.84k]
  ------------------
  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.84k|    d_storage.at(lenpos) = static_cast<char>(labellen);
  121|  4.84k|  }
  122|  2.43k|  if (d_storage.size() > s_maxDNSNameLength - 1U) {
  ------------------
  |  Branch (122:7): [True: 0, False: 2.43k]
  ------------------
  123|      0|    throwSafeRangeError("name too long: ", content);
  124|      0|  }
  125|  2.43k|  d_storage.append(1U, '\0');
  126|  2.43k|}
_ZN7DNSNameC2EPKcmmbPtS2_PjtPm:
  129|   169k|{
  130|   169k|  if (offset >= len)
  ------------------
  |  Branch (130:7): [True: 663, False: 168k]
  ------------------
  131|    663|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  132|       |
  133|   168k|  if(!uncompress) {
  ------------------
  |  Branch (133:6): [True: 2.58k, False: 166k]
  ------------------
  134|  2.58k|    if(const void * fnd=memchr(pos+offset, 0, len-offset)) {
  ------------------
  |  Branch (134:21): [True: 2.48k, False: 93]
  ------------------
  135|  2.48k|      d_storage.reserve(2+(const char*)fnd-(pos+offset));
  136|  2.48k|    }
  137|  2.58k|  }
  138|       |
  139|   168k|  packetParser(pos, len, offset, uncompress, qtype, qclass, consumed, 0, minOffset, 0, pointerBudget);
  140|   168k|}
_ZN7DNSName23parsePacketUncompressedERKN4pdns5views16UnsignedCharViewEmb:
  154|   225k|{
  155|   225k|  const size_t initialPos = pos;
  156|   225k|  auto existingSize = d_storage.size();
  157|   225k|  const size_t neededSizeForFinalLabel = /* final empty label length */ (existingSize == 0 ? 1U : 0U);
  ------------------
  |  Branch (157:74): [True: 213k, False: 12.0k]
  ------------------
  158|   225k|  size_t totalLength = 0;
  159|   225k|  unsigned char labellen = 0;
  160|       |
  161|  1.96M|  do {
  162|  1.96M|    labellen = view.at(pos);
  163|  1.96M|    ++pos;
  164|       |
  165|  1.96M|    if (labellen == 0) {
  ------------------
  |  Branch (165:9): [True: 167k, False: 1.79M]
  ------------------
  166|   167k|      --pos;
  167|   167k|      break;
  168|   167k|    }
  169|       |
  170|  1.79M|    if (labellen >= 0xc0) {
  ------------------
  |  Branch (170:9): [True: 57.4k, False: 1.74M]
  ------------------
  171|  57.4k|      if (!uncompress) {
  ------------------
  |  Branch (171:11): [True: 84, False: 57.3k]
  ------------------
  172|     84|        throw std::range_error("Found compressed label, instructed not to follow");
  173|     84|      }
  174|  57.3k|      --pos;
  175|  57.3k|      break;
  176|  57.4k|    }
  177|       |
  178|  1.74M|    if ((labellen & 0xc0) != 0) {
  ------------------
  |  Branch (178:9): [True: 210, False: 1.74M]
  ------------------
  179|    210|      throw std::range_error("Found an invalid label length in qname (only one of the first two bits is set)");
  180|    210|    }
  181|  1.74M|    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.74M|    if ((existingSize + totalLength + labellen + 1U + neededSizeForFinalLabel) > s_maxDNSNameLength) {
  ------------------
  |  Branch (184:9): [True: 25, False: 1.74M]
  ------------------
  185|     25|      throw std::range_error("name too long to append");
  186|     25|    }
  187|  1.74M|    if (pos + labellen >= view.size()) {
  ------------------
  |  Branch (187:9): [True: 208, False: 1.74M]
  ------------------
  188|    208|      throw std::range_error("Found an invalid label length in qname");
  189|    208|    }
  190|  1.74M|    pos += labellen;
  191|  1.74M|    totalLength += 1U + labellen;
  192|  1.74M|  }
  193|  1.74M|  while (pos < view.size());
  ------------------
  |  Branch (193:10): [True: 1.74M, False: 0]
  ------------------
  194|       |
  195|   225k|  if (totalLength != 0) {
  ------------------
  |  Branch (195:7): [True: 84.8k, False: 140k]
  ------------------
  196|  84.8k|    if (existingSize > 0) {
  ------------------
  |  Branch (196:9): [True: 9.68k, False: 75.1k]
  ------------------
  197|       |      // remove the last label count, we are about to override it */
  198|  9.68k|      --existingSize;
  199|  9.68k|    }
  200|  84.8k|    if ((existingSize + totalLength + 1U) > s_maxDNSNameLength) {
  ------------------
  |  Branch (200:9): [True: 0, False: 84.8k]
  ------------------
  201|      0|      throw std::range_error("name too long to append");
  202|      0|    }
  203|  84.8k|    d_storage.reserve(existingSize + totalLength + 1);
  204|  84.8k|    d_storage.resize(existingSize + totalLength);
  205|  84.8k|    memcpy(&d_storage.at(existingSize), &view.at(initialPos), totalLength);
  206|  84.8k|    d_storage.append(1, static_cast<char>(0));
  207|  84.8k|  }
  208|   225k|  return pos;
  209|   225k|}
_ZN7DNSName12packetParserEPKcmmbPtS2_PjittPm:
  213|   225k|{
  214|   225k|  if (offset >= len) {
  ------------------
  |  Branch (214:7): [True: 0, False: 225k]
  ------------------
  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|   225k|  if (offset < static_cast<size_t>(minOffset)) {
  ------------------
  |  Branch (218:7): [True: 0, False: 225k]
  ------------------
  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|   225k|  unsigned char labellen{0};
  222|       |
  223|   225k|  pdns::views::UnsignedCharView view(qpos, len);
  224|   225k|  auto pos = parsePacketUncompressed(view, offset, uncompress);
  225|       |
  226|       |
  227|   225k|  labellen = view.at(pos);
  228|   225k|  if (pos == offset && labellen != 0) {
  ------------------
  |  Branch (228:7): [True: 140k, False: 85.3k]
  |  Branch (228:24): [True: 45.5k, False: 94.6k]
  ------------------
  229|       |    // It's a pointer
  230|  45.5k|    if (pointerBudget != nullptr) {
  ------------------
  |  Branch (230:9): [True: 44.9k, False: 630]
  ------------------
  231|  44.9k|      if (*pointerBudget == 0) {
  ------------------
  |  Branch (231:11): [True: 0, False: 44.9k]
  ------------------
  232|      0|        throw std::range_error("Too many compression pointers processed in packet");
  233|      0|      }
  234|  44.9k|      (*pointerBudget)--;
  235|  44.9k|    }
  236|       |    // Are we chasing a pointer chain already for this name?
  237|  45.5k|    if (pointerChainLength++ > s_maxPointersToPointers) {
  ------------------
  |  Branch (237:9): [True: 3, False: 45.5k]
  ------------------
  238|      3|      throw std::range_error("Too many pointer to pointers during decompression (" + std::to_string(pointerChainLength) + ")");
  239|      3|    }
  240|  45.5k|  }
  241|   180k|  else {
  242|   180k|    pointerChainLength = 0; // not an immediate pointer to pointer case any more
  243|   180k|  }
  244|   225k|  pos++;
  245|   225k|  if (labellen != 0 && pos < view.size()) {
  ------------------
  |  Branch (245:7): [True: 57.3k, False: 168k]
  |  Branch (245:24): [True: 57.0k, False: 340]
  ------------------
  246|  57.0k|    if (labellen < 0xc0) {
  ------------------
  |  Branch (246:9): [True: 0, False: 57.0k]
  ------------------
  247|      0|      throw std::range_error("Invalid label byte during decompression ("+std::to_string(labellen)+")");
  248|      0|    }
  249|       |
  250|  57.0k|    if (!uncompress) {
  ------------------
  |  Branch (250:9): [True: 0, False: 57.0k]
  ------------------
  251|      0|      throw std::range_error("Found compressed label, instructed not to follow");
  252|      0|    }
  253|       |
  254|  57.0k|    labellen &= (~0xc0);
  255|  57.0k|    size_t newpos = (labellen << 8) + view.at(pos);
  256|       |
  257|  57.0k|    if (newpos >= offset) {
  ------------------
  |  Branch (257:9): [True: 251, False: 56.7k]
  ------------------
  258|    251|      throw std::range_error("Found a forward reference during label decompression");
  259|    251|    }
  260|       |
  261|  56.7k|    if (newpos < minOffset) {
  ------------------
  |  Branch (261:9): [True: 27, False: 56.7k]
  ------------------
  262|     27|      throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
  263|     27|    }
  264|       |
  265|  56.7k|    if (++depth > s_maxPointersPerName) {
  ------------------
  |  Branch (265:9): [True: 3, False: 56.7k]
  ------------------
  266|      3|      throw std::range_error("Abort label decompression after too many redirects (" + std::to_string(depth) + ")");
  267|      3|    }
  268|       |
  269|  56.7k|    packetParser(qpos, len, newpos, true, nullptr, nullptr, nullptr, depth, minOffset, pointerChainLength, pointerBudget);
  270|       |
  271|  56.7k|    pos++;
  272|  56.7k|  }
  273|       |
  274|   225k|  if (d_storage.empty()) {
  ------------------
  |  Branch (274:7): [True: 92.9k, False: 132k]
  ------------------
  275|  92.9k|    d_storage.append(1, static_cast<char>(0)); // we just parsed the root
  276|  92.9k|  }
  277|       |
  278|   225k|  if (consumed != nullptr) {
  ------------------
  |  Branch (278:7): [True: 160k, False: 64.5k]
  ------------------
  279|   160k|    *consumed = pos - offset;
  280|   160k|  }
  281|       |
  282|   225k|  if (qtype != nullptr) {
  ------------------
  |  Branch (282:7): [True: 0, False: 225k]
  ------------------
  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|   225k|  pos += 2;
  290|   225k|  if (qclass != nullptr) {
  ------------------
  |  Branch (290:7): [True: 0, False: 225k]
  ------------------
  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|   225k|}
_ZNK7DNSName10wirelengthEv:
  367|  2.31k|size_t DNSName::wirelength() const {
  368|  2.31k|  return d_storage.length();
  369|  2.31k|}
dnsname.cc:_ZL16checkLabelLengthh:
  143|  1.74M|{
  144|  1.74M|  if (length == 0) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.74M]
  ------------------
  145|      0|    throw std::range_error("no such thing as an empty label to append");
  146|      0|  }
  147|  1.74M|  if (length > DNSName::s_maxDNSLabelLength) {
  ------------------
  |  Branch (147:7): [True: 0, False: 1.74M]
  ------------------
  148|      0|    throw std::range_error("label too long to append");
  149|      0|  }
  150|  1.74M|}

_Z11dns_tolowerh:
   58|  3.15M|{
   59|  3.15M|  return dns_tolower_table[chr];
   60|  3.15M|}
_Z39pdns_ilexicographical_compare_three_wayNSt3__117basic_string_viewIcNS_11char_traitsIcEEEES3_:
   64|  91.6k|{
   65|  91.6k|  const unsigned char *aPtr = (const unsigned char*)a.data(), *bPtr = (const unsigned char*)b.data();
   66|  91.6k|  const unsigned char *aEptr = aPtr + a.length(), *bEptr = bPtr + b.length();
   67|   648k|  while(aPtr != aEptr && bPtr != bEptr) {
  ------------------
  |  Branch (67:9): [True: 568k, False: 79.7k]
  |  Branch (67:26): [True: 568k, False: 0]
  ------------------
   68|   568k|    if (*aPtr != *bPtr) {
  ------------------
  |  Branch (68:9): [True: 12.1k, False: 556k]
  ------------------
   69|  12.1k|      if (int rc = dns_tolower(*aPtr) - dns_tolower(*bPtr); rc != 0) {
  ------------------
  |  Branch (69:61): [True: 11.8k, False: 327]
  ------------------
   70|  11.8k|        return rc;
   71|  11.8k|      }
   72|  12.1k|    }
   73|   556k|    aPtr++;
   74|   556k|    bPtr++;
   75|   556k|  }
   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|  79.7k|  if (aPtr == aEptr) {
  ------------------
  |  Branch (79:7): [True: 79.7k, False: 0]
  ------------------
   80|  79.7k|    if (bPtr != bEptr) {
  ------------------
  |  Branch (80:9): [True: 0, False: 79.7k]
  ------------------
   81|      0|      return -1; // a < b
   82|      0|    }
   83|  79.7k|  }
   84|      0|  else {
   85|      0|    return 1; // a > b
   86|      0|  }
   87|  79.7k|  return 0; // a == b
   88|  79.7k|}
_ZN7DNSNameaSERKS_:
  151|  34.6k|  {
  152|  34.6k|    if (this != &rhs) {
  ------------------
  |  Branch (152:9): [True: 34.6k, False: 0]
  ------------------
  153|  34.6k|      d_storage = rhs.d_storage;
  154|  34.6k|    }
  155|  34.6k|    return *this;
  156|  34.6k|  }
_ZN7DNSNameaSEOS_:
  158|   155k|  {
  159|   155k|    if (this != &rhs) {
  ------------------
  |  Branch (159:9): [True: 155k, False: 0]
  ------------------
  160|   155k|      d_storage = std::move(rhs.d_storage);
  161|   155k|    }
  162|   155k|    return *this;
  163|   155k|  }
_ZNK7DNSName5emptyEv:
  210|   303k|  bool empty() const { return d_storage.empty(); }
_ZNK7DNSName6isRootEv:
  211|   120k|  bool isRoot() const { return d_storage.size()==1 && d_storage[0]==0; }
  ------------------
  |  Branch (211:32): [True: 12.8k, False: 107k]
  |  Branch (211:55): [True: 12.8k, False: 0]
  ------------------
_ZNK7DNSName10getStorageEv:
  261|  93.7k|  const string_t& getStorage() const {
  262|  93.7k|    return d_storage;
  263|  93.7k|  }
_ZNK7DNSNameeqERKS_:
  826|   122k|{
  827|   122k|  if (rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size()) {
  ------------------
  |  Branch (827:7): [True: 0, False: 122k]
  |  Branch (827:33): [True: 54.7k, False: 68.0k]
  ------------------
  828|  54.7k|    return false;
  829|  54.7k|  }
  830|       |
  831|  68.0k|  const auto* us = d_storage.cbegin();
  832|  68.0k|  const auto* p = rhs.d_storage.cbegin();
  833|  1.63M|  for (; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) {
  ------------------
  |  Branch (833:10): [True: 1.56M, False: 66.7k]
  |  Branch (833:36): [True: 1.56M, False: 0]
  ------------------
  834|  1.56M|    if (dns_tolower(*p) != dns_tolower(*us)) {
  ------------------
  |  Branch (834:9): [True: 1.30k, False: 1.56M]
  ------------------
  835|  1.30k|      return false;
  836|  1.30k|    }
  837|  1.56M|  }
  838|  66.7k|  return true;
  839|  68.0k|}
_ZN7DNSNameC2ERKS_:
  164|  2.31k|  DNSName(const DNSName& a) = default;
_ZN7DNSNameC2EOS_:
  165|  64.5k|  DNSName(DNSName&& a) = default;
_ZN7DNSNameC2Ev:
  148|  64.6k|  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:
  475|  62.4k|{
  476|  62.4k|  unsigned char *p = reinterpret_cast<unsigned char*>(&ah);
  477|       |
  478|   685k|  for(unsigned int n = 0; n < sizeof(dnsrecordheader); ++n) {
  ------------------
  |  Branch (478:27): [True: 622k, False: 62.4k]
  ------------------
  479|   622k|    p[n] = d_content.at(d_pos++);
  480|   622k|  }
  481|       |
  482|  62.4k|  ah.d_type = ntohs(ah.d_type);
  483|  62.4k|  ah.d_class = ntohs(ah.d_class);
  484|  62.4k|  ah.d_clen = ntohs(ah.d_clen);
  485|  62.4k|  ah.d_ttl = ntohl(ah.d_ttl);
  486|       |
  487|  62.4k|  d_startrecordpos = d_pos; // needed for getBlob later on
  488|  62.4k|  d_recordlen = ah.d_clen;
  489|  62.4k|  if (d_pos > d_content.size() || (d_content.size() - d_pos) < (d_recordlen)) {
  ------------------
  |  Branch (489:7): [True: 332, False: 62.1k]
  |  Branch (489:35): [True: 126, False: 62.0k]
  ------------------
  490|    126|    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()) + ")");
  491|    126|  }
  492|  62.4k|}
_ZN12PacketReader11get32BitIntEv:
  560|  62.7k|{
  561|  62.7k|  uint32_t ret=0;
  562|  62.7k|  if (!isWithinRecordBoundaries(d_pos, d_pos + sizeof(ret))) {
  ------------------
  |  Branch (562:7): [True: 169, False: 62.5k]
  ------------------
  563|    169|    throw std::out_of_range("Attempt to read 32 bit value outside of record");
  564|    169|  }
  565|  62.5k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  566|  62.5k|  ret<<=8;
  567|  62.5k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  568|  62.5k|  ret<<=8;
  569|  62.5k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  570|  62.5k|  ret<<=8;
  571|  62.5k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  572|       |
  573|  62.5k|  return ret;
  574|  62.7k|}
_ZN12PacketReader11get16BitIntEv:
  578|   203k|{
  579|   203k|  uint16_t ret=0;
  580|   203k|  if (!isWithinRecordBoundaries(d_pos, d_pos + sizeof(ret))) {
  ------------------
  |  Branch (580:7): [True: 44, False: 203k]
  ------------------
  581|     44|    throw std::out_of_range("Attempt to read 16 bit value outside of record");
  582|     44|  }
  583|   203k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  584|   203k|  ret<<=8;
  585|   203k|  ret+=static_cast<uint8_t>(d_content.at(d_pos++));
  586|       |
  587|   203k|  return ret;
  588|   203k|}
_ZN12PacketReader7getNameEv:
  599|   159k|{
  600|   159k|  unsigned int consumed{0};
  601|   159k|  const auto initialPosition = d_pos;
  602|   159k|  try {
  603|   159k|    uint16_t minOffset = d_standalone ? 0 : sizeof(dnsheader);
  ------------------
  |  Branch (603:26): [True: 0, False: 159k]
  ------------------
  604|   159k|    bool uncompress = !d_standalone;
  605|       |
  606|   159k|    DNSName name((const char*) d_content.data(), d_content.size(), d_pos, uncompress, nullptr /* qtype */, nullptr /* qclass */, &consumed, minOffset, &d_pointerBudget);
  607|       |
  608|   159k|    d_pos += consumed;
  609|       |    // if we know the length of the record, and we were parsing a DNS name inside the record contents
  610|       |    // (not the owner name, in which case d_startrecordpos and d_recordlen still refer to the content of the previous record),
  611|       |    // check that we did not go over the record boundary
  612|   159k|    if (!isWithinRecordBoundaries(initialPosition, d_pos, true)) {
  ------------------
  |  Branch (612:9): [True: 11, False: 159k]
  ------------------
  613|     11|      throw std::out_of_range("Attempt to read DNS name outside of record");
  614|     11|    }
  615|   159k|    return name;
  616|   159k|  }
  617|   159k|  catch(const std::range_error& re) {
  618|  1.20k|    throw std::out_of_range(string("dnsname issue: ")+re.what());
  619|  1.20k|  }
  620|   159k|  catch(...) {
  621|     11|    throw std::out_of_range("dnsname issue");
  622|     11|  }
  623|   159k|}
_ZN12PacketReader7xfrBlobERNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE:
  725|  36.6k|{
  726|  36.6k|  try {
  727|  36.6k|    if (d_recordlen != 0 && !(d_pos == (d_startrecordpos + d_recordlen))) {
  ------------------
  |  Branch (727:9): [True: 29.9k, False: 6.61k]
  |  Branch (727:29): [True: 29.9k, False: 0]
  ------------------
  728|  29.9k|      if (d_pos > (d_startrecordpos + d_recordlen)) {
  ------------------
  |  Branch (728:11): [True: 0, False: 29.9k]
  ------------------
  729|      0|        throw std::out_of_range("xfrBlob out of record range");
  730|      0|      }
  731|  29.9k|      blob.assign(&d_content.at(d_pos), &d_content.at(d_startrecordpos + d_recordlen - 1 ) + 1);
  732|  29.9k|    }
  733|  6.61k|    else {
  734|  6.61k|      blob.clear();
  735|  6.61k|    }
  736|       |
  737|  36.6k|    d_pos = d_startrecordpos + d_recordlen;
  738|  36.6k|  }
  739|  36.6k|  catch(...)
  740|  36.6k|  {
  741|      0|    throw std::out_of_range("xfrBlob out of range");
  742|      0|  }
  743|  36.6k|}
_Z16editDNSPacketTTLPcmRKNSt3__18functionIFjhttjEEE:
  947|  5.28k|{
  948|  5.28k|  if(length < sizeof(dnsheader))
  ------------------
  |  Branch (948:6): [True: 0, False: 5.28k]
  ------------------
  949|      0|    return;
  950|  5.28k|  try
  951|  5.28k|  {
  952|  5.28k|    dnsheader dh;
  953|  5.28k|    memcpy((void*)&dh, (const dnsheader*)packet, sizeof(dh));
  954|  5.28k|    uint64_t numrecords = ntohs(dh.ancount) + ntohs(dh.nscount) + ntohs(dh.arcount);
  955|  5.28k|    DNSPacketMangler dpm(packet, length);
  956|       |
  957|  5.28k|    uint64_t n;
  958|  70.2k|    for(n=0; n < ntohs(dh.qdcount) ; ++n) {
  ------------------
  |  Branch (958:14): [True: 64.9k, False: 5.28k]
  ------------------
  959|  64.9k|      dpm.skipDomainName();
  960|       |      /* type and class */
  961|  64.9k|      dpm.skipBytes(4);
  962|  64.9k|    }
  963|       |
  964|   112k|    for(n=0; n < numrecords; ++n) {
  ------------------
  |  Branch (964:14): [True: 107k, False: 5.26k]
  ------------------
  965|   107k|      dpm.skipDomainName();
  966|       |
  967|   107k|      uint8_t section = n < ntohs(dh.ancount) ? 1 : (n < (ntohs(dh.ancount) + ntohs(dh.nscount)) ? 2 : 3);
  ------------------
  |  Branch (967:25): [True: 23.0k, False: 84.6k]
  |  Branch (967:54): [True: 16.3k, False: 68.2k]
  ------------------
  968|   107k|      uint16_t dnstype = dpm.get16BitInt();
  969|   107k|      uint16_t dnsclass = dpm.get16BitInt();
  970|       |
  971|   107k|      if(dnstype == QType::OPT) // not getting near that one with a stick
  ------------------
  |  Branch (971:10): [True: 24, False: 107k]
  ------------------
  972|     24|        break;
  973|       |
  974|   107k|      uint32_t dnsttl = dpm.get32BitInt();
  975|   107k|      uint32_t newttl = visitor(section, dnsclass, dnstype, dnsttl);
  976|   107k|      if (newttl) {
  ------------------
  |  Branch (976:11): [True: 98.0k, False: 9.57k]
  ------------------
  977|  98.0k|        dpm.rewindBytes(sizeof(newttl));
  978|  98.0k|        dpm.setAndSkip32BitInt(newttl);
  979|  98.0k|      }
  980|   107k|      dpm.skipRData();
  981|   107k|    }
  982|  5.28k|  }
  983|  5.28k|  catch(...)
  984|  5.28k|  {
  985|  4.69k|    return;
  986|  4.69k|  }
  987|  5.28k|}

_ZN12PacketReaderC2ERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEtbb:
   72|  5.47k|    : d_pos(initialPos), d_startrecordpos(initialPos), d_internal(internalRepresentation), d_standalone(standalone), d_content(content)
   73|  5.47k|  {
   74|  5.47k|    if (content.size() > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (74:9): [True: 0, False: 5.47k]
  ------------------
   75|      0|      throw std::out_of_range("packet too large");
   76|      0|    }
   77|       |
   78|  5.47k|    d_recordlen = static_cast<uint16_t>(content.size());
   79|  5.47k|    d_pointerBudget = static_cast<size_t>(d_recordlen) * s_MaxPointersPerByte;
   80|  5.47k|  }
_ZN12PacketReader11xfr32BitIntERj:
   96|  58.7k|  {
   97|  58.7k|    val=get32BitInt();
   98|  58.7k|  }
_ZN12PacketReader11xfr16BitIntERt:
  131|   185k|  {
  132|   185k|    val=get16BitInt();
  133|   185k|  }
_ZN12PacketReader7xfrTypeERt:
  136|   126k|  {
  137|   126k|    xfr16BitInt(val);
  138|   126k|  }
_ZN12PacketReader7xfrNameER7DNSNameb:
  147|  64.1k|  {
  148|  64.1k|    name = getName();
  149|  64.1k|  }
_ZNK12PacketReader11getPositionEv:
  212|  58.3k|  {
  213|  58.3k|    return d_pos;
  214|  58.3k|  }
_ZN12PacketReader4skipEt:
  217|  58.3k|  {
  218|  58.3k|    size_t stop = d_pos;
  219|  58.3k|    stop += n;
  220|  58.3k|    if (!isWithinRecordBoundaries(d_pos, d_pos + n)) {
  ------------------
  |  Branch (220:9): [True: 1.12k, False: 57.2k]
  ------------------
  221|  1.12k|      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) + ")");
  222|  1.12k|    }
  223|  57.2k|    if (stop > d_content.size()) {
  ------------------
  |  Branch (223:9): [True: 51, False: 57.2k]
  ------------------
  224|     51|      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()) + ")");
  225|     51|    }
  226|       |
  227|  57.2k|    d_pos += n;
  228|  57.2k|  }
_ZNK12PacketReader24isWithinRecordBoundariesEmmb:
  234|   482k|  {
  235|   482k|    if (initialPosition > endPosition) {
  ------------------
  |  Branch (235:9): [True: 0, False: 482k]
  ------------------
  236|      0|      return false;
  237|      0|    }
  238|   482k|    if (canBeOutsideRecordContent && d_recordlen == 0) {
  ------------------
  |  Branch (238:9): [True: 158k, False: 324k]
  |  Branch (238:38): [True: 13.6k, False: 144k]
  ------------------
  239|       |      // we don't know the record's length, nothing to check
  240|  13.6k|      return true;
  241|  13.6k|    }
  242|   469k|    const size_t endOfRecordContent = d_startrecordpos + d_recordlen;
  243|   469k|    if (canBeOutsideRecordContent && initialPosition >= endOfRecordContent) {
  ------------------
  |  Branch (243:9): [True: 144k, False: 324k]
  |  Branch (243:38): [True: 30.2k, False: 114k]
  ------------------
  244|       |      // our initial position is after the last known record content,
  245|       |      // we are probably parsing the owner name of the next record,
  246|       |      // nothing to check
  247|  30.2k|      return true;
  248|  30.2k|    }
  249|       |    // are we still inside the record's content?
  250|   439k|    return initialPosition >= d_startrecordpos && initialPosition <= endOfRecordContent && endPosition <= endOfRecordContent;
  ------------------
  |  Branch (250:12): [True: 439k, False: 0]
  |  Branch (250:51): [True: 438k, False: 66]
  |  Branch (250:92): [True: 437k, False: 1.27k]
  ------------------
  251|   469k|  }
_ZN16DNSPacketManglerC2EPcm:
  669|  5.28k|    : d_packet(packet), d_length(length), d_notyouroffset(12), d_offset(d_notyouroffset)
  670|  5.28k|  {}
_ZN16DNSPacketMangler14skipDomainNameEv:
  677|   172k|  {
  678|   172k|    uint8_t len{};
  679|   172k|    bool isRoot = true;
  680|   246k|    while ((len = get8BitInt()) != 0) {
  ------------------
  |  Branch (680:12): [True: 131k, False: 114k]
  ------------------
  681|   131k|      isRoot = false;
  682|   131k|      if (len >= 0xc0) { // extended label
  ------------------
  |  Branch (682:11): [True: 58.1k, False: 73.7k]
  ------------------
  683|  58.1k|        get8BitInt();
  684|  58.1k|        return false;
  685|  58.1k|      }
  686|  73.7k|      skipBytes(len);
  687|  73.7k|    }
  688|   114k|    return isRoot;
  689|   172k|  }
_ZN16DNSPacketMangler9skipBytesEt:
  692|   138k|  {
  693|   138k|    moveOffset(bytes);
  694|   138k|  }
_ZN16DNSPacketMangler11rewindBytesEt:
  696|  98.0k|  {
  697|  98.0k|    rewindOffset(by);
  698|  98.0k|  }
_ZN16DNSPacketMangler11get32BitIntEv:
  700|   106k|  {
  701|   106k|    const char* p = d_packet + d_offset;
  702|   106k|    moveOffset(4);
  703|   106k|    uint32_t ret;
  704|   106k|    memcpy(&ret, p, sizeof(ret));
  705|       |    return ntohl(ret);
  706|   106k|  }
_ZN16DNSPacketMangler11get16BitIntEv:
  708|   320k|  {
  709|   320k|    const char* p = d_packet + d_offset;
  710|   320k|    moveOffset(2);
  711|   320k|    uint16_t ret;
  712|   320k|    memcpy(&ret, p, sizeof(ret));
  713|       |    return ntohs(ret);
  714|   320k|  }
_ZN16DNSPacketMangler10get8BitIntEv:
  717|   304k|  {
  718|   304k|    const char* p = d_packet + d_offset;
  719|   304k|    moveOffset(1);
  720|   304k|    return *p;
  721|   304k|  }
_ZN16DNSPacketMangler9skipRDataEv:
  724|   106k|  {
  725|   106k|    auto toskip = get16BitInt();
  726|   106k|    moveOffset(toskip);
  727|   106k|  }
_ZN16DNSPacketMangler18setAndSkip32BitIntEj:
  756|  98.0k|  {
  757|  98.0k|    moveOffset(4);
  758|       |
  759|       |    value = htonl(value);
  760|  98.0k|    memcpy(d_packet + d_offset-4, (const char*)&value, sizeof(value));
  761|  98.0k|  }
_ZN16DNSPacketMangler10moveOffsetEt:
  794|  1.07M|  {
  795|  1.07M|    d_notyouroffset += by;
  796|  1.07M|    if(d_notyouroffset > d_length)
  ------------------
  |  Branch (796:8): [True: 4.69k, False: 1.07M]
  ------------------
  797|  4.69k|      throw std::out_of_range("dns packet out of range: "+std::to_string(d_notyouroffset) +" > "
  798|  4.69k|      + std::to_string(d_length) );
  799|  1.07M|  }
_ZN16DNSPacketMangler12rewindOffsetEt:
  802|  98.0k|  {
  803|  98.0k|    if(d_notyouroffset < by)
  ------------------
  |  Branch (803:8): [True: 0, False: 98.0k]
  ------------------
  804|      0|      throw std::out_of_range("Rewinding dns packet out of range: "+std::to_string(d_notyouroffset) +" < "
  805|      0|                              + std::to_string(by));
  806|  98.0k|    d_notyouroffset -= by;
  807|  98.0k|    if(d_notyouroffset < 12)
  ------------------
  |  Branch (807:8): [True: 0, False: 98.0k]
  ------------------
  808|      0|      throw std::out_of_range("Rewinding dns packet out of range: "+std::to_string(d_notyouroffset) +" < "
  809|      0|                              + std::to_string(12));
  810|  98.0k|  }

_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEEC2ERS6_RK7DNSNametth:
   43|  2.31k|  d_qname(qname), d_content(content)
   44|  2.31k|{
   45|  2.31k|  d_content.clear();
   46|  2.31k|  dnsheader dnsheader;
   47|       |
   48|  2.31k|  memset(&dnsheader, 0, sizeof(dnsheader));
   49|  2.31k|  dnsheader.id=0;
   50|  2.31k|  dnsheader.qdcount=htons(1);
   51|  2.31k|  dnsheader.opcode=opcode;
   52|       |
   53|  2.31k|  const uint8_t* ptr=(const uint8_t*)&dnsheader;
   54|  2.31k|  d_content.reserve(sizeof(dnsheader) + qname.wirelength() + sizeof(qtype) + sizeof(qclass));
   55|  2.31k|  d_content.resize(sizeof(dnsheader));
   56|  2.31k|  uint8_t* dptr=(&*d_content.begin());
   57|       |
   58|  2.31k|  memcpy(dptr, ptr, sizeof(dnsheader));
   59|  2.31k|  d_namepositions.reserve(16);
   60|  2.31k|  xfrName(qname, false);
   61|  2.31k|  xfr16BitInt(qtype);
   62|  2.31k|  xfr16BitInt(qclass);
   63|       |
   64|  2.31k|  if (d_content.size() > std::numeric_limits<decltype(d_truncatemarker)>::max()) {
  ------------------
  |  Branch (64:7): [True: 0, False: 2.31k]
  ------------------
   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.31k|  d_truncatemarker = d_content.size();
   68|  2.31k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11startRecordERK7DNSNametjtN17DNSResourceRecord5PlaceEb:
   77|  62.0k|{
   78|  62.0k|  d_compress = compress;
   79|  62.0k|  commit();
   80|  62.0k|  if (d_content.size() > std::numeric_limits<decltype(d_rollbackmarker)>::max()) {
  ------------------
  |  Branch (80:7): [True: 0, False: 62.0k]
  ------------------
   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|  62.0k|  d_rollbackmarker = d_content.size();
   84|       |
   85|  62.0k|  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: 62.0k, False: 17]
  |  Branch (85:19): [True: 57.9k, False: 4.10k]
  |  Branch (85:37): [True: 32.0k, False: 25.8k]
  ------------------
   86|  32.0k|    static const std::array<unsigned char, 2> marker{0xc0, 0x0c};
   87|  32.0k|    d_content.insert(d_content.end(), reinterpret_cast<const char *>(marker.begin()), reinterpret_cast<const char *>(marker.end()));
   88|  32.0k|  }
   89|  30.0k|  else {
   90|  30.0k|    xfrName(name, compress);
   91|  30.0k|  }
   92|  62.0k|  xfr16BitInt(qtype);
   93|  62.0k|  xfr16BitInt(qclass);
   94|  62.0k|  xfr32BitInt(ttl);
   95|  62.0k|  xfr16BitInt(0); // this will be the record size
   96|  62.0k|  d_recordplace = place;
   97|       |
   98|  62.0k|  d_sor = d_content.size(); // this will remind us where to stuff the record size
   99|  62.0k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE6commitEv:
  594|  62.4k|{
  595|  62.4k|  if (d_sor == 0) {
  ------------------
  |  Branch (595:7): [True: 1.76k, False: 60.7k]
  ------------------
  596|  1.76k|    return;
  597|  1.76k|  }
  598|       |
  599|  60.7k|  if (d_sor < 2 || d_sor > d_content.size()) {
  ------------------
  |  Branch (599:7): [True: 0, False: 60.7k]
  |  Branch (599:20): [True: 0, False: 60.7k]
  ------------------
  600|      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()));
  601|      0|  }
  602|       |
  603|  60.7k|  if (d_content.size() > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (603:7): [True: 22, False: 60.6k]
  ------------------
  604|     22|    throw std::range_error("Trying to build a packet larger than " + std::to_string(std::numeric_limits<uint16_t>::max()) + " bytes");
  605|     22|  }
  606|       |
  607|  60.6k|  uint16_t rlen = d_content.size() - d_sor;
  608|  60.6k|  d_content.at(d_sor-2) = rlen >> 8;
  609|  60.6k|  d_content.at(d_sor-1) = rlen & 0xff;
  610|  60.6k|  d_sor = 0;
  611|  60.6k|  auto* dh = reinterpret_cast<dnsheader*>( &*d_content.begin());
  612|  60.6k|  switch(d_recordplace) {
  ------------------
  |  Branch (612:10): [True: 60.6k, False: 0]
  ------------------
  613|      0|  case DNSResourceRecord::QUESTION:
  ------------------
  |  Branch (613:3): [True: 0, False: 60.6k]
  ------------------
  614|      0|    dh->qdcount = htons(ntohs(dh->qdcount) + 1);
  615|      0|    break;
  616|  17.6k|  case DNSResourceRecord::ANSWER:
  ------------------
  |  Branch (616:3): [True: 17.6k, False: 43.0k]
  ------------------
  617|  17.6k|    dh->ancount = htons(ntohs(dh->ancount) + 1);
  618|  17.6k|    break;
  619|  14.0k|  case DNSResourceRecord::AUTHORITY:
  ------------------
  |  Branch (619:3): [True: 14.0k, False: 46.6k]
  ------------------
  620|  14.0k|    dh->nscount = htons(ntohs(dh->nscount) + 1);
  621|  14.0k|    break;
  622|  28.9k|  case DNSResourceRecord::ADDITIONAL:
  ------------------
  |  Branch (622:3): [True: 28.9k, False: 31.7k]
  ------------------
  623|  28.9k|    dh->arcount = htons(ntohs(dh->arcount) + 1);
  624|  28.9k|    break;
  625|  60.6k|  }
  626|       |
  627|  60.6k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11xfr32BitIntEm:
  155|  65.8k|{
  156|  65.8k|  if (val > std::numeric_limits<uint32_t>::max()) {
  ------------------
  |  Branch (156:7): [True: 0, False: 65.8k]
  ------------------
  157|      0|    throw runtime_error("Value too large to fit in 32 bits");
  158|      0|  }
  159|  65.8k|  uint32_t rval=htonl(static_cast<uint32_t>(val));
  160|  65.8k|  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval);
  161|  65.8k|  d_content.insert(d_content.end(), ptr, ptr+4);
  162|  65.8k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE11xfr16BitIntEm:
  165|   196k|{
  166|   196k|  if (val > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (166:7): [True: 0, False: 196k]
  ------------------
  167|      0|    throw runtime_error("Value too large to fit in 16 bits");
  168|      0|  }
  169|   196k|  uint16_t rval=htons(static_cast<uint16_t>(val));
  170|   196k|  uint8_t* ptr=reinterpret_cast<uint8_t*>(&rval);
  171|   196k|  d_content.insert(d_content.end(), ptr, ptr+2);
  172|   196k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE7xfrNameERK7DNSNameb:
  415|  58.1k|{
  416|  58.1k|  if(l_verbose)
  ------------------
  |  Branch (416:6): [Folded, False: 58.1k]
  ------------------
  417|      0|    cout<<"Wants to write "<<name<<", compress="<<compress<<", canonic="<<d_canonic<<", LC="<<d_lowerCase<<endl;
  418|  58.1k|  if(d_canonic || d_lowerCase)   // d_lowerCase implies canonic
  ------------------
  |  Branch (418:6): [True: 0, False: 58.1k]
  |  Branch (418:19): [True: 0, False: 58.1k]
  ------------------
  419|      0|    compress=false;
  420|       |
  421|  58.1k|  if(name.empty() || name.isRoot()) { // for speed
  ------------------
  |  Branch (421:6): [True: 0, False: 58.1k]
  |  Branch (421:22): [True: 8.72k, False: 49.4k]
  ------------------
  422|  8.72k|    d_content.push_back(0);
  423|  8.72k|    return;
  424|  8.72k|  }
  425|       |
  426|  49.4k|  uint16_t li=0;
  427|  49.4k|  uint16_t matchlen=0;
  428|  49.4k|  if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < maxCompressionOffset) {
  ------------------
  |  Branch (428:6): [True: 47.1k, False: 2.31k]
  |  Branch (428:20): [True: 44.2k, False: 2.84k]
  |  Branch (428:32): [True: 12.4k, False: 31.8k]
  |  Branch (428:68): [True: 12.4k, False: 0]
  ------------------
  429|  12.4k|    const auto& dns=name.getStorage();
  430|  12.4k|    if(l_verbose)
  ------------------
  |  Branch (430:8): [Folded, False: 12.4k]
  ------------------
  431|      0|      cout<<"Found a substring of "<<matchlen<<" bytes from the back, offset: "<<li<<", dnslen: "<<dns.size()<<endl;
  432|       |    // found a substring, if www.powerdns.com matched powerdns.com, we get back matchlen = 13
  433|       |
  434|  12.4k|    unsigned int pos=d_content.size();
  435|  12.4k|    if(pos < maxCompressionOffset && matchlen != dns.size()) {
  ------------------
  |  Branch (435:8): [True: 9.35k, False: 3.10k]
  |  Branch (435:38): [True: 1.08k, False: 8.27k]
  ------------------
  436|  1.08k|      if(l_verbose)
  ------------------
  |  Branch (436:10): [Folded, False: 1.08k]
  ------------------
  437|      0|        cout<<"Inserting pos "<<pos<<" for "<<name<<" for compressed case"<<endl;
  438|  1.08k|      d_namepositions.push_back(pos);
  439|  1.08k|    }
  440|       |
  441|  12.4k|    if(l_verbose)
  ------------------
  |  Branch (441:8): [Folded, False: 12.4k]
  ------------------
  442|      0|      cout<<"Going to write unique part: '"<<makeHexDump(string(dns.c_str(), dns.c_str() + dns.size() - matchlen)) <<"'"<<endl;
  443|  12.4k|    d_content.insert(d_content.end(), (const unsigned char*)dns.c_str(), (const unsigned char*)dns.c_str() + dns.size() - matchlen);
  444|  12.4k|    uint16_t offset=li;
  445|  12.4k|    offset|=0xc000;
  446|       |
  447|  12.4k|    d_content.push_back((char)(offset >> 8));
  448|  12.4k|    d_content.push_back((char)(offset & 0xff));
  449|  12.4k|  }
  450|  36.9k|  else {
  451|  36.9k|    unsigned int pos=d_content.size();
  452|  36.9k|    if(l_verbose)
  ------------------
  |  Branch (452:8): [Folded, False: 36.9k]
  ------------------
  453|      0|      cout<<"Found nothing, we are at pos "<<pos<<", inserting whole name"<<endl;
  454|  36.9k|    if(pos < maxCompressionOffset) {
  ------------------
  |  Branch (454:8): [True: 23.0k, False: 13.9k]
  ------------------
  455|  23.0k|      if(l_verbose)
  ------------------
  |  Branch (455:10): [Folded, False: 23.0k]
  ------------------
  456|      0|        cout<<"Inserting pos "<<pos<<" for "<<name<<" for uncompressed case"<<endl;
  457|  23.0k|      d_namepositions.push_back(pos);
  458|  23.0k|    }
  459|       |
  460|  36.9k|    std::unique_ptr<DNSName> lc;
  461|  36.9k|    if(d_lowerCase)
  ------------------
  |  Branch (461:8): [True: 0, False: 36.9k]
  ------------------
  462|      0|      lc = make_unique<DNSName>(name.makeLowerCase());
  463|       |
  464|  36.9k|    const DNSName::string_t& raw = (lc ? *lc : name).getStorage();
  ------------------
  |  Branch (464:37): [True: 0, False: 36.9k]
  ------------------
  465|  36.9k|    if(l_verbose)
  ------------------
  |  Branch (465:8): [Folded, False: 36.9k]
  ------------------
  466|      0|      cout<<"Writing out the whole thing "<<makeHexDump(string(raw.c_str(),  raw.c_str() + raw.length()))<<endl;
  467|  36.9k|    d_content.insert(d_content.end(), raw.c_str(), raw.c_str() + raw.size());
  468|  36.9k|  }
  469|  49.4k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE7xfrBlobERKNS0_12basic_stringIcNS0_11char_traitsIcEENS3_IcEEEEi:
  472|  36.6k|{
  473|  36.6k|  const uint8_t* ptr=reinterpret_cast<const uint8_t*>(blob.c_str());
  474|  36.6k|  d_content.insert(d_content.end(), ptr, ptr+blob.size());
  475|  36.6k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE9getHeaderEv:
   71|  20.8k|{
   72|  20.8k|  return reinterpret_cast<dnsheader*>(&*d_content.begin());
   73|  20.8k|}
_ZN22GenericDNSPacketWriterINSt3__16vectorIh14noinit_adaptorINS0_9allocatorIhEEEEEE10lookupNameERK7DNSNamePt:
  249|  44.2k|{
  250|       |  // iterate over the written labels, see if we find a match
  251|  44.2k|  const auto& raw = name.getStorage();
  252|       |
  253|       |  /* name might be a.root-servers.net, we need to be able to benefit from finding:
  254|       |     b.root-servers.net, or even:
  255|       |     b\xc0\x0c
  256|       |  */
  257|  44.2k|  unsigned int bestpos=0;
  258|  44.2k|  *matchLen = 0;
  259|       |
  260|       |  // positions of each label in the name we are trying to compress
  261|  44.2k|  boost::container::static_vector<uint16_t, 34> positionsInName;
  262|       |  // positions of labels in the packet we are building
  263|  44.2k|  boost::container::static_vector<uint16_t, 34> positionsInPacket;
  264|       |
  265|  44.2k|  try {
  266|  1.13M|    for(auto riter= raw.cbegin(); riter < raw.cend(); ) {
  ------------------
  |  Branch (266:35): [True: 1.10M, False: 29.3k]
  ------------------
  267|  1.10M|      if (*riter == 0) {
  ------------------
  |  Branch (267:11): [True: 14.9k, False: 1.09M]
  ------------------
  268|  14.9k|        break;
  269|  14.9k|      }
  270|  1.09M|      positionsInName.push_back(riter - raw.cbegin());
  271|  1.09M|      riter += *riter + 1;
  272|  1.09M|    }
  273|  44.2k|  }
  274|  44.2k|  catch (const std::bad_alloc& ba) {
  275|  29.3k|    if (l_verbose) {
  ------------------
  |  Branch (275:9): [Folded, False: 29.3k]
  ------------------
  276|      0|      cout << "Domain " << name << " too large to compress" << endl;
  277|      0|    }
  278|  29.3k|    return 0;
  279|  29.3k|  }
  280|       |
  281|  14.9k|  if (l_verbose) {
  ------------------
  |  Branch (281:7): [Folded, False: 14.9k]
  ------------------
  282|      0|    cout<<"Input vector for lookup "<<name<<": ";
  283|      0|    for (const auto n : positionsInName) {
  ------------------
  |  Branch (283:23): [True: 0, False: 0]
  ------------------
  284|      0|      cout << n << " ";
  285|      0|    }
  286|      0|    cout<<endl;
  287|      0|    cout<<makeHexDump(string(raw.c_str(), raw.c_str()+raw.size()))<<endl;
  288|      0|  }
  289|       |
  290|  14.9k|  if (l_verbose) {
  ------------------
  |  Branch (290:7): [Folded, False: 14.9k]
  ------------------
  291|      0|    cout << "Have " << d_namepositions.size() << " to ponder" << endl;
  292|      0|  }
  293|       |
  294|  14.9k|  int counter=1;
  295|   171k|  for (const auto positionInPacket : d_namepositions) {
  ------------------
  |  Branch (295:36): [True: 171k, False: 3.89k]
  ------------------
  296|       |    // here it's a bit tricky because the names might be compressed,
  297|       |    // so we will gather all labels composing the name, following
  298|       |    // pointers if needed
  299|       |    // for example if there is an uncompressed \1a\1b\1c\0 we will store
  300|       |    // the position of \1a, \1b, \1c
  301|       |    // if there is instead \1a followed by a pointer to \1b\1c\0 earlier
  302|       |    // in the packet we will store the position of \1a, \1b, \1c as well
  303|       |    // they will just be disjoint
  304|   171k|    if (l_verbose) {
  ------------------
  |  Branch (304:9): [Folded, False: 171k]
  ------------------
  305|      0|      cout<<"Pos: "<<positionInPacket<<", "<<d_content.size()<<endl;
  306|      0|      DNSName pname(reinterpret_cast<const char*>(d_content.data()), d_content.size(), positionInPacket, true); // only for debugging
  307|      0|      cout<<"Looking at '"<<pname<<"' in packet at position "<<positionInPacket<<"/"<<d_content.size()<<", option "<<counter<<"/"<<d_namepositions.size()<<endl;
  308|      0|      ++counter;
  309|      0|    }
  310|   171k|    size_t pointerQuota = 50U;
  311|       |    // memcmp here makes things _slower_
  312|   171k|    positionsInPacket.clear();
  313|   171k|    try {
  314|  4.34M|      for (auto iter = d_content.cbegin() + positionInPacket; iter < d_content.cend() && pointerQuota > 0;) {
  ------------------
  |  Branch (314:63): [True: 4.23M, False: 110k]
  |  Branch (314:63): [True: 4.23M, False: 110k]
  |  Branch (314:90): [True: 4.23M, False: 0]
  ------------------
  315|  4.23M|        uint8_t labelLength = *iter;
  316|  4.23M|        const uint16_t currentPos = (iter - d_content.cbegin());
  317|  4.23M|        if (l_verbose) {
  ------------------
  |  Branch (317:13): [Folded, False: 4.23M]
  ------------------
  318|      0|          cout << "Found label length: " << std::to_string(labelLength) << " at " << currentPos << endl;
  319|      0|        }
  320|  4.23M|        if (labelLength & 0xc0) {
  ------------------
  |  Branch (320:13): [True: 23.1k, False: 4.21M]
  ------------------
  321|  23.1k|          uint16_t npos = 0x100*(labelLength & (~0xc0)) + *++iter;
  322|       |          // check against going forward
  323|  23.1k|          if (npos >= currentPos || npos < sizeof(dnsheader)) {
  ------------------
  |  Branch (323:15): [True: 0, False: 23.1k]
  |  Branch (323:37): [True: 0, False: 23.1k]
  ------------------
  324|       |            /* something is not right */
  325|      0|            break;
  326|      0|          }
  327|       |
  328|       |          // jump to the target of the pointer
  329|  23.1k|          iter = d_content.begin() + npos;
  330|  23.1k|          if (l_verbose) {
  ------------------
  |  Branch (330:15): [Folded, False: 23.1k]
  ------------------
  331|      0|            cout << "Is compressed label to newpos " << npos << ", going there" << endl;
  332|      0|          }
  333|       |
  334|  23.1k|          if (pointerQuota >= 1) {
  ------------------
  |  Branch (334:15): [True: 23.1k, False: 0]
  ------------------
  335|  23.1k|            pointerQuota--;
  336|  23.1k|            continue;
  337|  23.1k|          }
  338|       |
  339|       |          // out of pointer quota, let's stop there
  340|      0|          break;
  341|  23.1k|        }
  342|       |
  343|  4.21M|        if (labelLength == 0) {
  ------------------
  |  Branch (343:13): [True: 60.6k, False: 4.15M]
  ------------------
  344|  60.6k|          break;
  345|  60.6k|        }
  346|       |
  347|  4.15M|        if (currentPos >= maxCompressionOffset) {
  ------------------
  |  Branch (347:13): [True: 768, False: 4.15M]
  ------------------
  348|    768|          break; // compression pointers cannot point here
  349|    768|        }
  350|       |
  351|  4.15M|        positionsInPacket.push_back(currentPos);
  352|       |        // jump to the next label
  353|  4.15M|        iter += labelLength + 1;
  354|  4.15M|      }
  355|   171k|    }
  356|   171k|    catch (const std::bad_alloc& ba) {
  357|   110k|      if (l_verbose) {
  ------------------
  |  Branch (357:11): [Folded, False: 110k]
  ------------------
  358|      0|        cout << "Domain " << name << " too large to compress" << endl;
  359|      0|      }
  360|   110k|      continue;
  361|   110k|    }
  362|       |
  363|  61.4k|    if (l_verbose) {
  ------------------
  |  Branch (363:9): [Folded, False: 61.4k]
  ------------------
  364|      0|      cout<<"Packet vector: "<<endl;
  365|      0|      for (const auto n : positionsInPacket) {
  ------------------
  |  Branch (365:25): [True: 0, False: 0]
  ------------------
  366|      0|        cout << n << " ";
  367|      0|      }
  368|      0|      cout<<endl;
  369|      0|    }
  370|       |
  371|  61.4k|    auto positionInNameIter = positionsInName.crbegin();
  372|  61.4k|    auto positionInPacketIter = positionsInPacket.crbegin();
  373|  61.4k|    unsigned int cmatchlen=1;
  374|   130k|    for(; positionInNameIter != positionsInName.crend() && positionInPacketIter != positionsInPacket.crend(); ++positionInNameIter, ++positionInPacketIter) {
  ------------------
  |  Branch (374:11): [True: 130k, False: 0]
  |  Branch (374:11): [True: 127k, False: 2.91k]
  |  Branch (374:60): [True: 127k, False: 2.91k]
  ------------------
  375|       |      // positionInNameIter is an offset in raw, pvect an offset in packet
  376|   127k|      uint8_t nlen = raw[*positionInNameIter];
  377|   127k|      uint8_t plen = d_content[*positionInPacketIter];
  378|       |
  379|   127k|      if (l_verbose) {
  ------------------
  |  Branch (379:11): [Folded, False: 127k]
  ------------------
  380|      0|        cout << "nlnen=" << (int)nlen << ", plen=" << (int)plen << endl;
  381|      0|      }
  382|       |
  383|   127k|      if (nlen != plen) {
  ------------------
  |  Branch (383:11): [True: 35.5k, False: 91.6k]
  ------------------
  384|  35.5k|        break;
  385|  35.5k|      }
  386|       |
  387|  91.6k|      auto rawpart = std::string_view(raw.c_str() + *positionInNameIter + 1, nlen); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  388|  91.6k|      auto pktpart = std::string_view((const char*)&d_content[*positionInPacketIter] + 1, nlen); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
  389|  91.6k|      if (pdns_ilexicographical_compare_three_way(rawpart, pktpart) != 0) {
  ------------------
  |  Branch (389:11): [True: 11.8k, False: 79.7k]
  ------------------
  390|  11.8k|        if (l_verbose) {
  ------------------
  |  Branch (390:13): [Folded, False: 11.8k]
  ------------------
  391|      0|          cout << "Mismatch: " << rawpart << " != " << pktpart << endl;
  392|      0|        }
  393|  11.8k|        break;
  394|  11.8k|      }
  395|       |
  396|  79.7k|      cmatchlen += nlen + 1;
  397|  79.7k|      if (cmatchlen == raw.length()) { // have matched all of it, can't improve
  ------------------
  |  Branch (397:11): [True: 11.0k, False: 68.7k]
  ------------------
  398|  11.0k|        if (l_verbose) {
  ------------------
  |  Branch (398:13): [Folded, False: 11.0k]
  ------------------
  399|      0|          cout << "Stopping search, matched whole name" << endl;
  400|      0|        }
  401|       |
  402|  11.0k|        *matchLen = cmatchlen;
  403|  11.0k|        return *positionInPacketIter;
  404|  11.0k|      }
  405|  79.7k|    }
  406|  50.3k|    if (positionInPacketIter != positionsInPacket.crbegin() && *matchLen < cmatchlen) {
  ------------------
  |  Branch (406:9): [True: 11.6k, False: 38.6k]
  |  Branch (406:9): [True: 4.48k, False: 45.8k]
  |  Branch (406:64): [True: 4.48k, False: 7.20k]
  ------------------
  407|  4.48k|      *matchLen = cmatchlen;
  408|  4.48k|      bestpos = *--positionInPacketIter;
  409|  4.48k|    }
  410|  50.3k|  }
  411|  3.89k|  return bestpos;
  412|  14.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.65k|{
   25|  2.65k|  if (size < sizeof(dnsheader) || size > std::numeric_limits<uint16_t>::max()) {
  ------------------
  |  Branch (25:7): [True: 6, False: 2.65k]
  |  Branch (25:35): [True: 9, False: 2.64k]
  ------------------
   26|     15|    return 0;
   27|     15|  }
   28|       |
   29|       |  // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   30|  2.64k|  const PacketBuffer packet(data, data + size);
   31|       |  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
   32|  2.64k|  const std::string_view view(reinterpret_cast<const char*>(packet.data()), packet.size());
   33|       |
   34|  2.64k|  try {
   35|  2.64k|    parseRecords(view);
   36|  2.64k|  }
   37|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   38|  2.64k|  catch (const std::exception&) {
   39|  2.38k|  }
   40|       |
   41|  2.64k|  try {
   42|  2.64k|    unsigned int consumed = 0;
   43|       |    // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
   44|  2.64k|    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.64k|    const DNSName replacement(std::string(1U + (data[0] % 63U), static_cast<char>('a' + (data[1] % 26U))) + ".example.");
   48|  2.64k|    PacketBuffer rewritten(packet);
   49|  2.64k|    if (dnsdist::changeNameInDNSPacket(rewritten, original, replacement)) {
  ------------------
  |  Branch (49:9): [True: 426, False: 2.21k]
  ------------------
   50|       |      // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
   51|    426|      parseRecords(std::string_view(reinterpret_cast<const char*>(rewritten.data()), rewritten.size()));
   52|    426|    }
   53|  2.64k|  }
   54|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   55|  2.64k|  catch (const std::exception&) {
   56|  1.88k|  }
   57|       |
   58|  2.64k|  try {
   59|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   60|  2.64k|    const uint32_t first = (static_cast<uint32_t>(data[0]) << 8U) | data[1];
   61|       |    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
   62|  2.64k|    const uint32_t second = (static_cast<uint32_t>(data[2]) << 8U) | data[3];
   63|  2.64k|    PacketBuffer restricted(packet);
   64|  2.64k|    dnsdist::PacketMangling::restrictDNSPacketTTLs(restricted, std::min(first, second), std::max(first, second));
   65|  2.64k|    dnsdist::PacketMangling::restrictDNSPacketTTLs(restricted, 0, second, {QType::A, QType::AAAA});
   66|  2.64k|  }
   67|       |  // NOLINTNEXTLINE(bugprone-empty-catch)
   68|  2.64k|  catch (const std::exception&) {
   69|      0|  }
   70|       |
   71|  2.64k|  PacketBuffer edited(packet);
   72|  2.64k|  dnsdist::PacketMangling::editDNSHeaderFromPacket(edited, [](dnsheader& header) {
   73|  2.64k|    header.rd = !header.rd;
   74|  2.64k|    header.cd = !header.cd;
   75|  2.64k|    return true;
   76|  2.64k|  });
   77|       |
   78|  2.64k|  return 0;
   79|  2.64k|}
fuzz_dnsdist_dnsparser.cc:_ZN12_GLOBAL__N_112parseRecordsERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEE:
   12|  3.07k|{
   13|  3.07k|  const dnsdist::DNSPacketOverlay overlay(packet);
   14|  14.4k|  for (const auto& record : overlay.d_records) {
  ------------------
  |  Branch (14:27): [True: 14.4k, False: 3.07k]
  ------------------
   15|  14.4k|    dnsdist::RecordParsers::parseAddressRecord(packet, record);
   16|  14.4k|    dnsdist::RecordParsers::parseCNAMERecord(packet, record);
   17|  14.4k|  }
   18|  3.07k|}
fuzz_dnsdist_dnsparser.cc:_ZZ22LLVMFuzzerTestOneInputENK3$_0clER9dnsheader:
   72|  2.64k|  dnsdist::PacketMangling::editDNSHeaderFromPacket(edited, [](dnsheader& header) {
   73|  2.64k|    header.rd = !header.rd;
   74|  2.64k|    header.cd = !header.cd;
   75|  2.64k|    return true;
   76|  2.64k|  });

_ZN12ComboAddressC2Ev:
  212|    860|  {
  213|       |    sin4.sin_family = AF_INET;
  214|    860|    sin4.sin_addr.s_addr = 0;
  215|    860|    sin4.sin_port = 0;
  216|    860|    sin6.sin6_scope_id = 0;
  217|    860|    sin6.sin6_flowinfo = 0;
  218|    860|  }
_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|    850|{
  662|    850|  ComboAddress address;
  663|       |
  664|    850|  if (version == 4) {
  ------------------
  |  Branch (664:7): [True: 248, False: 602]
  ------------------
  665|    248|    address.sin4.sin_family = AF_INET;
  666|    248|    if (len != sizeof(address.sin4.sin_addr)) {
  ------------------
  |  Branch (666:9): [True: 0, False: 248]
  ------------------
  667|      0|      throw NetmaskException("invalid raw address length");
  668|      0|    }
  669|    248|    memcpy(&address.sin4.sin_addr, raw, sizeof(address.sin4.sin_addr));
  670|    248|  }
  671|    602|  else if (version == 6) {
  ------------------
  |  Branch (671:12): [True: 602, False: 0]
  ------------------
  672|    602|    address.sin6.sin6_family = AF_INET6;
  673|    602|    if (len != sizeof(address.sin6.sin6_addr)) {
  ------------------
  |  Branch (673:9): [True: 0, False: 602]
  ------------------
  674|      0|      throw NetmaskException("invalid raw address length");
  675|      0|    }
  676|    602|    memcpy(&address.sin6.sin6_addr, raw, sizeof(address.sin6.sin6_addr));
  677|    602|  }
  678|      0|  else {
  679|      0|    throw NetmaskException("invalid address family");
  680|      0|  }
  681|       |
  682|    850|  return address;
  683|    850|}
_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:
  476|      2|{
  477|      2|  const size_t maxHostNameBufSize = getMaxHostNameSize() + 1;
  478|      2|  std::string hostname;
  479|      2|  hostname.resize(maxHostNameBufSize, 0);
  480|       |
  481|      2|  if (gethostname(hostname.data(), maxHostNameBufSize) == -1) {
  ------------------
  |  Branch (481:7): [True: 0, False: 2]
  ------------------
  482|      0|    return std::nullopt;
  483|      0|  }
  484|       |
  485|      2|  hostname.resize(strlen(hostname.c_str()));
  486|      2|  return std::make_optional(hostname);
  487|      2|}
_Z16makeIPv4sockaddrRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEP11sockaddr_in:
  775|      2|{
  776|      2|  std::string str(arg);
  777|      2|  if (str.empty()) {
  ------------------
  |  Branch (777:7): [True: 0, False: 2]
  ------------------
  778|      0|    return -1;
  779|      0|  }
  780|      2|  struct in_addr inp{};
  781|       |
  782|      2|  string::size_type pos = str.find(':');
  783|      2|  if (pos == string::npos) { // no port specified, not touching the port
  ------------------
  |  Branch (783:7): [True: 0, False: 2]
  ------------------
  784|      0|    if (inet_aton(str.c_str(), &inp) != 0) {
  ------------------
  |  Branch (784:9): [True: 0, False: 0]
  ------------------
  785|      0|      ret->sin_addr.s_addr = inp.s_addr;
  786|      0|      return 0;
  787|      0|    }
  788|      0|    return -1;
  789|      0|  }
  790|      2|  if (*(str.c_str() + pos + 1) == 0) { // trailing :
  ------------------
  |  Branch (790:7): [True: 0, False: 2]
  ------------------
  791|      0|    return -1;
  792|      0|  }
  793|       |
  794|      2|  auto* eptr = str.data() + str.size();
  795|      2|  int port = static_cast<int>(strtol(str.c_str() + pos + 1, &eptr, 10));
  796|      2|  if (port < 0 || port > 65535) {
  ------------------
  |  Branch (796:7): [True: 0, False: 2]
  |  Branch (796:19): [True: 0, False: 2]
  ------------------
  797|      0|    return -1;
  798|      0|  }
  799|      2|  if (*eptr != 0) {
  ------------------
  |  Branch (799:7): [True: 0, False: 2]
  ------------------
  800|      0|    return -1;
  801|      0|  }
  802|       |
  803|      2|  ret->sin_port = htons(port);
  804|      2|  if (inet_aton(str.substr(0, pos).c_str(), &inp) != 0) {
  ------------------
  |  Branch (804:7): [True: 2, False: 0]
  ------------------
  805|      2|    ret->sin_addr.s_addr = inp.s_addr;
  806|      2|    return 0;
  807|      2|  }
  808|      0|  return -1;
  809|      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|  const size_t maxHostNameSize = 255;
  468|      0|#if defined(_SC_HOST_NAME_MAX)
  469|      0|  return pdns::sysconf(_SC_HOST_NAME_MAX, maxHostNameSize);
  470|      0|#endif
  471|       |
  472|      0|  return maxHostNameSize;
  473|      2|}

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

_ZN14noinit_adaptorINSt3__19allocatorIhEEEC2Ev:
   22|  4.95k|  noinit_adaptor(): Allocator() { }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRKhJEEEvPT_OT0_DpOT1_:
   36|  6.83M|  void construct(U* p, V&& v, Args&&... args) {
   37|  6.83M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  6.83M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE7destroyIhEEvPT_:
   41|  40.4M|  void destroy(U* p) {
   42|  40.4M|    p->~U();
   43|  40.4M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRhJEEEvPT_OT0_DpOT1_:
   36|  15.3M|  void construct(U* p, V&& v, Args&&... args) {
   37|  15.3M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  15.3M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhEEvPT_:
   31|  27.7k|  void construct(U* p) {
   32|  27.7k|    ::new((void*)p) U;
   33|  27.7k|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhhJEEEvPT_OT0_DpOT1_:
   36|  10.9M|  void construct(U* p, V&& v, Args&&... args) {
   37|  10.9M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  10.9M|  }
_ZN14noinit_adaptorINSt3__19allocatorIhEEE9constructIhRKcJEEEvPT_OT0_DpOT1_:
   36|  7.26M|  void construct(U* p, V&& v, Args&&... args) {
   37|  7.26M|    ::new((void*)p) U(std::forward<V>(v), std::forward<Args>(args)...);
   38|  7.26M|  }

_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:
   98|      2|{
   99|      2|  std::map<uint16_t, const std::string> ret;
  100|       |
  101|    128|  for (const auto& name : names) {
  ------------------
  |  Branch (101:25): [True: 128, False: 2]
  ------------------
  102|    128|    ret.emplace(name.second, name.first);
  103|    128|  }
  104|      2|  return ret;
  105|      2|}

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

_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|   225k|    view(data_, size_)
   34|   225k|  {
   35|   225k|  }
_ZNK4pdns5views16UnsignedCharView2atEm:
   44|  2.33M|  {
   45|  2.33M|    return reinterpret_cast<const unsigned char&>(view.at(pos));
   46|  2.33M|  }
_ZNK4pdns5views16UnsignedCharView4sizeEv:
   60|  3.53M|  {
   61|  3.53M|    return view.size();
   62|  3.53M|  }

