]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdns: Improve error when record data is not consumed
authorAki Tuomi <cmouse@cmouse.fi>
Mon, 8 Jan 2018 10:27:48 +0000 (12:27 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Mon, 8 Jan 2018 10:44:25 +0000 (12:44 +0200)
Old: "All data was not consumed"
New: "When parsing <qtype> trailing data was not parsed: '<remaining>'"

pdns/dnsparser.hh
pdns/dnsrecords.hh
pdns/dnswriter.hh
pdns/rcpgenerator.hh

index 78a73f03bebc3b23b89d8fc7c72ab6f57e725232..2df65e2ab17cbc1e7020e8850004d3dc1839ab83 100644 (file)
@@ -153,6 +153,9 @@ public:
   uint16_t d_pos;
 
   bool eof() { return true; };
+  const string getRemaining() const {
+    return "";
+  };
 
 private:
   uint16_t d_startrecordpos; // needed for getBlob later on
index 55afedbf2d40f91fd44fa60ea96ec303b67df8e7..f1154b77dbf44cecca0e756db918ce50530a409a 100644 (file)
@@ -746,7 +746,7 @@ template<class Convertor>                                         \
 void RNAME##RecordContent::xfrPacket(Convertor& conv, bool noDot) \
 {                                                                 \
   CONV;                                                           \
-  if (conv.eof() == false) throw MOADNSException("All data was not consumed"); \
+  if (conv.eof() == false) throw MOADNSException("When parsing " #RNAME " trailing data was not parsed: '" + conv.getRemaining() + "'"); \
 }                                                                 \
 
 struct EDNSOpts
index 49cf6955cac9ee49dac7bff778d7a02eac396deb..0227b920f0cabd3a77704e9913c69411cae9209e 100644 (file)
@@ -132,6 +132,9 @@ public:
   }
   bool eof() { return true; } // we don't know how long the record should be
 
+  const string getRemaining() const {
+    return "";
+  }
 private:
   uint16_t lookupName(const DNSName& name, uint16_t* matchlen);
   vector<uint16_t> d_namepositions;
index 5f61034e919a7db7d6678b548cf2b8a2014c0213..6fb3abf744b962d1677f4ee656e14507a724429a 100644 (file)
@@ -59,6 +59,10 @@ public:
   void xfrBlobNoSpaces(string& val, int len=-1);
   void xfrBlob(string& val, int len=-1);
 
+  const string getRemaining() const {
+    return d_string.substr(d_pos);
+  }
+
   bool eof();
 private:
   string d_string;
@@ -89,6 +93,10 @@ public:
   void xfrBlob(const string& val, int len=-1);
   void xfrHexBlob(const string& val, bool keepReading=false);
   bool eof() { return true; };
+
+  const string getRemaining() const {
+     return "";
+  }
 private:
   string& d_string;
   bool d_nodot;