From d476d7fb8f6524ea462d737d973235193d0a10e8 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 24 Apr 2014 17:24:28 +0300 Subject: [PATCH] Require that all text data is consumed when parsing records --- pdns/dnsparser.hh | 2 ++ pdns/dnsrecords.hh | 1 + pdns/dnswriter.hh | 1 + pdns/rcpgenerator.hh | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index e5686b06f5..20436ecbab 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -143,6 +143,8 @@ public: uint16_t d_pos; + bool eof() { return true; }; + private: uint16_t d_startrecordpos; // needed for getBlob later on uint16_t d_recordlen; // ditto diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index fd2197cc88..893f71a9f0 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -601,6 +601,7 @@ template \ void RNAME##RecordContent::xfrPacket(Convertor& conv) \ { \ CONV; \ + if (conv.eof() == false) throw MOADNSException("All data was not consumed"); \ } \ struct EDNSOpts diff --git a/pdns/dnswriter.hh b/pdns/dnswriter.hh index 17976bef00..1ea68a9e77 100644 --- a/pdns/dnswriter.hh +++ b/pdns/dnswriter.hh @@ -110,6 +110,7 @@ public: { return d_content; } + bool eof() { return true; } // we don't know how long the record should be private: vector & d_content; diff --git a/pdns/rcpgenerator.hh b/pdns/rcpgenerator.hh index b3bca59251..040ce7f51d 100644 --- a/pdns/rcpgenerator.hh +++ b/pdns/rcpgenerator.hh @@ -85,7 +85,7 @@ public: void xfrText(const string& val, bool multi=false); void xfrBlob(const string& val, int len=-1); void xfrHexBlob(const string& val, bool keepReading=false); - + bool eof() { return true; }; private: string& d_string; }; -- 2.47.2