]> granicus.if.org Git - pdns/commitdiff
fix storage of empty unknown records
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 4 Feb 2008 21:44:41 +0000 (21:44 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 4 Feb 2008 21:44:41 +0000 (21:44 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1129 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnsparser.cc

index fabadfa01d5b59c47a324b3e68df8d34787a13d8..5fc84ebb367364c42d0629e20c66109e2af31238 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2005 - 2007  PowerDNS.COM BV
+    Copyright (C) 2005 - 2008  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -19,6 +19,7 @@
 #include "dnsparser.hh"
 #include "dnswriter.hh"
 #include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
 
 using namespace boost;
 
@@ -53,9 +54,9 @@ public:
     string tmp((char*)&*d_record.begin(), d_record.size());
     vector<string> parts;
     stringtok(parts, tmp);
-    if(parts.size()!=3)
+    if(parts.size()!=3 && !(parts.size()==2 && equals(parts[1],"0")) )
       throw MOADNSException("Unknown record was stored incorrectly, need 3 fields, got "+lexical_cast<string>(parts.size())+": "+tmp );
-    const string& relevant=parts[2];
+    const string& relevant=(parts.size() > 2) ? parts[2] : "";
     unsigned int total=atoi(parts[1].c_str());
     if(relevant.size()!=2*total)
       throw runtime_error("invalid unknown record");