From: Otto Moerbeek Date: Wed, 16 Jul 2025 13:33:18 +0000 (+0200) Subject: Let fuzz test compile, slowParseEDNSOptions moved X-Git-Tag: rec-5.0.12~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F15853%2Fhead;p=thirdparty%2Fpdns.git Let fuzz test compile, slowParseEDNSOptions moved Signed-off-by: Otto Moerbeek --- diff --git a/pdns/dnsdist-ecs.cc b/pdns/dnsdist-ecs.cc index 2cad1945bc..60840575e7 100644 --- a/pdns/dnsdist-ecs.cc +++ b/pdns/dnsdist-ecs.cc @@ -266,62 +266,6 @@ bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, return true; } -static bool slowParseEDNSOptions(const PacketBuffer& packet, EDNSOptionViewMap& options) -{ - if (packet.size() < sizeof(dnsheader)) { - return false; - } - - const dnsheader_aligned dh(packet.data()); - - if (ntohs(dh->qdcount) == 0) { - return false; - } - - if (ntohs(dh->arcount) == 0) { - throw std::runtime_error("slowParseEDNSOptions() should not be called for queries that have no EDNS"); - } - - try { - uint64_t numrecords = ntohs(dh->ancount) + ntohs(dh->nscount) + ntohs(dh->arcount); - DNSPacketMangler dpm(const_cast(reinterpret_cast(&packet.at(0))), packet.size()); - uint64_t n; - for(n=0; n < ntohs(dh->qdcount) ; ++n) { - dpm.skipDomainName(); - /* type and class */ - dpm.skipBytes(4); - } - - for(n=0; n < numrecords; ++n) { - dpm.skipDomainName(); - - uint8_t section = n < ntohs(dh->ancount) ? 1 : (n < (ntohs(dh->ancount) + ntohs(dh->nscount)) ? 2 : 3); - uint16_t dnstype = dpm.get16BitInt(); - dpm.get16BitInt(); - dpm.skipBytes(4); /* TTL */ - - if(section == 3 && dnstype == QType::OPT) { - uint32_t offset = dpm.getOffset(); - if (offset >= packet.size()) { - return false; - } - /* if we survive this call, we can parse it safely */ - dpm.skipRData(); - return getEDNSOptions(reinterpret_cast(&packet.at(offset)), packet.size() - offset, options) == 0; - } - else { - dpm.skipRData(); - } - } - } - catch(...) - { - return false; - } - - return true; -} - int locateEDNSOptRR(const PacketBuffer& packet, uint16_t * optStart, size_t * optLen, bool * last) { assert(optStart != NULL);