]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
LUA view: do not crash on empty IP list, fixes #8572 8589/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 25 Nov 2019 12:05:22 +0000 (13:05 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 28 Nov 2019 09:47:10 +0000 (10:47 +0100)
(cherry picked from commit 28beeb0f76f2ba0dcea0def88fe46dbce51d06eb)

pdns/lua-record.cc

index 623b4bee07de1cbe6cb4cee8b1a7de1041b19086..fa7a9a0c6cb215ea529bfd60842448c41ca32789 100644 (file)
@@ -863,6 +863,9 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
         for(const auto& nmpair : netmasks) {
           Netmask nm(nmpair.second);
           if(nm.match(bestwho)) {
+            if (destinations.empty()) {
+              throw std::invalid_argument("The IP list cannot be empty (for netmask " + nm.toString() + ")");
+            }
             return destinations[dns_random(destinations.size())].second;
           }
         }