]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Handle large YAML values for a backend weight
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 13:36:37 +0000 (15:36 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 13:36:37 +0000 (15:36 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-configuration-yaml.cc

index 27f74c1f3389a0932cac24bd5d0e95d79b6cd9e8..5bd884b4f8bf4bd7b225435408580cb5358b3914 100644 (file)
@@ -458,12 +458,12 @@ static std::shared_ptr<DownstreamState> createBackendFromConfiguration(const Con
   backendConfig.d_numberOfSockets = config.sockets;
   backendConfig.d_qpsLimit = config.queries_per_second;
   backendConfig.order = config.order;
-  if (config.weight < 1) {
+  if (config.weight < 1 || config.weight > std::numeric_limits<decltype(backendConfig.d_weight)>::max()) {
     SLOG(warnlog("Ignoring invalid weight on backend %s", std::string(config.address)),
          context.logger->info(Logr::Warning, "Ignoring invalid weight on backend", "backend.address", Logging::Loggable(config.address)));
   }
   else {
-    backendConfig.d_weight = config.weight;
+    backendConfig.d_weight = static_cast<int>(config.weight);
   }
 
   backendConfig.d_maxInFlightQueriesPerConn = config.max_in_flight;