From: Peter van Dijk Date: Tue, 9 Jul 2019 09:27:18 +0000 (+0200) Subject: centralise constant X-Git-Tag: auth-4.2.0-rc3~19^2~1^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e692c6ab2059eaf613ee08b96da7c689d4944771;p=pdns centralise constant (cherry picked from commit 43f038d7d1931bf499d8b03435b99feecea4d170) --- diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index ca95cc243..82ddce707 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -201,6 +201,7 @@ void DNSPacketWriter::xfrUnquotedText(const string& text, bool lenField) static constexpr bool l_verbose=false; +static constexpr uint16_t maxCompressionOffset=16384; uint16_t DNSPacketWriter::lookupName(const DNSName& name, uint16_t* matchLen) { // iterate over the written labels, see if we find a match @@ -268,7 +269,7 @@ uint16_t DNSPacketWriter::lookupName(const DNSName& name, uint16_t* matchLen) if(!c) break; auto offset = iter - d_content.cbegin(); - if (offset >= 16384) break; // compression pointers cannot point here + if (offset >= maxCompressionOffset) break; // compression pointers cannot point here pvect.push_back(offset); iter+=*iter+1; } @@ -328,14 +329,14 @@ void DNSPacketWriter::xfrName(const DNSName& name, bool compress, bool) uint16_t li=0; uint16_t matchlen=0; - if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < 16384) { + if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < maxCompressionOffset) { const auto& dns=name.getStorage(); if(l_verbose) cout<<"Found a substring of "<