From: Remi Gacogne Date: Fri, 29 Oct 2021 13:10:03 +0000 (+0200) Subject: dnsdist: Only update 'ednsAdded' and 'optionAdded' if we process the query X-Git-Tag: dnsdist-1.7.0-beta1~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6de06c8ea9053eaa08140ab19327c917a94b78ce;p=thirdparty%2Fpdns.git dnsdist: Only update 'ednsAdded' and 'optionAdded' if we process the query --- diff --git a/pdns/dnsdist-ecs.cc b/pdns/dnsdist-ecs.cc index 0eda3ab993..e4e3bd6e8b 100644 --- a/pdns/dnsdist-ecs.cc +++ b/pdns/dnsdist-ecs.cc @@ -154,9 +154,6 @@ bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, assert(initialPacket.size() >= sizeof(dnsheader)); const struct dnsheader* dh = reinterpret_cast(initialPacket.data()); - optionAdded = false; - ednsAdded = true; - if (ntohs(dh->qdcount) == 0) { return false; } @@ -165,6 +162,9 @@ bool slowRewriteEDNSOptionInQueryWithRecords(const PacketBuffer& initialPacket, throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + " should not be called for queries that have no records"); } + optionAdded = false; + ednsAdded = true; + PacketReader pr(pdns_string_view(reinterpret_cast(initialPacket.data()), initialPacket.size())); size_t idx = 0; @@ -589,8 +589,6 @@ bool handleEDNSClientSubnet(PacketBuffer& packet, const size_t maximumSize, cons newContent.reserve(packet.size()); if (!slowRewriteEDNSOptionInQueryWithRecords(packet, newContent, ednsAdded, EDNSOptionCode::ECS, ecsAdded, overrideExisting, newECSOption)) { - ednsAdded = false; - ecsAdded = false; return false; }