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)
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;
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++;
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
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);
};