From: Aki Tuomi Date: Mon, 19 Oct 2015 07:34:14 +0000 (+0300) Subject: Remove d_recurse X-Git-Tag: dnsdist-1.0.0-alpha1~252^2~2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c6ce4f1f75175fd4b5417f8ac81aad93528b81d;p=pdns Remove d_recurse --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 5e6ffe134..5b5567648 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -24,7 +24,6 @@ std::ostream & operator<<(std::ostream &os, const DNSName& d) DNSName::DNSName(const char* p) { d_empty=false; - d_recurse=0; d_storage.reserve(strlen(p)+1); auto labels = segmentDNSName(p); for(const auto& e : labels) @@ -34,12 +33,11 @@ DNSName::DNSName(const char* p) DNSName::DNSName(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed) { d_empty=false; - d_recurse = 0; packetParser(pos, len, offset, uncompress, qtype, qclass, consumed); } // this should be the __only__ dns name parser in PowerDNS. -void DNSName::packetParser(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed) +void DNSName::packetParser(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, int depth) { unsigned char labellen; const char *opos = pos; @@ -54,9 +52,9 @@ void DNSName::packetParser(const char* pos, int len, int offset, bool uncompress int newpos = (labellen << 8) + *(const unsigned char*)pos; if(newpos < offset) { - if (++d_recurse > 100) + if (++depth > 100) throw std::range_error("Abort label decompression after 100 redirects"); - packetParser(opos, len, newpos, true); + packetParser(opos, len, newpos, true, 0, 0, 0, depth); } else throw std::range_error("Found a forward reference during label decompression"); pos++; diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 889b719c1..bdb191433 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -27,7 +27,7 @@ class DNSName { public: - DNSName() : d_empty(true), d_recurse(0) {} //!< Don't constructs the root name + DNSName() : d_empty(true) {} //!< Don't constructs the root name explicit DNSName(const char* p); //!< Constructs from a human formatted, escaped presentation explicit DNSName(const std::string& str) : DNSName(str.c_str()) {} //!< Constructs from a human formatted, escaped presentation DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0); //!< Construct from a DNS Packet, taking the first question if offset=12 @@ -87,9 +87,8 @@ private: bool slowCanonCompare(const DNSName& rhs) const; string_t d_storage; bool d_empty; - int d_recurse; - void packetParser(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0); + void packetParser(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0, int depth=0); static std::string escapeLabel(const std::string& orig); static std::string unescapeLabel(const std::string& orig); };