]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Make sure that setConsistentHashingBalancingFactor() >= 0 8567/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 22 Nov 2019 08:54:06 +0000 (09:54 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 22 Nov 2019 08:54:06 +0000 (09:54 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc

index 251a071f598721711ccc48d34b102bb36bed53a7..4976e3a667921e157c1301ccba63b7b791083f14 100644 (file)
@@ -1593,7 +1593,14 @@ void setupLuaConfig(bool client)
 
   g_lua.writeFunction("setConsistentHashingBalancingFactor", [](double factor) {
       setLuaSideEffect();
-      g_consistentHashBalancingFactor = factor;
+      if (factor >= 0) {
+        g_consistentHashBalancingFactor = factor;
+      }
+      else {
+        errlog("Invalid value passed to setConsistentHashingBalancingFactor()!");
+        g_outputBuffer="Invalid value passed to setConsistentHashingBalancingFactor()!\n";
+        return;
+      }
     });
 
   g_lua.writeFunction("setRingBuffersSize", [](size_t capacity, boost::optional<size_t> numberOfShards) {
index 4c3bb2cc529fb1210d4c72986a1a5534a7e66164..71066f1d0c7be9f8bd95a1a37029e895a6527d20 100644 (file)
@@ -896,7 +896,7 @@ shared_ptr<DownstreamState> chashed(const NumberedServerVector& servers, const D
   shared_ptr<DownstreamState> ret = nullptr, first = nullptr;
 
   double targetLoad = std::numeric_limits<double>::max();
-  if (g_consistentHashBalancingFactor != 0) {
+  if (g_consistentHashBalancingFactor > 0) {
     /* we start with one, representing the query we are currently handling */
     double currentLoad = 1;
     for (const auto& pair : servers) {