]> granicus.if.org Git - pdns/commitdiff
improve error message on unparseable responses from backend, and also do not log...
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 29 Feb 2016 11:27:01 +0000 (12:27 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Mon, 29 Feb 2016 11:27:01 +0000 (12:27 +0100)
pdns/dnsdist.cc
pdns/dnsname.cc

index 995a893e05389eb0ba721807b0bd7061dd8f0834..042c9162f82a71e422b1c92c137d3cdb9c0b337e 100644 (file)
@@ -207,7 +207,8 @@ void* responderThread(std::shared_ptr<DownstreamState> state)
       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;
     }
index 94f7c542abf97c285d89305d9b5a3e6ccbc5ec41..2b1d269c6f3437c7bd2a7f225f4d8d9a43d384dc 100644 (file)
@@ -60,7 +60,7 @@ 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)
 {
   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)) {
@@ -79,7 +79,7 @@ void DNSName::packetParser(const char* qpos, int len, int offset, bool uncompres
   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;