]> granicus.if.org Git - pdns/commitdiff
slightly improve error messages and reporting, attempting to zoom in on broken packets
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 12 Apr 2006 08:52:51 +0000 (08:52 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 12 Apr 2006 08:52:51 +0000 (08:52 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@682 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnsrecords.hh
pdns/lwres.cc
pdns/rcpgenerator.cc

index e604e6c33d8ccfbe5664c807172a92111ca3e69d..d8674fc19758aee11e7fded3a0976c550c4776dd 100644 (file)
@@ -293,8 +293,13 @@ void RNAME##RecordContent::report(void)
                                                                                                    \
 RNAME##RecordContent::RNAME##RecordContent(const string& zoneData) : DNSRecordContent(RTYPE)       \
 {                                                                                                  \
-  RecordTextReader rtr(zoneData);                                                                  \
-  xfrPacket(rtr);                                                                                  \
+  try {                                                                                            \
+    RecordTextReader rtr(zoneData);                                                                \
+    xfrPacket(rtr);                                                                                \
+  }                                                                                                \
+  catch(RecordTextException& rtr) {                                                                \
+    throw MOADNSParser("Parsing record content: "+string(rtr.what()));                             \
+  }                                                                                               \
 }                                                                                                  \
                                                                                                    \
 string RNAME##RecordContent::getZoneRepresentation() const                                         \
index b801144771d30c03bff390627046ef38c79d1081..8bd5b98a8a11b67554073125eaeda6056114023f 100644 (file)
@@ -35,6 +35,7 @@
 #include "syncres.hh"
 #include "dnswriter.hh"
 #include "dnsparser.hh"
+#include "logger.hh"
 
 LWRes::LWRes()
 {
@@ -154,11 +155,16 @@ LWRes::res_t LWRes::result()
     return ret;
     //    return p.getAnswers();
   }
+  catch(exception &mde) {
+    if(::arg().mustDo("log-common-errors"))
+      L<<Logger::Error<<"Unable to parse packet from remote server: "<<mde.what()<<"\n";
+  }
   catch(...) {
-    g_stats.serverParseError++; 
-    d_rcode=RCode::ServFail;
-    LWRes::res_t empty;
-    return empty;
+    L<<Logger::Error<<"Unknown error parsing packet from remote server"<<endl;
   }
+  g_stats.serverParseError++; 
+  d_rcode=RCode::ServFail;
+  LWRes::res_t empty;
+  return empty;
 }
 
index 78a8c759720dd17c8883c77628649fcaa2decdb6..2180ecb2ba2cc8f0ba02402e1b9636441df21f7e 100644 (file)
@@ -65,7 +65,7 @@ void RecordTextReader::xfrIP(uint32_t &val)
   skipSpaces();
 
   if(!isdigit(d_string.at(d_pos)))
-    throw RecordTextException("expected digits at position "+lexical_cast<string>(d_pos)+" in '"+d_string+"'");
+    throw RecordTextException("while parsing IP address, expected digits at position "+lexical_cast<string>(d_pos)+" in '"+d_string+"'");
   
   string ip;
   xfrLabel(ip);