]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add some sanity checking to rec_control wipe-cache 4165/head
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 12 Jul 2016 17:20:34 +0000 (19:20 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 18 Jul 2016 08:56:39 +0000 (10:56 +0200)
Closes #4098

pdns/rec_channel_rec.cc

index aefce242de74c4abe5ec8c2435d70f98ec03d643..2b96b2a5f1339cc7dcd6b1b443028df128ad6c01 100644 (file)
@@ -242,8 +242,22 @@ template<typename T>
 string doWipeCache(T begin, T end)
 {
   int count=0, countNeg=0;
+
+  vector<string> toWipe;
+
   for(T i=begin; i != end; ++i) {
     string canon=toCanonic("", *i);
+
+    if (canon[0] == '.')
+      return "dot found in the first place of " + canon + ". Nothing wiped.\n";
+
+    if (canon.find("..") != string::npos)
+      return "double dot found in " + canon + ". Nothing wiped.\n";
+
+    toWipe.push_back(canon);
+  }
+
+  BOOST_FOREACH(const string& canon, toWipe) {
     count+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon));
     countNeg+=broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, canon));
   }