qname=DNSName(packet, responseLen, sizeof(dnsheader), false, &qtype, &qclass, &consumed);
}
catch(std::exception& e) {
- infolog("Backend %s sent us a response that did not parse: %s", state->remote.toStringWithPort(), e.what());
+ if(got > (ssize_t)sizeof(dnsheader))
+ infolog("Backend %s sent us a response with id %d that did not parse: %s", state->remote.toStringWithPort(), ntohs(dh->id), e.what());
g_stats.nonCompliantResponses++;
continue;
}
DNSName::DNSName(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed)
{
if (offset >= len)
- throw std::range_error("Trying to read past the end of the buffer");
+ throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
if(!uncompress) {
if(const void * fnd=memchr(pos+offset, 0, len-offset)) {
const unsigned char *opos = pos;
if (offset >= len)
- throw std::range_error("Trying to read past the end of the buffer");
+ throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
pos += offset;
const unsigned char* end = pos + len;