From 43f038d7d1931bf499d8b03435b99feecea4d170 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 9 Jul 2019 11:27:18 +0200 Subject: [PATCH] centralise constant --- pdns/dnswriter.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 "<