]> granicus.if.org Git - pdns/commitdiff
auth: Correctly check unknown record content size
authorRemi Gacogne <rgacogne-github@coredump.fr>
Mon, 24 Oct 2016 09:09:00 +0000 (11:09 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 12 Jan 2017 09:25:27 +0000 (10:25 +0100)
pdns/dnsparser.cc

index ebdcf0a067821a7c5cbe24cd9672c38283ce8e61..25f6851005b0bd891cc4692512478ae4b2734920 100644 (file)
@@ -44,8 +44,8 @@ public:
       throw MOADNSException("Unknown record was stored incorrectly, need 3 fields, got "+std::to_string(parts.size())+": "+zone );
     const string& relevant=(parts.size() > 2) ? parts[2] : "";
     unsigned int total=pdns_stou(parts[1]);
-    if(relevant.size()!=2*total)
-      throw MOADNSException((boost::format("invalid unknown record length for label %s: size not equal to length field (%d != %d)") % d_dr.d_name.toString() % relevant.size() % (2*total)).str());
+    if(relevant.size() % 2 || relevant.size() / 2 != total)
+      throw MOADNSException((boost::format("invalid unknown record length: size not equal to length field (%d != 2 * %d)") % relevant.size() % total).str());
     string out;
     out.reserve(total+1);
     for(unsigned int n=0; n < total; ++n) {